Bug fix for APCPowerReceiverBattery (#40188)

Initial commit
This commit is contained in:
chromiumboy
2025-09-07 09:52:27 -05:00
committed by GitHub
parent c1ca510e78
commit 499dde1ec1
2 changed files with 5 additions and 8 deletions

View File

@@ -33,8 +33,6 @@ namespace Content.Server.Power.Components
set
{
_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;
}
// 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
{

View File

@@ -347,6 +347,10 @@ namespace Content.Server.Power.EntitySystems
// 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
@@ -369,7 +373,6 @@ namespace Content.Server.Power.EntitySystems
if (apcBattery.Enabled != enableBattery)
{
apcBattery.Enabled = enableBattery;
metadata = MetaData(uid);
Dirty(uid, apcBattery, metadata);
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 (!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);