fix power cell exceptions with health analyzers (#15753)

This commit is contained in:
Nemanja
2023-04-24 21:11:03 -04:00
committed by GitHub
parent 5f3d3ecfc1
commit 53a33a5853

View File

@@ -224,7 +224,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
/// </summary> /// </summary>
public bool TryUseCharge(EntityUid uid, float charge, PowerCellSlotComponent? component = null, EntityUid? user = null) public bool TryUseCharge(EntityUid uid, float charge, PowerCellSlotComponent? component = null, EntityUid? user = null)
{ {
if (!TryGetBatteryFromSlot(uid, out var battery, component)) if (!TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery, component))
{ {
if (user != null) if (user != null)
_popup.PopupEntity(Loc.GetString("power-cell-no-battery"), uid, user.Value); _popup.PopupEntity(Loc.GetString("power-cell-no-battery"), uid, user.Value);
@@ -232,7 +232,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
return false; return false;
} }
if (!_battery.TryUseCharge(uid, charge, battery)) if (!_battery.TryUseCharge(batteryEnt.Value, charge, battery))
{ {
if (user != null) if (user != null)
_popup.PopupEntity(Loc.GetString("power-cell-insufficient"), uid, user.Value); _popup.PopupEntity(Loc.GetString("power-cell-insufficient"), uid, user.Value);