]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add method to clear an action's cooldown (#21517)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Wed, 8 Nov 2023 01:24:43 +0000 (17:24 -0800)
committerGitHub <noreply@github.com>
Wed, 8 Nov 2023 01:24:43 +0000 (18:24 -0700)
Content.Shared/Actions/SharedActionsSystem.cs

index d035e6ccfbf6cdb24272d6635e742e79ea7beb35..666110575a84e62ba50f03260e2ffa63c952465e 100644 (file)
@@ -126,6 +126,27 @@ public abstract class SharedActionsSystem : EntitySystem
         Dirty(actionId.Value, action);
     }
 
+    public void SetCooldown(EntityUid? actionId, TimeSpan cooldown)
+    {
+        var start = GameTiming.CurTime;
+        SetCooldown(actionId, start, start + cooldown);
+    }
+
+    public void ClearCooldown(EntityUid? actionId)
+    {
+        if (actionId == null)
+            return;
+
+        if (!TryGetActionData(actionId, out var action))
+            return;
+
+        if (action.Cooldown is not { } cooldown)
+            return;
+
+        action.Cooldown = (cooldown.Start, GameTiming.CurTime);
+        Dirty(actionId.Value, action);
+    }
+
     public void StartUseDelay(EntityUid? actionId)
     {
         if (actionId == null)