]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix: don't retroactively drain disabled batteries (#37364)
authorPerry Fraser <perryprog@users.noreply.github.com>
Mon, 12 May 2025 21:24:00 +0000 (17:24 -0400)
committerGitHub <noreply@github.com>
Mon, 12 May 2025 21:24:00 +0000 (23:24 +0200)
* 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

Content.Shared/PowerCell/SharedPowerCellSystem.cs
Content.Shared/PowerCell/ToggleCellDrawSystem.cs

index f098f575c4eac3f2f882d18c5e3f172f64adf2b1..3398563e556f5e15afd14ef5436b7a4113dbbfef 100644 (file)
@@ -26,7 +26,7 @@ public abstract class SharedPowerCellSystem : EntitySystem
 
     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)
@@ -71,20 +71,14 @@ public abstract class SharedPowerCellSystem : EntitySystem
         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)
     {
         if (!Resolve(ent, ref ent.Comp, false) || ent.Comp.Enabled == enabled)
             return;
 
+        if (enabled)
+            ent.Comp.NextUpdateTime = Timing.CurTime;
+
         ent.Comp.Enabled = enabled;
         Dirty(ent, ent.Comp);
     }
index 070937b8b49ed1426e3ad6ed42dc6061910399e1..14d91d2f5fb8f0ae59d1e7ba0e92ee2c0ccaf948 100644 (file)
@@ -38,7 +38,6 @@ public sealed class ToggleCellDrawSystem : EntitySystem
     {
         var uid = ent.Owner;
         var draw = Comp<PowerCellDrawComponent>(uid);
-        _cell.QueueUpdate((uid, draw));
         _cell.SetDrawEnabled((uid, draw), args.Activated);
     }