fix: don't retroactively drain disabled batteries (#37364)
* fix: don't retroactively drain disabled batteries If something that used PowerCellDraw temporarily disabled said draw, once it became re-enabled the system would play catch-up trying to drain the battery for all the time since the component was disabled. * fixup! fix: don't retroactively drain disabled batteries
This commit is contained in:
@@ -26,7 +26,7 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnMapInit(Entity<PowerCellDrawComponent> ent, ref MapInitEvent args)
|
private void OnMapInit(Entity<PowerCellDrawComponent> ent, ref MapInitEvent args)
|
||||||
{
|
{
|
||||||
QueueUpdate((ent, ent.Comp));
|
ent.Comp.NextUpdateTime = Timing.CurTime + ent.Comp.Delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRejuvenate(EntityUid uid, PowerCellSlotComponent component, RejuvenateEvent args)
|
private void OnRejuvenate(EntityUid uid, PowerCellSlotComponent component, RejuvenateEvent args)
|
||||||
@@ -71,20 +71,14 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
|||||||
RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false);
|
RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Makes the draw logic update in the next tick.
|
|
||||||
/// </summary>
|
|
||||||
public void QueueUpdate(Entity<PowerCellDrawComponent?> ent)
|
|
||||||
{
|
|
||||||
if (Resolve(ent, ref ent.Comp))
|
|
||||||
ent.Comp.NextUpdateTime = Timing.CurTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetDrawEnabled(Entity<PowerCellDrawComponent?> ent, bool enabled)
|
public void SetDrawEnabled(Entity<PowerCellDrawComponent?> ent, bool enabled)
|
||||||
{
|
{
|
||||||
if (!Resolve(ent, ref ent.Comp, false) || ent.Comp.Enabled == enabled)
|
if (!Resolve(ent, ref ent.Comp, false) || ent.Comp.Enabled == enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
ent.Comp.NextUpdateTime = Timing.CurTime;
|
||||||
|
|
||||||
ent.Comp.Enabled = enabled;
|
ent.Comp.Enabled = enabled;
|
||||||
Dirty(ent, ent.Comp);
|
Dirty(ent, ent.Comp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ public sealed class ToggleCellDrawSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
var uid = ent.Owner;
|
var uid = ent.Owner;
|
||||||
var draw = Comp<PowerCellDrawComponent>(uid);
|
var draw = Comp<PowerCellDrawComponent>(uid);
|
||||||
_cell.QueueUpdate((uid, draw));
|
|
||||||
_cell.SetDrawEnabled((uid, draw), args.Activated);
|
_cell.SetDrawEnabled((uid, draw), args.Activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user