mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
* the definition of insanity * the definition of insanity * the definition of insanity * we have hullrot at home * maybe the real hullrot was the friends we made along the way * john hullrot * i am going to hullroooooot * it's hullrotver * we're so hullback * we're rotting the hull with this one * hullmerge * the hullrot is leaking * never gonna rot you up * hullfresh * john starsector * god i wish we had grid collision damage * you can tell I am very tired because I stopped forcing a hullrot joke into every commit message * hr * this is a surprise sprite that will help us later * motherfucker * i have nothing good to say * still nothing * brb * random letter random letter random letter dash random number random number random number * ass * blast * ffs * fcuk * RE: ffs * RE: RE: ffs * гнида жестяная * continue * i hate tests * i love tests * slide to the right * i hate tests again * what the fuck * ты шиз? * ?? * bbgun
40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using Content.Server.Construction;
|
|
using Content.Server.Power.Components;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.Power.EntitySystems
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class UpgradeBatterySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly BatterySystem _batterySystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<UpgradeBatteryComponent, RefreshPartsEvent>(OnRefreshParts);
|
|
SubscribeLocalEvent<UpgradeBatteryComponent, UpgradeExamineEvent>(OnUpgradeExamine);
|
|
}
|
|
|
|
public void OnRefreshParts(EntityUid uid, UpgradeBatteryComponent component, RefreshPartsEvent args)
|
|
{
|
|
var powerCellRating = args.PartRatings[component.MachinePartPowerCapacity];
|
|
|
|
if (TryComp<BatteryComponent>(uid, out var batteryComp))
|
|
{
|
|
_batterySystem.SetMaxCharge(uid, MathF.Pow(component.MaxChargeMultiplier, powerCellRating) * component.BaseMaxCharge, batteryComp);
|
|
}
|
|
}
|
|
|
|
private void OnUpgradeExamine(EntityUid uid, UpgradeBatteryComponent component, UpgradeExamineEvent args)
|
|
{
|
|
// UpgradeBatteryComponent.MaxChargeMultiplier is not the actual multiplier, so we have to do this.
|
|
if (TryComp<BatteryComponent>(uid, out var batteryComp))
|
|
{
|
|
args.AddPercentageUpgrade("upgrade-max-charge", batteryComp.MaxCharge / component.BaseMaxCharge);
|
|
}
|
|
}
|
|
}
|
|
}
|