Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseEditorAction.c
Go to the documentation of this file.
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))]
34
35 [Attribute(SCR_Enum.GetDefault(EEditorActionGroup.NONE), uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditorActionGroup))]
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")]
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.")]
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 */
112 {
113 //if (!m_Info)
114 // m_Info = SCR_UIInfo.CreatePlaceholderInfo(SCR_UIInfo);
115
116 return m_Info;
117 }
118
127
132 string GetShortcut()
133 {
134 if (m_sShortcutRef)
135 return m_sShortcutRef;
136 else
137 return m_sShortcut;
138 }
139
143 void SetShortcutRef(string shortcutRef)
144 {
145 m_sShortcutRef = shortcutRef;
146 }
147
152 {
153 return m_iOrder;
154 }
155
160 bool IsServer()
161 {
162 return true;
163 }
164
172 {
173 return -1;
174 }
175
180 array<ref SCR_BaseEditorEffect> GetEffects()
181 {
182 return m_Effects;
183 }
184
185 protected void OnShortcut()
186 {
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 }
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
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
223 SCR_NotificationsComponent.SendLocal(ENotification.ACTION_ON_COOLDOWN, m_fCurrentCooldownTime * 100);
224
225 return true;
226 }
227
228 //~ Activate cooldown
230 return false;
231 }
232
238 {
239 return m_bIsOnCooldown;
240 }
241
242 //~ Start Cooldown
243 protected void ActivateCooldown()
244 {
245 if (m_fCooldownTime <= 0)
246 return;
247
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 {
260
261 if (m_fCurrentCooldownTime <= 0)
263 }
264
265 //~ Cooldown done
266 protected void OnCooldownDone()
267 {
268 GetGame().GetCallqueue().Remove(UpdateCooldown);
269 m_bIsOnCooldown = false;
270 }
271
273 {
274 //~ Remove cooldown from Call Queue
275 if (m_bIsOnCooldown)
277 }
278};
279
280class SCR_EditorActionData
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
304class 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
355class 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
420class SCR_WaypointActionParameters : SCR_ContextActionParameters
421{
422
423};
424
425class 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_EAIThreatSectorFlags flags
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
@ ACTION
EEditorActionType
EEditorActionGroup
@ COMMAND_SPAWN_POINT
Spawn points in command bar.
@ COMMAND_TASK
Tasks in command bar.
@ COMMAND_WAYPOINT
Waypoints in command bar.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
int Type
void AddShortcut(SCR_BaseActionsEditorComponent actionsManager)
bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags)
void PerformOwner(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags, int param=-1)
EEditorActionType GetActionType()
void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags, int param=-1)
bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags)
void SetShortcutRef(string shortcutRef)
array< ref SCR_BaseEditorEffect > GetEffects()
ref array< ref SCR_BaseEditorEffect > m_Effects
EEditorActionGroup m_ActionGroup
EEditorActionType m_ActionType
EEditorActionGroup GetActionGroup()
SCR_BaseActionsEditorComponent m_ActionsManager
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
@ NONE
When Shape is created and not initialized yet.
Definition ShapeType.c:15
SCR_FieldOfViewSettings Attribute
EActionTrigger
@ SIMULATION
dynamic bodies are colliding and are simulated
@ DYNAMIC
Include entities without enf::EntityFlags.TFL_STATIC.