]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add StartDelay bool to actions (#33026)
authorlzk <124214523+lzk228@users.noreply.github.com>
Mon, 28 Oct 2024 22:21:14 +0000 (23:21 +0100)
committerGitHub <noreply@github.com>
Mon, 28 Oct 2024 22:21:14 +0000 (23:21 +0100)
* add StartDelay bool to actions

* forgot summary

Content.Server/Ghost/GhostSystem.cs
Content.Shared/Actions/BaseActionComponent.cs
Content.Shared/Actions/SharedActionsSystem.cs
Content.Shared/Bed/Sleep/SleepingSystem.cs
Resources/Prototypes/Actions/types.yml
Resources/Prototypes/Entities/Mobs/Player/observer.yml

index 85fec0d7d1fd2b1524917b32c4b0be3bb526db5a..2f4269a05d004c7e08982ad9d236fd6bc70b44f0 100644 (file)
@@ -213,14 +213,7 @@ namespace Content.Server.Ghost
 
         private void OnMapInit(EntityUid uid, GhostComponent component, MapInitEvent args)
         {
-            if (_actions.AddAction(uid, ref component.BooActionEntity, out var act, component.BooAction)
-                && act.UseDelay != null)
-            {
-                var start = _gameTiming.CurTime;
-                var end = start + act.UseDelay.Value;
-                _actions.SetCooldown(component.BooActionEntity.Value, start, end);
-            }
-
+            _actions.AddAction(uid, ref component.BooActionEntity, component.BooAction);
             _actions.AddAction(uid, ref component.ToggleGhostHearingActionEntity, component.ToggleGhostHearingAction);
             _actions.AddAction(uid, ref component.ToggleLightingActionEntity, component.ToggleLightingAction);
             _actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
index 01452bdc72e0f49643ca05654e2971d2d9a48cd1..c3aa6cc97eebef76ff5db9bd3dada2ba1ac1f334 100644 (file)
@@ -76,6 +76,11 @@ public abstract partial class BaseActionComponent : Component
     // TODO serialization
     public (TimeSpan Start, TimeSpan End)? Cooldown;
 
+    /// <summary>
+    ///     If true, the action will have an initial cooldown applied upon addition.
+    /// </summary>
+    [DataField] public bool StartDelay = false;
+
     /// <summary>
     ///     Time interval between action uses.
     /// </summary>
index 76b8a1b081b49c29c53775d54afe3110b45fc1be..fc6f0baf7721a94fac5810d72d8af69027aa15cd 100644 (file)
@@ -813,6 +813,9 @@ public abstract class SharedActionsSystem : EntitySystem
         if (action.AttachedEntity != null)
             RemoveAction(action.AttachedEntity.Value, actionId, action: action);
 
+        if (action.StartDelay && action.UseDelay != null)
+            SetCooldown(actionId, action.UseDelay.Value);
+
         DebugTools.AssertOwner(performer, comp);
         comp ??= EnsureComp<ActionsComponent>(performer);
         action.AttachedEntity = performer;
index 6a04bfe42df7bfc0a1f621ac0f56d742167606cf..90e1fd38e862bbee2931b8022fcc0e7081dd2cae 100644 (file)
@@ -130,9 +130,6 @@ public sealed partial class SleepingSystem : EntitySystem
         RaiseLocalEvent(ent, ref ev);
         _blindableSystem.UpdateIsBlind(ent.Owner);
         _actionsSystem.AddAction(ent, ref ent.Comp.WakeAction, WakeActionId, ent);
-
-        // TODO remove hardcoded time.
-        _actionsSystem.SetCooldown(ent.Comp.WakeAction, _gameTiming.CurTime, _gameTiming.CurTime + TimeSpan.FromSeconds(2f));
     }
 
     private void OnSpeakAttempt(Entity<SleepingComponent> ent, ref SpeakAttemptEvent args)
index 5430a3f005a53881857419e42ed66c4fda01d156..d80e36bde1f22c11ddb7c78a18cc617db4e20758 100644 (file)
     checkCanInteract: false
     checkConsciousness: false
     event: !type:WakeActionEvent
+    startDelay: true
+    useDelay: 2
 
 - type: entity
   id: ActionActivateHonkImplant
index 397061defe8105e540efa7351558e90fd7dea28d..d7c5dfe97bbd0583f299c141f90315b772942246 100644 (file)
@@ -79,6 +79,7 @@
     icon: Interface/Actions/scream.png
     checkCanInteract: false
     event: !type:BooActionEvent
+    startDelay: true
     useDelay: 120
 
 - type: entity