Add APC power meter (#14196)

This commit is contained in:
Kevin Zheng
2023-02-21 07:23:38 -08:00
committed by GitHub
parent 322006ab81
commit 32b9a7b781
5 changed files with 14 additions and 2 deletions

View File

@@ -135,9 +135,12 @@ namespace Content.Server.Power.EntitySystems
if (!Resolve(uid, ref apc, ref battery, ref ui))
return;
var netBattery = Comp<PowerNetworkBatteryComponent>(uid);
float power = netBattery is not null ? netBattery.CurrentSupply : 0f;
if (_userInterfaceSystem.GetUiOrNull(uid, ApcUiKey.Key, ui) is { } bui)
{
bui.SetState(new ApcBoundInterfaceState(apc.MainBreakerEnabled, apc.LastExternalState, battery.CurrentCharge / battery.MaxCharge));
bui.SetState(new ApcBoundInterfaceState(apc.MainBreakerEnabled, (int)MathF.Ceiling(power), apc.LastExternalState, battery.CurrentCharge / battery.MaxCharge));
}
}