SMES and substation require power cells as machine parts (#20344)
* Initial commit * Balancing and tweaks
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Content.Server.Power.Components
|
|||||||
/// The machine part that affects the power capacity.
|
/// The machine part that affects the power capacity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("machinePartPowerCapacity", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
[DataField("machinePartPowerCapacity", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||||
public string MachinePartPowerCapacity = "Capacitor";
|
public string MachinePartPowerCapacity = "PowerCell";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The machine part rating is raised to this power when calculating power gain
|
/// The machine part rating is raised to this power when calculating power gain
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using Content.Server.Construction.Components;
|
||||||
|
using Content.Shared.Construction.Prototypes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
|
namespace Content.Server.Power.Components
|
||||||
|
{
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed partial class UpgradePowerSupplyRampingComponent : Component
|
||||||
|
{
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float BaseRampRate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The machine part that affects the power supply ramping
|
||||||
|
/// </summary>
|
||||||
|
[DataField("machinePartPowerCapacity", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||||
|
public string MachinePartRampRate = "Capacitor";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The multiplier used for scaling the power supply ramping
|
||||||
|
/// </summary>
|
||||||
|
[DataField("supplyRampingMultiplier")]
|
||||||
|
public float SupplyRampingMultiplier = 1f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// What type of scaling is being used?
|
||||||
|
/// </summary>
|
||||||
|
[DataField("scaling", required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public MachineUpgradeScalingType Scaling;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current value that the power supply is being scaled by
|
||||||
|
/// </summary>
|
||||||
|
[DataField("actualScalar"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float ActualScalar = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class UpgradeBatterySystem : EntitySystem
|
public sealed class UpgradeBatterySystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly BatterySystem _batterySystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -17,11 +19,11 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
|
|
||||||
public void OnRefreshParts(EntityUid uid, UpgradeBatteryComponent component, RefreshPartsEvent args)
|
public void OnRefreshParts(EntityUid uid, UpgradeBatteryComponent component, RefreshPartsEvent args)
|
||||||
{
|
{
|
||||||
var capacitorRating = args.PartRatings[component.MachinePartPowerCapacity];
|
var powerCellRating = args.PartRatings[component.MachinePartPowerCapacity];
|
||||||
|
|
||||||
if (TryComp<BatteryComponent>(uid, out var batteryComp))
|
if (TryComp<BatteryComponent>(uid, out var batteryComp))
|
||||||
{
|
{
|
||||||
batteryComp.MaxCharge = MathF.Pow(component.MaxChargeMultiplier, capacitorRating - 1) * component.BaseMaxCharge;
|
_batterySystem.SetMaxCharge(uid, MathF.Pow(component.MaxChargeMultiplier, powerCellRating - 1) * component.BaseMaxCharge, batteryComp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Server.Construction;
|
using Content.Server.Construction;
|
||||||
using Content.Server.Construction.Components;
|
using Content.Server.Construction.Components;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
|
||||||
@@ -20,6 +20,10 @@ public sealed class UpgradePowerSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<UpgradePowerSupplierComponent, MapInitEvent>(OnSupplierMapInit);
|
SubscribeLocalEvent<UpgradePowerSupplierComponent, MapInitEvent>(OnSupplierMapInit);
|
||||||
SubscribeLocalEvent<UpgradePowerSupplierComponent, RefreshPartsEvent>(OnSupplierRefreshParts);
|
SubscribeLocalEvent<UpgradePowerSupplierComponent, RefreshPartsEvent>(OnSupplierRefreshParts);
|
||||||
SubscribeLocalEvent<UpgradePowerSupplierComponent, UpgradeExamineEvent>(OnSupplierUpgradeExamine);
|
SubscribeLocalEvent<UpgradePowerSupplierComponent, UpgradeExamineEvent>(OnSupplierUpgradeExamine);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<UpgradePowerSupplyRampingComponent, MapInitEvent>(OnSupplyRampingMapInit);
|
||||||
|
SubscribeLocalEvent<UpgradePowerSupplyRampingComponent, RefreshPartsEvent>(OnSupplyRampingRefreshParts);
|
||||||
|
SubscribeLocalEvent<UpgradePowerSupplyRampingComponent, UpgradeExamineEvent>(OnSupplyRampingUpgradeExamine);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, UpgradePowerDrawComponent component, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, UpgradePowerDrawComponent component, MapInitEvent args)
|
||||||
@@ -76,7 +80,7 @@ public sealed class UpgradePowerSystem : EntitySystem
|
|||||||
switch (component.Scaling)
|
switch (component.Scaling)
|
||||||
{
|
{
|
||||||
case MachineUpgradeScalingType.Linear:
|
case MachineUpgradeScalingType.Linear:
|
||||||
supply += component.BaseSupplyRate * (rating - 1);
|
supply += component.PowerSupplyMultiplier * component.BaseSupplyRate * (rating - 1);
|
||||||
break;
|
break;
|
||||||
case MachineUpgradeScalingType.Exponential:
|
case MachineUpgradeScalingType.Exponential:
|
||||||
supply *= MathF.Pow(component.PowerSupplyMultiplier, rating - 1);
|
supply *= MathF.Pow(component.PowerSupplyMultiplier, rating - 1);
|
||||||
@@ -97,4 +101,39 @@ public sealed class UpgradePowerSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
args.AddPercentageUpgrade("upgrade-power-supply", component.ActualScalar);
|
args.AddPercentageUpgrade("upgrade-power-supply", component.ActualScalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSupplyRampingMapInit(EntityUid uid, UpgradePowerSupplyRampingComponent component, MapInitEvent args)
|
||||||
|
{
|
||||||
|
if (TryComp<PowerNetworkBatteryComponent>(uid, out var battery))
|
||||||
|
component.BaseRampRate = battery.SupplyRampRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSupplyRampingRefreshParts(EntityUid uid, UpgradePowerSupplyRampingComponent component, RefreshPartsEvent args)
|
||||||
|
{
|
||||||
|
var rampRate = component.BaseRampRate;
|
||||||
|
var rating = args.PartRatings[component.MachinePartRampRate];
|
||||||
|
switch (component.Scaling)
|
||||||
|
{
|
||||||
|
case MachineUpgradeScalingType.Linear:
|
||||||
|
rampRate += component.SupplyRampingMultiplier * component.BaseRampRate * (rating - 1);
|
||||||
|
break;
|
||||||
|
case MachineUpgradeScalingType.Exponential:
|
||||||
|
rampRate *= MathF.Pow(component.SupplyRampingMultiplier, rating - 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.Error($"invalid power supply ramping type for {ToPrettyString(uid)}.");
|
||||||
|
rampRate = component.BaseRampRate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
component.ActualScalar = rampRate / component.BaseRampRate;
|
||||||
|
|
||||||
|
if (TryComp<PowerNetworkBatteryComponent>(uid, out var battery))
|
||||||
|
battery.SupplyRampRate = rampRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSupplyRampingUpgradeExamine(EntityUid uid, UpgradePowerSupplyRampingComponent component, UpgradeExamineEvent args)
|
||||||
|
{
|
||||||
|
args.AddPercentageUpgrade("upgrade-power-supply-ramping", component.ActualScalar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ machine-part-name-matter-bin = Matter Bin
|
|||||||
upgrade-power-draw = power draw
|
upgrade-power-draw = power draw
|
||||||
upgrade-max-charge = max charge
|
upgrade-max-charge = max charge
|
||||||
upgrade-power-supply = power supply
|
upgrade-power-supply = power supply
|
||||||
|
upgrade-power-supply-ramping = power ramp rate
|
||||||
|
|
||||||
two-way-lever-left = push left
|
two-way-lever-left = push left
|
||||||
two-way-lever-right = push right
|
two-way-lever-right = push right
|
||||||
|
|||||||
@@ -476,7 +476,10 @@
|
|||||||
- type: MachineBoard
|
- type: MachineBoard
|
||||||
prototype: SMESBasicEmpty
|
prototype: SMESBasicEmpty
|
||||||
requirements:
|
requirements:
|
||||||
Capacitor: 5
|
Capacitor: 1
|
||||||
|
PowerCell: 4
|
||||||
|
materialRequirements:
|
||||||
|
CableHV: 10
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: CellRechargerCircuitboard
|
id: CellRechargerCircuitboard
|
||||||
@@ -553,7 +556,8 @@
|
|||||||
- type: MachineBoard
|
- type: MachineBoard
|
||||||
prototype: SubstationBasicEmpty
|
prototype: SubstationBasicEmpty
|
||||||
requirements:
|
requirements:
|
||||||
Capacitor: 3
|
Capacitor: 1
|
||||||
|
PowerCell: 1
|
||||||
materialRequirements:
|
materialRequirements:
|
||||||
CableMV: 5
|
CableMV: 5
|
||||||
CableHV: 5
|
CableHV: 5
|
||||||
|
|||||||
@@ -62,6 +62,9 @@
|
|||||||
- type: Battery
|
- type: Battery
|
||||||
maxCharge: 360
|
maxCharge: 360
|
||||||
startingCharge: 360
|
startingCharge: 360
|
||||||
|
- type: MachinePart
|
||||||
|
part: PowerCell
|
||||||
|
rating: 1
|
||||||
- type: Tag
|
- type: Tag
|
||||||
tags:
|
tags:
|
||||||
- PowerCellSmall
|
- PowerCellSmall
|
||||||
@@ -100,6 +103,9 @@
|
|||||||
- type: Battery
|
- type: Battery
|
||||||
maxCharge: 720
|
maxCharge: 720
|
||||||
startingCharge: 720
|
startingCharge: 720
|
||||||
|
- type: MachinePart
|
||||||
|
part: PowerCell
|
||||||
|
rating: 2
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PowerCellMediumPrinted
|
id: PowerCellMediumPrinted
|
||||||
@@ -135,7 +141,10 @@
|
|||||||
- type: Battery
|
- type: Battery
|
||||||
maxCharge: 1080
|
maxCharge: 1080
|
||||||
startingCharge: 1080
|
startingCharge: 1080
|
||||||
|
- type: MachinePart
|
||||||
|
part: PowerCell
|
||||||
|
rating: 3
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PowerCellHighPrinted
|
id: PowerCellHighPrinted
|
||||||
suffix: Empty
|
suffix: Empty
|
||||||
@@ -170,7 +179,10 @@
|
|||||||
- type: Battery
|
- type: Battery
|
||||||
maxCharge: 1800
|
maxCharge: 1800
|
||||||
startingCharge: 1800
|
startingCharge: 1800
|
||||||
|
- type: MachinePart
|
||||||
|
part: PowerCell
|
||||||
|
rating: 4
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PowerCellHyperPrinted
|
id: PowerCellHyperPrinted
|
||||||
suffix: Empty
|
suffix: Empty
|
||||||
|
|||||||
@@ -32,6 +32,9 @@
|
|||||||
- type: UpgradeBattery
|
- type: UpgradeBattery
|
||||||
maxChargeMultiplier: 2
|
maxChargeMultiplier: 2
|
||||||
baseMaxCharge: 8000000
|
baseMaxCharge: 8000000
|
||||||
|
- type: UpgradePowerSupplyRamping
|
||||||
|
scaling: Linear
|
||||||
|
supplyRampingMultiplier: 1
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: Battery
|
- type: Battery
|
||||||
startingCharge: 0
|
startingCharge: 0
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
- type: UpgradeBattery
|
- type: UpgradeBattery
|
||||||
maxChargeMultiplier: 2
|
maxChargeMultiplier: 2
|
||||||
baseMaxCharge: 2500000
|
baseMaxCharge: 2500000
|
||||||
|
- type: UpgradePowerSupplyRamping
|
||||||
|
scaling: Linear
|
||||||
|
supplyRampingMultiplier: 1
|
||||||
- type: Battery
|
- type: Battery
|
||||||
startingCharge: 0
|
startingCharge: 0
|
||||||
- type: ExaminableBattery
|
- type: ExaminableBattery
|
||||||
|
|||||||
@@ -12,3 +12,9 @@
|
|||||||
id: MatterBin
|
id: MatterBin
|
||||||
name: machine-part-name-matter-bin
|
name: machine-part-name-matter-bin
|
||||||
stockPartPrototype: MatterBinStockPart
|
stockPartPrototype: MatterBinStockPart
|
||||||
|
|
||||||
|
- type: machinePart
|
||||||
|
id: PowerCell
|
||||||
|
name: machine-part-name-power-cell
|
||||||
|
stockPartPrototype: PowerCellSmall
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user