mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
# Description By extremely popular demand(Both internally, and from our downstreams), this PR reimplements Part Upgrading. Since some of the systems that this PR touches were substantially changed since the removal of Parts, I had to do a lot of very in depth by-hand edits of individual systems. Shockingly, the only one that really proved any trouble was Cloning System, so I'm genuinely surprised wizden didn't substantially touch any of these codes since removing parts.. # Changelog 🆑 - add: Part Upgrading has returned! --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
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 - 1) * 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);
|
|
}
|
|
}
|
|
}
|
|
}
|