set
{
_needsPower = value;
- // Reset this so next tick will do a power update.
- Recalculate = true;
}
}
set => NetworkLoad.Enabled = !value;
}
- // TODO Is this needed? It forces a PowerChangedEvent when NeedsPower is toggled even if it changes to the same state.
- public bool Recalculate;
-
[ViewVariables]
public PowerState.Load NetworkLoad { get; } = new PowerState.Load
{
// Check if the entity has an internal battery
if (_apcBatteryQuery.TryComp(uid, out var apcBattery) && _batteryQuery.TryComp(uid, out var battery))
{
+ metadata = MetaData(uid);
+ if (Paused(uid, metadata))
+ continue;
+
apcReceiver.Load = apcBattery.IdleLoad;
// Try to draw power from the battery if there isn't sufficient external power
if (apcBattery.Enabled != enableBattery)
{
apcBattery.Enabled = enableBattery;
- metadata = MetaData(uid);
Dirty(uid, apcBattery, metadata);
var apcBatteryEv = new ApcPowerReceiverBatteryChangedEvent(enableBattery);
}
// If new value is the same as the old, then exit
- if (!apcReceiver.Recalculate && apcReceiver.Powered == powered)
+ if (apcReceiver.Powered == powered)
continue;
metadata ??= MetaData(uid);
if (Paused(uid, metadata))
continue;
- apcReceiver.Recalculate = false;
apcReceiver.Powered = powered;
Dirty(uid, apcReceiver, metadata);