Machine Battery Scaling (SMES/Substation) (#11662)
Co-authored-by: CommieFlowers <rasmus.cedergren@hotmail.com>
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user