diff --git a/Content.Server/Power/Components/UpgradeBatteryComponent.cs b/Content.Server/Power/Components/UpgradeBatteryComponent.cs new file mode 100644 index 0000000000..74a5328148 --- /dev/null +++ b/Content.Server/Power/Components/UpgradeBatteryComponent.cs @@ -0,0 +1,28 @@ +using Content.Shared.Construction.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Server.Power.Components +{ + + [RegisterComponent] + public sealed class UpgradeBatteryComponent : Component + { + /// + /// The machine part that affects the power capacity. + /// + [DataField("machinePartPowerCapacity", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string MachinePartPowerCapacity = "Capacitor"; + + /// + /// The machine part rating is raised to this power when calculating power gain + /// + [DataField("maxChargeMultiplier")] + public float MaxChargeMultiplier = 2f; + + /// + /// Power gain scaling + /// + [DataField("baseMaxCharge")] + public float BaseMaxCharge = 8000000; + } +} diff --git a/Content.Server/Power/EntitySystems/UpgradeBatterySystem.cs b/Content.Server/Power/EntitySystems/UpgradeBatterySystem.cs new file mode 100644 index 0000000000..0d48b76463 --- /dev/null +++ b/Content.Server/Power/EntitySystems/UpgradeBatterySystem.cs @@ -0,0 +1,27 @@ +using Content.Server.Construction; +using Content.Server.Power.Components; +using JetBrains.Annotations; + +namespace Content.Server.Power.SMES +{ + [UsedImplicitly] + public sealed class UpgradeBatterySystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnRefreshParts); + } + + public void OnRefreshParts(EntityUid uid, UpgradeBatteryComponent component, RefreshPartsEvent args) + { + var capacitorRating = args.PartRatings[component.MachinePartPowerCapacity]; + + if (TryComp(uid, out var batteryComp)) + { + batteryComp.MaxCharge = MathF.Pow(component.MaxChargeMultiplier, capacitorRating - 1) * component.BaseMaxCharge; + } + } + } +} diff --git a/Resources/Prototypes/Entities/Structures/Power/smes.yml b/Resources/Prototypes/Entities/Structures/Power/smes.yml index 38b1acfa54..8074059930 100644 --- a/Resources/Prototypes/Entities/Structures/Power/smes.yml +++ b/Resources/Prototypes/Entities/Structures/Power/smes.yml @@ -20,11 +20,13 @@ layers: - state: smes - type: Smes + - type: UpgradeBattery + maxChargeMultiplier: 2 + baseMaxCharge: 8000000 - type: Appearance visuals: - type: SmesVisualizer - type: Battery - maxCharge: 10000000 startingCharge: 0 - type: ExaminableBattery - type: NodeContainer @@ -66,11 +68,11 @@ - type: entity parent: BaseSMES id: SMESBasic - suffix: Basic, 10MW + suffix: Basic, 8MW components: - type: Battery - maxCharge: 10000000 - startingCharge: 10000000 + maxCharge: 8000000 + startingCharge: 8000000 - type: entity parent: SMESBasic diff --git a/Resources/Prototypes/Entities/Structures/Power/substation.yml b/Resources/Prototypes/Entities/Structures/Power/substation.yml index 1a06b6ce64..2f05f24dc4 100644 --- a/Resources/Prototypes/Entities/Structures/Power/substation.yml +++ b/Resources/Prototypes/Entities/Structures/Power/substation.yml @@ -17,8 +17,10 @@ shader: unshaded - state: full shader: unshaded + - type: UpgradeBattery + maxChargeMultiplier: 2 + baseMaxCharge: 2500000 - type: Battery - maxCharge: 4000000 startingCharge: 0 - type: ExaminableBattery - type: PointLight @@ -163,11 +165,11 @@ - type: entity parent: BaseSubstation id: SubstationBasic - suffix: Basic, 4MW + suffix: Basic, 2.5MW components: - type: Battery - maxCharge: 4000000 - startingCharge: 4000000 + maxCharge: 2500000 + startingCharge: 2500000 - type: entity parent: SubstationBasic