Fix battery charging stopping just short of being full (#34028)

This commit is contained in:
Errant
2025-01-10 07:54:55 +01:00
committed by GitHub
parent b42a01580c
commit 0b1ed3ec7e
5 changed files with 8 additions and 20 deletions

View File

@@ -223,10 +223,10 @@ internal sealed class ChargerSystem : EntitySystem
if (container.ContainedEntities.Count == 0)
return CellChargerStatus.Empty;
if (!SearchForBattery(container.ContainedEntities[0], out _, out var heldBattery))
if (!SearchForBattery(container.ContainedEntities[0], out var heldEnt, out var heldBattery))
return CellChargerStatus.Off;
if (Math.Abs(heldBattery.MaxCharge - heldBattery.CurrentCharge) < 0.01)
if (_battery.IsFull(heldEnt.Value, heldBattery))
return CellChargerStatus.Charged;
return CellChargerStatus.Charging;
@@ -247,12 +247,6 @@ internal sealed class ChargerSystem : EntitySystem
return;
_battery.SetCharge(batteryUid.Value, heldBattery.CurrentCharge + component.ChargeRate * frameTime, heldBattery);
// Just so the sprite won't be set to 99.99999% visibility
if (heldBattery.MaxCharge - heldBattery.CurrentCharge < 0.01)
{
_battery.SetCharge(batteryUid.Value, heldBattery.MaxCharge, heldBattery);
}
UpdateStatus(uid, component);
}