@@ -33,8 +33,6 @@ namespace Content.Server.Power.Components
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_needsPower = value;
|
_needsPower = value;
|
||||||
// Reset this so next tick will do a power update.
|
|
||||||
Recalculate = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,9 +49,6 @@ namespace Content.Server.Power.Components
|
|||||||
set => NetworkLoad.Enabled = !value;
|
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]
|
[ViewVariables]
|
||||||
public PowerState.Load NetworkLoad { get; } = new PowerState.Load
|
public PowerState.Load NetworkLoad { get; } = new PowerState.Load
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -347,6 +347,10 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
// Check if the entity has an internal battery
|
// Check if the entity has an internal battery
|
||||||
if (_apcBatteryQuery.TryComp(uid, out var apcBattery) && _batteryQuery.TryComp(uid, out var 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;
|
apcReceiver.Load = apcBattery.IdleLoad;
|
||||||
|
|
||||||
// Try to draw power from the battery if there isn't sufficient external power
|
// Try to draw power from the battery if there isn't sufficient external power
|
||||||
@@ -369,7 +373,6 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
if (apcBattery.Enabled != enableBattery)
|
if (apcBattery.Enabled != enableBattery)
|
||||||
{
|
{
|
||||||
apcBattery.Enabled = enableBattery;
|
apcBattery.Enabled = enableBattery;
|
||||||
metadata = MetaData(uid);
|
|
||||||
Dirty(uid, apcBattery, metadata);
|
Dirty(uid, apcBattery, metadata);
|
||||||
|
|
||||||
var apcBatteryEv = new ApcPowerReceiverBatteryChangedEvent(enableBattery);
|
var apcBatteryEv = new ApcPowerReceiverBatteryChangedEvent(enableBattery);
|
||||||
@@ -382,14 +385,13 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If new value is the same as the old, then exit
|
// If new value is the same as the old, then exit
|
||||||
if (!apcReceiver.Recalculate && apcReceiver.Powered == powered)
|
if (apcReceiver.Powered == powered)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
metadata ??= MetaData(uid);
|
metadata ??= MetaData(uid);
|
||||||
if (Paused(uid, metadata))
|
if (Paused(uid, metadata))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
apcReceiver.Recalculate = false;
|
|
||||||
apcReceiver.Powered = powered;
|
apcReceiver.Powered = powered;
|
||||||
Dirty(uid, apcReceiver, metadata);
|
Dirty(uid, apcReceiver, metadata);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user