Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BaseEditorAction.c
Go to the documentation of this file.
2 {
6 };
8 {
9  NONE,
13  DYNAMIC,
17 };
18 
19 //------------------------------------------------------------------------------------------------
20 [BaseContainerProps(configRoot:true)]
25 {
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;
28 
29  [Attribute()]
30  protected ref SCR_UIInfo m_Info;
31 
32  [Attribute(SCR_Enum.GetDefault(EEditorActionType.ACTION), uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditorActionType))]
33  protected EEditorActionType m_ActionType;
34 
35  [Attribute(SCR_Enum.GetDefault(EEditorActionGroup.NONE), uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditorActionGroup))]
36  protected EEditorActionGroup m_ActionGroup;
37 
38  [Attribute(desc: "Lower number is higher priority in the order")]
39  protected int m_iOrder;
40 
41  [Attribute()]
42  protected string m_sShortcut;
43 
44  [Attribute(defvalue: "true", desc: "If false will not execute the shortcut via toolbar when pressed")]
45  protected bool m_bEnableShortcutLogics;
46 
47  [Attribute(category: "Effects")]
48  protected ref array<ref SCR_BaseEditorEffect> m_Effects;
49 
50  protected SCR_BaseActionsEditorComponent m_ActionsManager;
51  protected string m_sShortcutRef;
52 
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;
55 
56  protected float m_fCurrentCooldownTime;
57 
58  //~ In mili seconds what is the update freq for the cooldown update. If changed updated the step param for m_fCooldownTime (m_fCooldownUpdateFreq / 1000)
59  protected float m_fCooldownUpdateFreq = 50;
60 
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;
63 
64  protected bool m_bIsOnCooldown;
65 
69  bool IsEnabled()
70  {
71  return m_bEnabled;
72  }
73 
77  bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
78  {
79  Print(string.Format("CanBeShown condition method not overridden for action %1, action won't show", Type()), LogLevel.WARNING);
80  return false;
81  }
82 
86  bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
87  {
88  return true;
89  }
90 
94  void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags, int param = -1)
95  {
96 
97  }
98 
99  /*
100  Local execution only, eg. effects or UI
101  */
102  void PerformOwner(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags, int param = -1)
103  {
104 
105  }
106 
107  /*
108  Get UI info representing the action.
109  \return UI info
110  */
111  SCR_UIInfo GetInfo()
112  {
113  //if (!m_Info)
114  // m_Info = SCR_UIInfo.CreatePlaceholderInfo(SCR_UIInfo);
115 
116  return m_Info;
117  }
118 
119  EEditorActionType GetActionType()
120  {
121  return m_ActionType;
122  }
123  EEditorActionGroup GetActionGroup()
124  {
125  return m_ActionGroup;
126  }
127 
132  string GetShortcut()
133  {
134  if (m_sShortcutRef)
135  return m_sShortcutRef;
136  else
137  return m_sShortcut;
138  }
143  void SetShortcutRef(string shortcutRef)
144  {
145  m_sShortcutRef = shortcutRef;
146  }
147 
151  int GetOrder()
152  {
153  return m_iOrder;
154  }
155 
160  bool IsServer()
161  {
162  return true;
163  }
164 
171  int GetParam()
172  {
173  return -1;
174  }
175 
180  array<ref SCR_BaseEditorEffect> GetEffects()
181  {
182  return m_Effects;
183  }
184 
185  protected void OnShortcut()
186  {
187  if (m_ActionsManager)
188  m_ActionsManager.ActionPerformInstantly(this);
189  }
190  void AddShortcut(SCR_BaseActionsEditorComponent actionsManager)
191  {
192  if (m_sShortcut.IsEmpty() || m_bEnableShortcutLogics == false)
193  return;
194 
195  m_ActionsManager = actionsManager;
196  GetGame().GetInputManager().AddActionListener(m_sShortcut, EActionTrigger.DOWN, OnShortcut);
197  }
198  void RemoveShortcut()
199  {
200  if (m_sShortcut.IsEmpty() || m_bEnableShortcutLogics == false)
201  return;
202 
203  m_ActionsManager = null;
204  GetGame().GetInputManager().RemoveActionListener(m_sShortcut, EActionTrigger.DOWN, OnShortcut);
205  }
206 
212  bool CheckAndSetCooldown()
213  {
214  //~ No Cooldown
215  if (m_fCooldownTime <= 0)
216  return false;
217 
218  //~ Is On Cooldown
219  if (IsOnCooldown())
220  {
221  //~ Send cooldown notification
222  if (m_bShowOnCooldownNotification)
223  SCR_NotificationsComponent.SendLocal(ENotification.ACTION_ON_COOLDOWN, m_fCurrentCooldownTime * 100);
224 
225  return true;
226  }
227 
228  //~ Activate cooldown
229  ActivateCooldown();
230  return false;
231  }
232 
237  bool IsOnCooldown()
238  {
239  return m_bIsOnCooldown;
240  }
241 
242  //~ Start Cooldown
243  protected void ActivateCooldown()
244  {
245  if (m_fCooldownTime <= 0)
246  return;
247 
248  m_fCurrentCooldownTime = m_fCooldownTime;
249 
250  m_bIsOnCooldown = true;
251 
252  //~ Add to callqueue to remove cooldown
253  GetGame().GetCallqueue().CallLater(UpdateCooldown, m_fCooldownUpdateFreq, true);
254  }
255 
256  //~ Update current cooldown
257  protected void UpdateCooldown()
258  {
259  m_fCurrentCooldownTime -= m_fCooldownUpdateFreq / 1000;
260 
261  if (m_fCurrentCooldownTime <= 0)
262  OnCooldownDone();
263  }
264 
265  //~ Cooldown done
266  protected void OnCooldownDone()
267  {
268  GetGame().GetCallqueue().Remove(UpdateCooldown);
269  m_bIsOnCooldown = false;
270  }
271 
272  void ~SCR_BaseEditorAction()
273  {
274  //~ Remove cooldown from Call Queue
275  if (m_bIsOnCooldown)
276  OnCooldownDone();
277  }
278 };
279 
281 {
282  private SCR_BaseEditorAction m_EditorAction;
283  private bool m_CanBePerformed;
284 
285  SCR_BaseEditorAction GetAction()
286  {
287  return m_EditorAction;
288  }
289 
290  bool GetCanBePerformed()
291  {
292  return m_CanBePerformed;
293  }
294 
295  void SCR_EditorActionData(SCR_BaseEditorAction action, bool canPerform)
296  {
297  m_EditorAction = action;
298  m_CanBePerformed = canPerform;
299  }
300 };
301 
302 
303 /* TESTING MULTIPLAYER SHENANIGANS
304 class SCR_BaseEditorActionParameters
305 {
306  int m_iTestInt;
307 
308  void SCR_BaseEditorActionParameters()
309  {
310 
311  }
312 
313  //################################################################################################
315  //------------------------------------------------------------------------------------------------
316  static void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
317  {
318  snapshot.Serialize(packet, 4);
319  }
320 
321  //------------------------------------------------------------------------------------------------
322  static bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
323  {
324  return snapshot.Serialize(packet, 4);
325  }
326 
327  //------------------------------------------------------------------------------------------------
328  static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx)
329  {
330  return lhs.CompareSnapshots(rhs, 4);
331  }
332 
333  //------------------------------------------------------------------------------------------------
334  static bool PropCompare(SCR_BaseEditorActionParameters prop, SSnapSerializerBase snapshot, ScriptCtx ctx)
335  {
336  return snapshot.Compare(prop.m_iTestInt, 4);
337  }
338 
339  //------------------------------------------------------------------------------------------------
340  static bool Extract(SCR_BaseEditorActionParameters prop, ScriptCtx ctx, SSnapSerializerBase snapshot)
341  {
342  snapshot.SerializeBytes(prop.m_iTestInt, 4);
343 
344  return true;
345  }
346 
347  //------------------------------------------------------------------------------------------------
348  static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, SCR_BaseEditorActionParameters prop)
349  {
350  snapshot.SerializeBytes(prop.m_iTestInt, 4);
351  return true;
352  }
353 };
354 
355 class SCR_ContextActionParameters : SCR_BaseEditorActionParameters
356 {
357  vector m_CursorWorldPosition = "100 100 100";
358 
359  void SCR_ContextActionParameters(vector cursorWorldPosition)
360  {
361  m_CursorWorldPosition = cursorWorldPosition;
362  }
363 
364  //################################################################################################
366  //------------------------------------------------------------------------------------------------
367  static override void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
368  {
369  snapshot.Serialize(packet, 16);
370  }
371 
372  //------------------------------------------------------------------------------------------------
373  static override bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
374  {
375  return snapshot.Serialize(packet, 16);
376  }
377 
378  //------------------------------------------------------------------------------------------------
379  static override bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx)
380  {
381  return lhs.CompareSnapshots(rhs, 16);
382  }
383 
384  //------------------------------------------------------------------------------------------------
385  static bool PropCompare(SCR_ContextActionParameters prop, SSnapSerializerBase snapshot, ScriptCtx ctx)
386  {
387  return SCR_BaseEditorActionParameters.PropCompare(prop, snapshot, ctx)
388  && snapshot.Compare(prop.m_CursorWorldPosition[0], 4)
389  && snapshot.Compare(prop.m_CursorWorldPosition[1], 4)
390  && snapshot.Compare(prop.m_CursorWorldPosition[2], 4);
391  }
392 
393  //------------------------------------------------------------------------------------------------
394  static bool Extract(SCR_ContextActionParameters prop, ScriptCtx ctx, SSnapSerializerBase snapshot)
395  {
396  SCR_BaseEditorActionParameters.Extract(prop, ctx, snapshot);
397  snapshot.SerializeBytes(prop.m_CursorWorldPosition[0], 4);
398  snapshot.SerializeBytes(prop.m_CursorWorldPosition[1], 4);
399  snapshot.SerializeBytes(prop.m_CursorWorldPosition[2], 4);
400 
401  return true;
402  }
403 
404  //------------------------------------------------------------------------------------------------
405  static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, SCR_ContextActionParameters prop)
406  {
407  SCR_BaseEditorActionParameters.Inject(snapshot, ctx, prop);
408  float temp;
409  prop.m_CursorWorldPosition = vector.Zero;
410  snapshot.SerializeBytes(temp, 4);
411  prop.m_CursorWorldPosition[0] = temp;
412  snapshot.SerializeBytes(temp, 4);
413  prop.m_CursorWorldPosition[1] = temp;
414  snapshot.SerializeBytes(temp, 4);
415  prop.m_CursorWorldPosition[2] = temp;
416  return true;
417  }
418 };
419 
420 class SCR_WaypointActionParameters : SCR_ContextActionParameters
421 {
422 
423 };
424 
425 class SCR_ToolbarActionParameters : SCR_ContextActionParameters
426 {
427  int m_iPlacedEntityId;
428  bool m_bShortcutTriggered;
429 
430  void SCR_ToolbarActionParameters(vector cursorWorldPosition, bool shortcutTriggered = false, int placedEntityId = -1)
431  {
432  m_CursorWorldPosition = cursorWorldPosition;
433  m_iPlacedEntityId = placedEntityId;
434  m_bShortcutTriggered = shortcutTriggered;
435  }
436 
437  //################################################################################################
439  //------------------------------------------------------------------------------------------------
440  static override void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
441  {
442  snapshot.Serialize(packet, 20);
443  }
444 
445  //------------------------------------------------------------------------------------------------
446  static override bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
447  {
448  return snapshot.Serialize(packet, 20);
449  }
450 
451  //------------------------------------------------------------------------------------------------
452  static override bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx)
453  {
454  return lhs.CompareSnapshots(rhs, 20);
455  }
456 
457  //------------------------------------------------------------------------------------------------
458  static bool PropCompare(SCR_ToolbarActionParameters prop, SSnapSerializerBase snapshot, ScriptCtx ctx)
459  {
460  return SCR_ContextActionParameters.PropCompare(prop, snapshot, ctx)
461  && snapshot.Compare(prop.m_iPlacedEntityId, 4);
462  }
463 
464  //------------------------------------------------------------------------------------------------
465  static bool Extract(SCR_ToolbarActionParameters prop, ScriptCtx ctx, SSnapSerializerBase snapshot)
466  {
467  SCR_ContextActionParameters.Extract(prop, ctx, snapshot);
468  snapshot.SerializeBytes(prop.m_iPlacedEntityId, 4);
469  return true;
470  }
471 
472  //------------------------------------------------------------------------------------------------
473  static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, SCR_ToolbarActionParameters prop)
474  {
475  SCR_ContextActionParameters.Inject(snapshot, ctx, prop);
476  snapshot.SerializeBytes(prop.m_iPlacedEntityId, 4);
477  return true;
478  }
479 };
480 */
SCR_BaseEditorAction
Definition: SCR_BaseEditorAction.c:24
m_ActionGroup
EEditorActionGroup m_ActionGroup
Definition: SCR_BaseActionsEditorComponent.c:3
SCR_Enum
Definition: SCR_Enum.c:1
COMMAND_TASK
@ COMMAND_TASK
Tasks in command bar.
Definition: SCR_BaseEditorAction.c:15
EEditorActionType
EEditorActionType
Definition: SCR_BaseEditorAction.c:1
ACTION
@ ACTION
Definition: SCR_BaseEditorAction.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SIMULATION
@ SIMULATION
Definition: SCR_BaseEditorAction.c:10
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EditorActionData
Definition: SCR_BaseEditorAction.c:280
TOGGLE
@ TOGGLE
Definition: SCR_BaseEditorAction.c:4
TOOLS
@ TOOLS
Definition: SCR_BaseEditorAction.c:12
m_iOrder
int m_iOrder
Definition: SCR_BaseActionsEditorComponent.c:6
ENotification
ENotification
Definition: ENotification.c:4
Attribute
typedef Attribute
Post-process effect of scripted camera.
COMMAND_WAYPOINT
@ COMMAND_WAYPOINT
Waypoints in command bar.
Definition: SCR_BaseEditorAction.c:14
m_Info
protected ref SCR_HintUIInfo m_Info
Definition: SCR_BaseHintCondition.c:3
DYNAMIC
@ DYNAMIC
Definition: SCR_BaseEditorAction.c:5
SAVING
@ SAVING
Definition: SCR_BaseEditorAction.c:11
SCR_UIInfo
Definition: SCR_UIInfo.c:7
EEditorActionGroup
EEditorActionGroup
Definition: SCR_BaseEditorAction.c:7
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
COMMAND_SPAWN_POINT
@ COMMAND_SPAWN_POINT
Spawn points in command bar.
Definition: SCR_BaseEditorAction.c:16
m_ActionType
EEditorActionType m_ActionType
Definition: SCR_ActionsToolbarEditorUIComponent.c:3
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
NONE
@ NONE
Definition: SCR_BaseEditorAction.c:9
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180