Machine Battery Scaling (SMES/Substation) (#11662)

Co-authored-by: CommieFlowers <rasmus.cedergren@hotmail.com>
This commit is contained in:
rolfero
2022-10-04 02:59:39 +02:00
committed by GitHub
parent 0c24f8b69b
commit f8c4c2d449
4 changed files with 67 additions and 8 deletions

View 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;
}
}
}
}