From dc3a2f6d28c50abaab5453fd1aabe79e1b2ff859 Mon Sep 17 00:00:00 2001 From: lzk <124214523+lzk228@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:21:14 +0100 Subject: [PATCH] add StartDelay bool to actions (#33026) * add StartDelay bool to actions * forgot summary --- Content.Server/Ghost/GhostSystem.cs | 9 +-------- Content.Shared/Actions/BaseActionComponent.cs | 5 +++++ Content.Shared/Actions/SharedActionsSystem.cs | 3 +++ Content.Shared/Bed/Sleep/SleepingSystem.cs | 3 --- Resources/Prototypes/Actions/types.yml | 2 ++ Resources/Prototypes/Entities/Mobs/Player/observer.yml | 1 + 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index 85fec0d7d1..2f4269a05d 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -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); diff --git a/Content.Shared/Actions/BaseActionComponent.cs b/Content.Shared/Actions/BaseActionComponent.cs index 01452bdc72..c3aa6cc97e 100644 --- a/Content.Shared/Actions/BaseActionComponent.cs +++ b/Content.Shared/Actions/BaseActionComponent.cs @@ -76,6 +76,11 @@ public abstract partial class BaseActionComponent : Component // TODO serialization public (TimeSpan Start, TimeSpan End)? Cooldown; + /// + /// If true, the action will have an initial cooldown applied upon addition. + /// + [DataField] public bool StartDelay = false; + /// /// Time interval between action uses. /// diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 76b8a1b081..fc6f0baf77 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -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(performer); action.AttachedEntity = performer; diff --git a/Content.Shared/Bed/Sleep/SleepingSystem.cs b/Content.Shared/Bed/Sleep/SleepingSystem.cs index 6a04bfe42d..90e1fd38e8 100644 --- a/Content.Shared/Bed/Sleep/SleepingSystem.cs +++ b/Content.Shared/Bed/Sleep/SleepingSystem.cs @@ -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 ent, ref SpeakAttemptEvent args) diff --git a/Resources/Prototypes/Actions/types.yml b/Resources/Prototypes/Actions/types.yml index 5430a3f005..d80e36bde1 100644 --- a/Resources/Prototypes/Actions/types.yml +++ b/Resources/Prototypes/Actions/types.yml @@ -280,6 +280,8 @@ checkCanInteract: false checkConsciousness: false event: !type:WakeActionEvent + startDelay: true + useDelay: 2 - type: entity id: ActionActivateHonkImplant diff --git a/Resources/Prototypes/Entities/Mobs/Player/observer.yml b/Resources/Prototypes/Entities/Mobs/Player/observer.yml index 397061defe..d7c5dfe97b 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/observer.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/observer.yml @@ -79,6 +79,7 @@ icon: Interface/Actions/scream.png checkCanInteract: false event: !type:BooActionEvent + startDelay: true useDelay: 120 - type: entity