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

@@ -87,8 +87,8 @@ namespace Content.Server.Power.EntitySystems
var query = EntityQueryEnumerator<BatterySelfRechargerComponent, BatteryComponent>();
while (query.MoveNext(out var uid, out var comp, out var batt))
{
if (!comp.AutoRecharge) continue;
if (batt.IsFullyCharged) continue;
if (!comp.AutoRecharge || IsFull(uid, batt))
continue;
if (comp.AutoRechargePause)
{
@@ -212,14 +212,14 @@ namespace Content.Server.Power.EntitySystems
}
/// <summary>
/// Returns whether the battery is at least 99% charged, basically full.
/// Returns whether the battery is full.
/// </summary>
public bool IsFull(EntityUid uid, BatteryComponent? battery = null)
{
if (!Resolve(uid, ref battery))
return false;
return battery.CurrentCharge / battery.MaxCharge >= 0.99f;
return battery.CurrentCharge >= battery.MaxCharge;
}
}
}