Machine Battery Scaling (SMES/Substation) (#11662)
Co-authored-by: CommieFlowers <rasmus.cedergren@hotmail.com>
This commit is contained in:
28
Content.Server/Power/Components/UpgradeBatteryComponent.cs
Normal file
28
Content.Server/Power/Components/UpgradeBatteryComponent.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The machine part that affects the power capacity.
|
||||
/// </summary>
|
||||
[DataField("machinePartPowerCapacity", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||
public string MachinePartPowerCapacity = "Capacitor";
|
||||
|
||||
/// <summary>
|
||||
/// The machine part rating is raised to this power when calculating power gain
|
||||
/// </summary>
|
||||
[DataField("maxChargeMultiplier")]
|
||||
public float MaxChargeMultiplier = 2f;
|
||||
|
||||
/// <summary>
|
||||
/// Power gain scaling
|
||||
/// </summary>
|
||||
[DataField("baseMaxCharge")]
|
||||
public float BaseMaxCharge = 8000000;
|
||||
}
|
||||
}
|
||||
27
Content.Server/Power/EntitySystems/UpgradeBatterySystem.cs
Normal file
27
Content.Server/Power/EntitySystems/UpgradeBatterySystem.cs
Normal file
@@ -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<UpgradeBatteryComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
}
|
||||
|
||||
public void OnRefreshParts(EntityUid uid, UpgradeBatteryComponent component, RefreshPartsEvent args)
|
||||
{
|
||||
var capacitorRating = args.PartRatings[component.MachinePartPowerCapacity];
|
||||
|
||||
if (TryComp<BatteryComponent>(uid, out var batteryComp))
|
||||
{
|
||||
batteryComp.MaxCharge = MathF.Pow(component.MaxChargeMultiplier, capacitorRating - 1) * component.BaseMaxCharge;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user