26 [
Attribute(
"1",
desc:
"When disabled, the action will not appear in action list.\nUse to temporary hide actions without losing their configuration.")]
27 protected bool m_bEnabled;
38 [
Attribute(
desc:
"Lower number is higher priority in the order")]
39 protected int m_iOrder;
42 protected string m_sShortcut;
44 [
Attribute(defvalue:
"true",
desc:
"If false will not execute the shortcut via toolbar when pressed")]
45 protected bool m_bEnableShortcutLogics;
48 protected ref array<ref SCR_BaseEditorEffect> m_Effects;
50 protected SCR_BaseActionsEditorComponent m_ActionsManager;
51 protected string m_sShortcutRef;
53 [
Attribute(
"0",
desc:
"Cooldown to prevent spamming of action. Leave zero or less to ignore, time in seconds.",
params:
"0, inf, 0.05")]
54 protected float m_fCooldownTime;
56 protected float m_fCurrentCooldownTime;
59 protected float m_fCooldownUpdateFreq = 50;
61 [
Attribute(
"1",
desc:
"If true will show notification if trying to perform the action if the cooldown is active.")]
62 protected bool m_bShowOnCooldownNotification;
64 protected bool m_bIsOnCooldown;
77 bool CanBeShown(
SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,
int flags)
79 Print(
string.Format(
"CanBeShown condition method not overridden for action %1, action won't show", Type()), LogLevel.WARNING);
86 bool CanBePerformed(
SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,
int flags)
94 void Perform(
SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,
int flags,
int param = -1)
102 void PerformOwner(
SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,
int flags,
int param = -1)
135 return m_sShortcutRef;
143 void SetShortcutRef(
string shortcutRef)
145 m_sShortcutRef = shortcutRef;
180 array<ref SCR_BaseEditorEffect> GetEffects()
185 protected void OnShortcut()
187 if (m_ActionsManager)
188 m_ActionsManager.ActionPerformInstantly(
this);
190 void AddShortcut(SCR_BaseActionsEditorComponent actionsManager)
192 if (m_sShortcut.IsEmpty() || m_bEnableShortcutLogics ==
false)
195 m_ActionsManager = actionsManager;
196 GetGame().GetInputManager().AddActionListener(m_sShortcut, EActionTrigger.DOWN, OnShortcut);
198 void RemoveShortcut()
200 if (m_sShortcut.IsEmpty() || m_bEnableShortcutLogics ==
false)
203 m_ActionsManager =
null;
204 GetGame().GetInputManager().RemoveActionListener(m_sShortcut, EActionTrigger.DOWN, OnShortcut);
212 bool CheckAndSetCooldown()
215 if (m_fCooldownTime <= 0)
222 if (m_bShowOnCooldownNotification)
223 SCR_NotificationsComponent.SendLocal(
ENotification.ACTION_ON_COOLDOWN, m_fCurrentCooldownTime * 100);
239 return m_bIsOnCooldown;
243 protected void ActivateCooldown()
245 if (m_fCooldownTime <= 0)
248 m_fCurrentCooldownTime = m_fCooldownTime;
250 m_bIsOnCooldown =
true;
253 GetGame().GetCallqueue().CallLater(UpdateCooldown, m_fCooldownUpdateFreq,
true);
257 protected void UpdateCooldown()
259 m_fCurrentCooldownTime -= m_fCooldownUpdateFreq / 1000;
261 if (m_fCurrentCooldownTime <= 0)
266 protected void OnCooldownDone()
268 GetGame().GetCallqueue().Remove(UpdateCooldown);
269 m_bIsOnCooldown =
false;
283 private bool m_CanBePerformed;
287 return m_EditorAction;
290 bool GetCanBePerformed()
292 return m_CanBePerformed;
297 m_EditorAction = action;
298 m_CanBePerformed = canPerform;