Implement Equals for ApcBoundInterfaceState (#27965)
* Implement Equals for ApcBoundInterfaceState Saves a lot on bandwidth. Also made it round to the nearest 5. * Also this
This commit is contained in:
@@ -8,6 +8,7 @@ using Content.Shared.APC;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Rounding;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
@@ -147,10 +148,14 @@ public sealed class ApcSystem : EntitySystem
|
||||
return;
|
||||
|
||||
var battery = netBat.NetworkBattery;
|
||||
const int ChargeAccuracy = 5;
|
||||
|
||||
// TODO: Fix ContentHelpers or make a new one coz this is cooked.
|
||||
var charge = ContentHelpers.RoundToNearestLevels(battery.CurrentStorage / battery.Capacity, 1.0, 100 / ChargeAccuracy) / 100f * ChargeAccuracy;
|
||||
|
||||
var state = new ApcBoundInterfaceState(apc.MainBreakerEnabled, apc.HasAccess,
|
||||
(int) MathF.Ceiling(battery.CurrentSupply), apc.LastExternalState,
|
||||
battery.CurrentStorage / battery.Capacity);
|
||||
charge);
|
||||
|
||||
_ui.SetUiState((uid, ui), ApcUiKey.Key, state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user