add StartDelay bool to actions (#33026)
* add StartDelay bool to actions * forgot summary
This commit is contained in:
@@ -213,14 +213,7 @@ namespace Content.Server.Ghost
|
|||||||
|
|
||||||
private void OnMapInit(EntityUid uid, GhostComponent component, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, GhostComponent component, MapInitEvent args)
|
||||||
{
|
{
|
||||||
if (_actions.AddAction(uid, ref component.BooActionEntity, out var act, component.BooAction)
|
_actions.AddAction(uid, ref component.BooActionEntity, 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.ToggleGhostHearingActionEntity, component.ToggleGhostHearingAction);
|
_actions.AddAction(uid, ref component.ToggleGhostHearingActionEntity, component.ToggleGhostHearingAction);
|
||||||
_actions.AddAction(uid, ref component.ToggleLightingActionEntity, component.ToggleLightingAction);
|
_actions.AddAction(uid, ref component.ToggleLightingActionEntity, component.ToggleLightingAction);
|
||||||
_actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
|
_actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ public abstract partial class BaseActionComponent : Component
|
|||||||
// TODO serialization
|
// TODO serialization
|
||||||
public (TimeSpan Start, TimeSpan End)? Cooldown;
|
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>
|
/// <summary>
|
||||||
/// Time interval between action uses.
|
/// Time interval between action uses.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -813,6 +813,9 @@ public abstract class SharedActionsSystem : EntitySystem
|
|||||||
if (action.AttachedEntity != null)
|
if (action.AttachedEntity != null)
|
||||||
RemoveAction(action.AttachedEntity.Value, actionId, action: action);
|
RemoveAction(action.AttachedEntity.Value, actionId, action: action);
|
||||||
|
|
||||||
|
if (action.StartDelay && action.UseDelay != null)
|
||||||
|
SetCooldown(actionId, action.UseDelay.Value);
|
||||||
|
|
||||||
DebugTools.AssertOwner(performer, comp);
|
DebugTools.AssertOwner(performer, comp);
|
||||||
comp ??= EnsureComp<ActionsComponent>(performer);
|
comp ??= EnsureComp<ActionsComponent>(performer);
|
||||||
action.AttachedEntity = performer;
|
action.AttachedEntity = performer;
|
||||||
|
|||||||
@@ -130,9 +130,6 @@ public sealed partial class SleepingSystem : EntitySystem
|
|||||||
RaiseLocalEvent(ent, ref ev);
|
RaiseLocalEvent(ent, ref ev);
|
||||||
_blindableSystem.UpdateIsBlind(ent.Owner);
|
_blindableSystem.UpdateIsBlind(ent.Owner);
|
||||||
_actionsSystem.AddAction(ent, ref ent.Comp.WakeAction, WakeActionId, ent);
|
_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)
|
private void OnSpeakAttempt(Entity<SleepingComponent> ent, ref SpeakAttemptEvent args)
|
||||||
|
|||||||
@@ -280,6 +280,8 @@
|
|||||||
checkCanInteract: false
|
checkCanInteract: false
|
||||||
checkConsciousness: false
|
checkConsciousness: false
|
||||||
event: !type:WakeActionEvent
|
event: !type:WakeActionEvent
|
||||||
|
startDelay: true
|
||||||
|
useDelay: 2
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ActionActivateHonkImplant
|
id: ActionActivateHonkImplant
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
icon: Interface/Actions/scream.png
|
icon: Interface/Actions/scream.png
|
||||||
checkCanInteract: false
|
checkCanInteract: false
|
||||||
event: !type:BooActionEvent
|
event: !type:BooActionEvent
|
||||||
|
startDelay: true
|
||||||
useDelay: 120
|
useDelay: 120
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
|
|||||||
Reference in New Issue
Block a user