add StartDelay bool to actions (#33026)

* add StartDelay bool to actions

* forgot summary
This commit is contained in:
lzk
2024-10-28 23:21:14 +01:00
committed by GitHub
parent 7ac2d9a8bd
commit dc3a2f6d28
6 changed files with 12 additions and 11 deletions

View 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);

View 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>

View 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;

View 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)

View File

@@ -280,6 +280,8 @@
checkCanInteract: false
checkConsciousness: false
event: !type:WakeActionEvent
startDelay: true
useDelay: 2
- type: entity
id: ActionActivateHonkImplant

View File

@@ -79,6 +79,7 @@
icon: Interface/Actions/scream.png
checkCanInteract: false
event: !type:BooActionEvent
startDelay: true
useDelay: 120
- type: entity