Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkDebug.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
5 static void OnDiag()
6 {
7 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_TASKS))
8 Tasks();
9
10 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_REGISTERED_AREAS))
11 RegisteredAreas();
12
13 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_DEBUG_AREAS))
14 DebugAreas();
15
16 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_LAYER_INSPECTOR))
17 LayerInspector();
18
19 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_ACTION_INSPECTOR))
20 ActionInspector();
21
22 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_LOGIC_INSPECTOR))
23 LogicInspector();
24
25 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_PLUGIN_INSPECTOR))
26 PluginInspector();
27
28 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_CONDITION_INSPECTOR))
29 ConditionInspector();
30
31 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_DEBUG_ACTIONS))
32 DebugActions();
33
34 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_FINISH_TASK))
35 {
36 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
37 if (taskSystem)
38 {
39 SCR_Task task = taskSystem.GetTaskAssignedTo(SCR_TaskExecutor.FromLocalPlayer());
40 if (task)
41 task.SetTaskState(SCR_ETaskState.COMPLETED);
42 }
43 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_SCENARIO_FRAMEWORK_FINISH_TASK, 0);
44 }
45 }
46
47 //------------------------------------------------------------------------------------------------
49 static void Tasks()
50 {
51 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
52 if (!taskSystem)
53 return;
54
55 DbgUI.Begin("ScenarioFramework Tasks");
56 {
57 array<SCR_ScenarioFrameworkTask> scenarioFrameworkTasks = {};
58 array<SCR_Task> finishedTasks = {};
59 array<string> listElements = {};
60 array<SCR_Task> tasks = {};
61 taskSystem.GetTasks(tasks);
62 SCR_ScenarioFrameworkTask scenarioFrameworkTask;
63 SCR_ScenarioFrameworkSlotTask scenarioFrameworkSlotTask;
64 SCR_ScenarioFrameworkLayerTask scenarioFrameworkLayerTask;
65 SCR_ScenarioFrameworkArea scenarioFrameworkArea;
66 foreach (SCR_Task task : tasks)
67 {
68 scenarioFrameworkTask = SCR_ScenarioFrameworkTask.Cast(task);
69 if (!scenarioFrameworkTask)
70 continue;
71
72 scenarioFrameworkSlotTask = scenarioFrameworkTask.GetSlotTask();
73 if (!scenarioFrameworkSlotTask)
74 continue;
75
76 scenarioFrameworkLayerTask = scenarioFrameworkTask.GetLayerTask();
77 if (!scenarioFrameworkLayerTask)
78 continue;
79
80 scenarioFrameworkArea = scenarioFrameworkLayerTask.GetParentArea();
81 if (!scenarioFrameworkArea)
82 continue;
83
84 listElements.Insert(WidgetManager.Translate(string.Format("%1 - Area: %2 - LayerTask: %3 - SlotTask: %4", scenarioFrameworkTask.GetTaskName(), scenarioFrameworkArea.GetName(), scenarioFrameworkLayerTask.GetName(), scenarioFrameworkSlotTask.GetName())));
85 scenarioFrameworkTasks.Insert(scenarioFrameworkTask);
86 }
87
88 if (!listElements.IsEmpty())
89 {
90 int taskListIndex;
91 DbgUI.List("Active Tasks", taskListIndex, listElements);
92
93 scenarioFrameworkTask = scenarioFrameworkTasks[taskListIndex];
94
95 bool inspectArea;
96 DbgUI.Check("Inspect Area", inspectArea);
97 if (inspectArea)
98 LayerInspector(scenarioFrameworkTask.GetLayerTask().GetParentArea().GetName());
99
100 bool inspectLayerTask;
101 DbgUI.Check("Inspect Layer Task", inspectLayerTask);
102 if (inspectLayerTask)
103 LayerInspector(scenarioFrameworkTask.GetLayerTask().GetName());
104
105 bool inspectSlotTask;
106 DbgUI.Check("Inspect Slot Task", inspectSlotTask);
107 if (inspectSlotTask)
108 LayerInspector(scenarioFrameworkTask.GetSlotTask().GetName());
109
110 ProcessSlotTask(scenarioFrameworkTask.GetSlotTask());
111
112 DbgUI.Spacer(16);
113
114 bool includeChildren = true;
115 DbgUI.Check("Restore Include Children", includeChildren);
116
117 bool reinitAfterRestoration = true;
118 DbgUI.Check("Reinit After Restoration", reinitAfterRestoration);
119
120 bool affectRandomization = false;
121 DbgUI.Check("Restore Affects Randomization", affectRandomization);
122
123 bool deleteSpawnedEntities = true;
124 DbgUI.Check("Delete Spawned Entities", deleteSpawnedEntities);
125
126 if (DbgUI.Button("Restore To Default"))
127 scenarioFrameworkTask.GetLayerTask().RestoreToDefault(includeChildren, reinitAfterRestoration, deleteSpawnedEntities);
128 }
129 }
130 DbgUI.End();
131 }
132
133 //------------------------------------------------------------------------------------------------
135 static void RegisteredAreas()
136 {
137 DbgUI.Begin("ScenarioFramework Registered Areas");
138 {
139
141 if (!scenarioFrameworkSystem)
142 return;
143
144 array<string> listElements = {};
145 foreach (SCR_ScenarioFrameworkArea area : scenarioFrameworkSystem.m_aAreas)
146 {
147 listElements.Insert(area.GetName());
148 }
149
150 if (!listElements.IsEmpty())
151 {
152 int selectedAreaIndex;
153 DbgUI.List("Areas", selectedAreaIndex, listElements);
154
155 bool inspectArea;
156 DbgUI.Check("Inspect Area", inspectArea);
157 if (inspectArea)
158 {
159 string layerName = listElements[selectedAreaIndex];
160 LayerInspector(layerName);
161 }
162 }
163 }
164 DbgUI.End();
165 }
166
167 //------------------------------------------------------------------------------------------------
169 static void DebugActions()
170 {
172 if (!scenarioFrameworkSystem)
173 return;
174
175 DbgUI.Begin("ScenarioFramework Debug Actions");
176 {
177 array<string> listElements = {};
178 if (!scenarioFrameworkSystem.m_aDebugActions || scenarioFrameworkSystem.m_aDebugActions.IsEmpty())
179 return;
180
181 foreach (SCR_ScenarioFrameworkDebugAction action : scenarioFrameworkSystem.m_aDebugActions)
182 {
183 listElements.Insert(action.m_sDebugActionName);
184 }
185
186 if (listElements.IsEmpty())
187 return;
188
189 int selectedActionIndex;
190 DbgUI.List("Available actions", selectedActionIndex, listElements);
191
192 if (scenarioFrameworkSystem.m_aDebugActions.IsIndexValid(selectedActionIndex))
193 ProcessDebugAction(scenarioFrameworkSystem.m_aDebugActions[selectedActionIndex]);
194 }
195 DbgUI.End();
196 }
197
198 //------------------------------------------------------------------------------------------------
199 static void ProcessDebugAction(SCR_ScenarioFrameworkDebugAction debugAction)
200 {
201 if (!DbgUI.Button("ACTIVATE"))
202 return;
203
204 foreach (SCR_ScenarioFrameworkActionBase action : debugAction.m_aDebugActions)
205 {
206 action.Init(null);
207 action.OnActivate(null);
208 }
209 }
210
211 //------------------------------------------------------------------------------------------------
213 static void DebugAreas()
214 {
215 DbgUI.Begin("ScenarioFramework Debug Areas");
216 {
218 if (!scenarioFrameworkSystem)
219 return;
220
221 array<string> listElements = {};
222 foreach (SCR_ScenarioFrameworkDebugArea debugArea : scenarioFrameworkSystem.m_aDebugAreas)
223 {
224 listElements.Insert(string.Format("%1 - LayerTask: %2 - SlotTask: %3", debugArea.m_sForcedArea, debugArea.m_sForcedLayerTask, debugArea.m_sForcedSlotTask));
225 }
226
227 if (!listElements.IsEmpty())
228 {
229 int selectedAreaIndex;
230 DbgUI.List("Debug Areas", selectedAreaIndex, listElements);
231
232 string toRemoveDebugArea = scenarioFrameworkSystem.m_aDebugAreas[selectedAreaIndex].m_sForcedArea;
233 if (DbgUI.Button(string.Format("Remove Debug Area: %1", toRemoveDebugArea)))
234 RemoveDebugArea(toRemoveDebugArea);
235
236 if (DbgUI.Button("Clear All Debug Areas"))
237 scenarioFrameworkSystem.m_aDebugAreas.Clear();
238 }
239
240 DbgUI.Spacer(16);
241 DbgUI.Text("New Debug Area");
242 string newDebugArea;
243 string newDebugLayerTask;
244 string newDebugSlotTask;
245 DbgUI.InputText("Area (Requiered)", newDebugArea);
246 DbgUI.InputText("Layer Task (Optional)", newDebugLayerTask);
247 DbgUI.InputText("Slot Task (Optional)", newDebugSlotTask);
248 if (DbgUI.Button("Add Debug Area"))
249 AddNewDebugArea(newDebugArea, newDebugLayerTask, newDebugSlotTask);
250
251 // This part is currently not working properly and is under investigation
252 DbgUI.Spacer(16);
253 bool possiblePresets;
254 DbgUI.Check("Show possible Debug Area Presets", possiblePresets);
255 if (possiblePresets)
256 {
257 DbgUI.Text("All possible Debug Area Presets");
258 array<string> listPossibleElements = {};
259 array<ref array<ref SCR_ScenarioFrameworkDebugArea>> allDebugArea = {};
260 allDebugArea = SCR_ScenarioFrameworkDebug.GetDebugAreaPresets();
261
262 foreach (int index, array<ref SCR_ScenarioFrameworkDebugArea> debugArea : allDebugArea)
263 {
264 listPossibleElements.Insert(string.Format("Debug Preset %1", index));
265 }
266
267 if (!listPossibleElements.IsEmpty())
268 {
269 int selectedPresetIndex;
270 DbgUI.List("Debug Area Presets", selectedPresetIndex, listPossibleElements);
271
272 array<string> listSelectedPresetElements = {};
273 foreach (SCR_ScenarioFrameworkDebugArea debugSelectedPresetArea : allDebugArea[selectedPresetIndex])
274 {
275 listSelectedPresetElements.Insert(string.Format("%1 - LayerTask: %2 - SlotTask: %3", debugSelectedPresetArea.m_sForcedArea, debugSelectedPresetArea.m_sForcedLayerTask, debugSelectedPresetArea.m_sForcedSlotTask));
276 }
277
278 if (!listSelectedPresetElements.IsEmpty())
279 {
280 int selectedPresetListIndex;
281 DbgUI.List("Selected Preset Details", selectedPresetListIndex, listSelectedPresetElements);
282 }
283
284 if (DbgUI.Button(string.Format("Add Debug Preset %1", selectedPresetIndex)))
285 {
286 foreach (SCR_ScenarioFrameworkDebugArea newSelectedDebugArea : allDebugArea[selectedPresetIndex])
287 {
288 AddNewDebugArea(newSelectedDebugArea)
289 }
290 }
291 }
292 }
293
294 DbgUI.Spacer(16);
295 DbgUI.Text("Remove Debug Area Removal");
296
297 if (DbgUI.Button("Reinit ScenarioFramework"))
298 ReinitScenarioFramework(scenarioFrameworkSystem);
299 }
300 DbgUI.End();
301 }
302
303 //------------------------------------------------------------------------------------------------
306 static void ReinitScenarioFramework(SCR_ScenarioFrameworkSystem scenarioFrameworkSystem)
307 {
308 if (!scenarioFrameworkSystem)
309 return;
310
312 scenarioFrameworkSystem.m_bDebugInit = true;
313 scenarioFrameworkSystem.m_aSelectedAreas.Clear();
314 scenarioFrameworkSystem.m_aLayerTasksToBeInitialized.Clear();
315 scenarioFrameworkSystem.m_aLayerTasksForRandomization.Clear();
316 scenarioFrameworkSystem.m_aAreasTasksToSpawn.Clear();
317 scenarioFrameworkSystem.m_aLayersTaskToSpawn.Clear();
318 scenarioFrameworkSystem.m_aSlotsTaskToSpawn.Clear();
319 scenarioFrameworkSystem.m_aESFTaskTypesAvailable.Clear();
320 scenarioFrameworkSystem.m_aESFTaskTypeForRandomization.Clear();
321 scenarioFrameworkSystem.m_aSpawnedAreas.Clear();
322 scenarioFrameworkSystem.m_aDespawnedAreas.Clear();
323 scenarioFrameworkSystem.m_mVariableMap.Clear();
324
325 foreach (SCR_ScenarioFrameworkArea registeredArea : scenarioFrameworkSystem.m_aAreas)
326 {
327 if (!scenarioFrameworkSystem.m_aCoreAreas.Contains(registeredArea.GetName()))
328 registeredArea.RestoreToDefault(true);
329 }
330
331 scenarioFrameworkSystem.Init();
332 }
333
334 //------------------------------------------------------------------------------------------------
339 static void AddNewDebugArea(string newDebugArea, string newDebugLayerTask, string newDebugSlotTask)
340 {
342 if (!scenarioFrameworkSystem)
343 return;
344
345 foreach (SCR_ScenarioFrameworkDebugArea debugArea : scenarioFrameworkSystem.m_aDebugAreas)
346 {
347 // If there is already the same area inserted, we don't want to continue
348 if (debugArea.m_sForcedArea == newDebugArea)
349 return;
350 }
351
353 debugArea.m_sForcedArea = newDebugArea;
354 debugArea.m_sForcedLayerTask = newDebugLayerTask;
355 debugArea.m_sForcedSlotTask = newDebugSlotTask;
356
357 scenarioFrameworkSystem.m_aDebugAreas.Insert(debugArea);
358 }
359
360 //------------------------------------------------------------------------------------------------
363 static void AddNewDebugArea(SCR_ScenarioFrameworkDebugArea newDebugArea)
364 {
366 if (!scenarioFrameworkSystem)
367 return;
368
369 foreach (SCR_ScenarioFrameworkDebugArea debugArea : scenarioFrameworkSystem.m_aDebugAreas)
370 {
371 // If there is already the same area inserted, we don't want to continue
372 if (debugArea.m_sForcedArea == newDebugArea.m_sForcedArea)
373 return;
374 }
375
376 scenarioFrameworkSystem.m_aDebugAreas.Insert(newDebugArea);
377 }
378
379 //------------------------------------------------------------------------------------------------
382 static void RemoveDebugArea(string toRemoveDebugArea)
383 {
385 if (!scenarioFrameworkSystem)
386 return;
387
388 for (int i = scenarioFrameworkSystem.m_aDebugAreas.Count() - 1; i >= 0; i--)
389 {
390 if (scenarioFrameworkSystem.m_aDebugAreas[i].m_sForcedArea == toRemoveDebugArea)
391 scenarioFrameworkSystem.m_aDebugAreas.Remove(i);
392 }
393 }
394
395 //------------------------------------------------------------------------------------------------
397 static array<ref array<ref SCR_ScenarioFrameworkDebugArea>> GetDebugAreaPresets()
398 {
400 if (!scenarioFrameworkSystem)
401 return null;
402
403 array<ref array<ref SCR_ScenarioFrameworkDebugArea>> allDebugArea = {};
404
405
406 array<SCR_ScenarioFrameworkSlotTask> aSlotTasks = {};
407 foreach (SCR_ScenarioFrameworkArea area : scenarioFrameworkSystem.m_aAreas)
408 {
409 area.GetAllSlotTasks(aSlotTasks);
410 if (!aSlotTasks || aSlotTasks.IsEmpty())
411 continue;
412
413 foreach (SCR_ScenarioFrameworkSlotTask slotTask : aSlotTasks)
414 {
415 if (!slotTask)
416 continue;
417
419 debugArea.m_sForcedArea = area.GetName();
420 debugArea.m_sForcedLayerTask = slotTask.GetLayerTask().GetName();
421 debugArea.m_sForcedSlotTask = slotTask.GetName();
422
423 bool newAreaCreated;
424 array<ref SCR_ScenarioFrameworkDebugArea> temporaryDebugAreas = {};
425
426 if (allDebugArea.IsEmpty())
427 {
428 temporaryDebugAreas.Insert(debugArea);
429 allDebugArea.Insert(temporaryDebugAreas);
430 continue;
431 }
432
433 array<ref SCR_ScenarioFrameworkDebugArea> temporaryDebugAreas2 = {};
434 foreach (array<ref SCR_ScenarioFrameworkDebugArea> debugAreasFromAll : allDebugArea)
435 {
436 bool unusedAreaFound = true;
437 foreach (SCR_ScenarioFrameworkDebugArea innerDebugArea : debugAreasFromAll)
438 {
439 if (innerDebugArea.m_sForcedArea == area.GetName())
440 {
441 unusedAreaFound = false;
442 break;
443 }
444 }
445
446 if (unusedAreaFound)
447 {
448 debugAreasFromAll.Insert(debugArea);
449 break;
450 }
451 else
452 {
453 temporaryDebugAreas2.Insert(debugArea);
454 newAreaCreated = true;
455 }
456 }
457
458 if (newAreaCreated)
459 {
460 allDebugArea.Insert(temporaryDebugAreas2);
461 }
462 }
463 }
464
466 for (int i = allDebugArea.Count() - 1; i >= 0; i--)
467 {
468 array<ref SCR_ScenarioFrameworkDebugArea> debugAreasFromAll = allDebugArea[i];
469
470 for (int j = debugAreasFromAll.Count() - 1; j >= 0; j--)
471 {
472 debugArea = debugAreasFromAll[j];
473 foreach (array<ref SCR_ScenarioFrameworkDebugArea> debugAreasFromAll2 : allDebugArea)
474 {
475 bool unusedAreaFound = true;
476 foreach (SCR_ScenarioFrameworkDebugArea innerDebugArea : debugAreasFromAll2)
477 {
478 if (innerDebugArea.m_sForcedArea == debugArea.m_sForcedArea)
479 {
480 unusedAreaFound = false;
481 break;
482 }
483 }
484
485 if (unusedAreaFound)
486 {
487 debugAreasFromAll2.Insert(debugArea);
488 debugAreasFromAll.Remove(j);
489 break;
490 }
491 }
492 }
493
494 if (debugAreasFromAll.IsEmpty())
495 allDebugArea.Remove(i);
496 }
497
498 return allDebugArea;
499 }
500
501 //------------------------------------------------------------------------------------------------
504 static void LayerInspector(string inputLayerName = "")
505 {
506 DbgUI.Begin(string.Format("ScenarioFramework Layer Inspector %1", inputLayerName));
507 {
508 if (SCR_StringHelper.IsEmptyOrWhiteSpace(inputLayerName))
509 DbgUI.InputText("Layer Name to inspect", inputLayerName);
510
511 IEntity layerEntity = GetGame().GetWorld().FindEntityByName(inputLayerName);
512 if (layerEntity)
513 {
514 bool layerTaskHasFinishConditions;
515 bool layerTaskHasFinishActions;
516 bool layerTaskHasCreateActions;
517 bool layerTaskHasFailedActions;
518 bool layerTaskHasCancelledActions;
519 bool layerTaskHasProgressActions;
520 bool layerTaskHasAssignedActions;
521
522
523 bool slotTaskHasFinishConditions;
524 bool slotTaskHasFinishActions;
525 bool slotTaskHasCreateActions;
526 bool slotTaskHasFailedActions;
527 bool slotTaskHasCancelledActions;
528 bool slotTaskHasProgressActions;
529 bool slotTaskHasAssignedActions;
531 if (layerBase)
532 {
533 bool detailsChecked = true;
534 if (detailsChecked)
535 {
536 if (layerBase.m_bInitiated)
537 DbgUI.Text("Initiated");
538 else
539 DbgUI.Text("Not Initiated");
540
541 DbgUI.Text((string.Format("Activation type: %1", SCR_Enum.GetEnumName(SCR_ScenarioFrameworkEActivationType, layerBase.m_eActivationType))));
542
543 if (layerBase.m_bIsTerminated)
544 DbgUI.Text("Terminated");
545 else
546 DbgUI.Text("Not Terminated");
547
548 if (layerBase.m_iCurrentlySpawnedChildren < layerBase.m_iSupposedSpawnedChildren)
549 {
550 DbgUI.Text(string.Format("Currently spawned %1 out of %2 children", layerBase.m_iCurrentlySpawnedChildren, layerBase.m_iSupposedSpawnedChildren));
551 }
552
553 if (layerBase.m_Area)
554 DbgUI.Text((string.Format("Parent Area Name: %1", layerBase.m_Area.GetName())));
555
556 if (layerBase.m_ParentLayer)
557 DbgUI.Text((string.Format("Parent Layer Name: %1", layerBase.m_ParentLayer.GetName())));
558 }
559
560 SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(layerBase);
561 if (layerTask)
562 {
563 ProcessSlotTask(layerTask.m_SlotTask);
564 if ((layerTask.m_aFinishConditions && !layerTask.m_aFinishConditions.IsEmpty()))
565 layerTaskHasFinishConditions = true;
566
567 if ((layerTask.m_aTriggerActionsOnFinish && !layerTask.m_aTriggerActionsOnFinish.IsEmpty()))
568 layerTaskHasFinishActions = true;
569
570 if ((layerTask.m_aActionsOnCreated && !layerTask.m_aActionsOnCreated.IsEmpty()))
571 layerTaskHasCreateActions = true;
572
573 if ((layerTask.m_aActionsOnFailed && !layerTask.m_aActionsOnFailed.IsEmpty()))
574 layerTaskHasFailedActions = true;
575
576 if ((layerTask.m_aActionsOnCancelled && !layerTask.m_aActionsOnCancelled.IsEmpty()))
577 layerTaskHasCancelledActions = true;
578
579 if ((layerTask.m_aActionsOnProgress && !layerTask.m_aActionsOnProgress.IsEmpty()))
580 layerTaskHasProgressActions = true;
581
582 if ((layerTask.m_aActionsOnAssigned && !layerTask.m_aActionsOnAssigned.IsEmpty()))
583 layerTaskHasAssignedActions = true;
584 }
585
587 if (slotBase)
588 {
589 string spawnedEntityDisplayName;
590 spawnedEntityDisplayName = slotBase.GetSpawnedEntityDisplayName();
591 if (!SCR_StringHelper.IsEmptyOrWhiteSpace(spawnedEntityDisplayName))
592 DbgUI.Text((string.Format("Spawned Entity Display Name: %1", spawnedEntityDisplayName)));
593
594 IEntity spawnedEntity = slotBase.GetSpawnedEntity();
595
596 BaseGameTriggerEntity baseGameTrigger = BaseGameTriggerEntity.Cast(spawnedEntity);
597 if (baseGameTrigger)
598 {
599 if (baseGameTrigger.IsPeriodicQueriesEnabled())
600 {
601 DbgUI.Text("Trigger Periodic Queries Enabled");
602 if (DbgUI.Button("Disable Periodic Queries"))
603 baseGameTrigger.EnablePeriodicQueries(false);
604 }
605 else
606 {
607 DbgUI.Text("Trigger Periodic Queries Disabled");
608 if (DbgUI.Button("Enable Periodic Queries"))
609 baseGameTrigger.EnablePeriodicQueries(true);
610 }
611 }
612
613 SCR_ScenarioFrameworkSlotTask slotTask = SCR_ScenarioFrameworkSlotTask.Cast(slotBase);
614 if (slotTask)
615 {
616 ProcessSlotTask(slotTask);
617 if ((slotTask.m_aFinishConditions && !slotTask.m_aFinishConditions.IsEmpty()))
618 slotTaskHasFinishConditions = true;
619
620 if ((slotTask.m_aActionsOnFinished && !slotTask.m_aActionsOnFinished.IsEmpty()))
621 slotTaskHasFinishActions = true;
622
623 if ((slotTask.m_aActionsOnCreated && !slotTask.m_aActionsOnCreated.IsEmpty()))
624 slotTaskHasCreateActions = true;
625
626 if ((slotTask.m_aActionsOnFailed && !slotTask.m_aActionsOnFailed.IsEmpty()))
627 slotTaskHasFailedActions = true;
628
629 if ((slotTask.m_aActionsOnCancelled && !slotTask.m_aActionsOnCancelled.IsEmpty()))
630 slotTaskHasCancelledActions = true;
631
632 if ((slotTask.m_aActionsOnProgress && !slotTask.m_aActionsOnProgress.IsEmpty()))
633 slotTaskHasProgressActions = true;
634
635 if ((slotTask.m_aActionsOnAssigned && !slotTask.m_aActionsOnAssigned.IsEmpty()))
636 slotTaskHasAssignedActions = true;
637 }
638 else if (spawnedEntity)
639 {
640 ProcessTeleport(spawnedEntity.GetOrigin(), "Teleport to Spawned Entity");
641 }
642
643 if (layerBase.m_aPlugins && !layerBase.m_aPlugins.IsEmpty())
644 {
645 bool inspectPlugins;
646 DbgUI.Check("Inspect Plugins", inspectPlugins);
647 if (inspectPlugins)
648 PluginInspector(inputLayerName);
649 }
650 }
651 else
652 {
653 array<string> childrenLayerElements = {};
654 ProcessLayerHierarchy(layerBase, childrenLayerElements);
655
656 if (!childrenLayerElements.IsEmpty())
657 {
658 DbgUI.Spacer(16);
659
660 DbgUI.Text("Layer Hierarchy:");
661 int childLayerIndex;
662 DbgUI.List("Layer Hierarchy", childLayerIndex, childrenLayerElements);
663
664 bool inspectChildLayer;
665 DbgUI.Check("Inspect Child Layer", inspectChildLayer);
666 if (inspectChildLayer)
667 {
668 string layerName = childrenLayerElements[childLayerIndex];
669 layerName.Replace("-", "");
670 LayerInspector(layerName);
671 }
672 }
673
674 array<string> logicLayerElements = {};
675 array<SCR_ScenarioFrameworkLogic> m_aLogic = {};
676 layerBase.GetLogics(m_aLogic);
677 foreach (SCR_ScenarioFrameworkLogic logic : m_aLogic)
678 {
679 logicLayerElements.Insert(logic.GetName());
680 }
681
682 if (!logicLayerElements.IsEmpty())
683 {
684 DbgUI.Text("Layer Logics:");
685 int logicIndex;
686 DbgUI.List("Logics Hierarchy", logicIndex, logicLayerElements);
687
688 bool inspectLogic;
689 DbgUI.Check("Inspect Logic", inspectLogic);
690 if (inspectLogic)
691 {
692 string logicName = logicLayerElements[logicIndex];
693 LogicInspector(logicName);
694 }
695 }
696
697 if (layerBase.m_aPlugins && !layerBase.m_aPlugins.IsEmpty())
698 {
699 bool inspectPlugins;
700 DbgUI.Check("Inspect Plugins", inspectPlugins);
701 if (inspectPlugins)
702 PluginInspector(inputLayerName);
703 }
704 }
705
706 if ((layerBase.m_aActivationActions && !layerBase.m_aActivationActions.IsEmpty()) || layerTaskHasFinishActions
707 || layerTaskHasCreateActions || layerTaskHasFailedActions || layerTaskHasCancelledActions || layerTaskHasProgressActions || layerTaskHasAssignedActions || slotTaskHasFinishActions
708 || slotTaskHasCreateActions || slotTaskHasFailedActions || slotTaskHasCancelledActions || slotTaskHasProgressActions || slotTaskHasAssignedActions
709 )
710 {
711 bool inspectActivationActions;
712 DbgUI.Check("Inspect Actions", inspectActivationActions);
713 if (inspectActivationActions)
714 ActionInspector(inputLayerName);
715 }
716
717 if ((layerBase.m_aActivationConditions && !layerBase.m_aActivationConditions.IsEmpty()) || slotTaskHasFinishConditions || layerTaskHasFinishConditions)
718 {
719 bool inspectActivationConditions;
720 DbgUI.Check("Inspect Conditions", inspectActivationConditions);
721 if (inspectActivationConditions)
722 ConditionInspector(inputLayerName);
723 }
724
725 DbgUI.Spacer(16);
726 ProcessTeleport(layerBase.GetOwner().GetOrigin(), "Teleport to Layer");
727
728 if (layerBase.m_bInitiated)
729 {
730 if (DbgUI.Button("Initiate Dynamic Despawn"))
731 layerBase.DynamicDespawn(layerBase);
732 }
733 else
734 {
735 if (DbgUI.Button("Initiate Dynamic Spawn"))
736 layerBase.DynamicReinit();
737 }
738
739 DbgUI.Spacer(16);
740
741 bool includeChildren = true;
742 DbgUI.Check("Restore Include Children", includeChildren);
743
744 bool reinitAfterRestoration = true;
745 DbgUI.Check("Reinit After Restoration", reinitAfterRestoration);
746
747 bool affectRandomization = true;
748 DbgUI.Check("Restore Affects Randomization", affectRandomization);
749
750 bool deleteSpawnedEntities = true;
751 DbgUI.Check("Delete Spawned Entities", deleteSpawnedEntities);
752
753 if (DbgUI.Button("Restore To Default"))
754 layerBase.RestoreToDefault(includeChildren, reinitAfterRestoration, affectRandomization, deleteSpawnedEntities);
755 }
756 }
757 }
758 DbgUI.End();
759 }
760
761 //------------------------------------------------------------------------------------------------
766 static void ProcessLayerHierarchy(SCR_ScenarioFrameworkLayerBase layerBase, inout array<string> childrenLayerElements, int level = 0)
767 {
768 string levelString;
769 for (int i = 0; i < level; i++)
770 {
771 levelString += "-";
772 }
773
774 array<SCR_ScenarioFrameworkLayerBase> childrenLayers = {};
775 layerBase.GetChildren(childrenLayers);
776
777 childrenLayers.RemoveItem(null);
778 foreach (SCR_ScenarioFrameworkLayerBase layerChild : childrenLayers)
779 {
780 childrenLayerElements.Insert(string.Format("%1%2", levelString, layerChild.GetName()));
781 ProcessLayerHierarchy(layerChild, childrenLayerElements, level + 1);
782 }
783 }
784
785 //------------------------------------------------------------------------------------------------
788 static void ProcessSlotTask(SCR_ScenarioFrameworkSlotTask slotTask)
789 {
790 if (!slotTask)
791 return;
792
793 SCR_ETaskState state = slotTask.GetTaskState();
794 DbgUI.Text((string.Format("Task State: %1", SCR_Enum.GetEnumName(SCR_ETaskState, state))));
795
796 if (state != SCR_ETaskState.COMPLETED && state != SCR_ETaskState.FAILED && state != SCR_ETaskState.CANCELLED)
797 {
798 if (DbgUI.Button("Finish Task"))
799 {
800 SCR_ScenarioFrameworkLayerTask layerTask = slotTask.GetLayerTask();
801 if (layerTask)
802 {
803 layerTask.ProcessLayerTaskState(SCR_ETaskState.COMPLETED);
804 }
805 }
806
807 if (DbgUI.Button("Finish Task (Forced)"))
808 {
809 SCR_ScenarioFrameworkLayerTask layerTask = slotTask.GetLayerTask();
810 if (layerTask)
811 {
812 layerTask.ProcessLayerTaskState(SCR_ETaskState.COMPLETED, true);
813 }
814 }
815 }
816
817 IEntity spawnedEntity = slotTask.GetSpawnedEntity();
818 if (spawnedEntity)
819 ProcessTeleport(spawnedEntity.GetOrigin(), "Teleport to Spawned Entity");
820 }
821
822 //------------------------------------------------------------------------------------------------
826 static void ProcessTeleport(vector destination, string buttonName)
827 {
828 if (DbgUI.Button(buttonName))
829 {
831 if (char)
832 char.SetOrigin(destination)
833 }
834 }
835
836 //------------------------------------------------------------------------------------------------
839 static void ActionInspector(string inputLayerName = "")
840 {
841 DbgUI.Begin(string.Format("ScenarioFramework Action Inspector %1", inputLayerName));
842 {
843 if (SCR_StringHelper.IsEmptyOrWhiteSpace(inputLayerName))
844 DbgUI.InputText("Layer Name to inspect", inputLayerName);
845
846 IEntity layerEntity = GetGame().GetWorld().FindEntityByName(inputLayerName);
847 if (layerEntity)
848 {
850 if (layerBase)
851 {
852 PrepareActionStrings(layerBase.m_aActivationActions, layerEntity, "Activation Actions");
853
854 SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(layerBase);
855 if (layerTask)
856 {
857 PrepareActionStrings(layerTask.m_aTriggerActionsOnFinish, layerEntity, "Finish Actions");
858 PrepareActionStrings(layerTask.m_aActionsOnCreated, layerEntity, "Created Actions");
859 PrepareActionStrings(layerTask.m_aActionsOnFailed, layerEntity, "Failed Actions");
860 PrepareActionStrings(layerTask.m_aActionsOnCancelled, layerEntity, "Cancelled Actions");
861 PrepareActionStrings(layerTask.m_aActionsOnProgress, layerEntity, "Progress Actions");
862 PrepareActionStrings(layerTask.m_aActionsOnAssigned, layerEntity, "Assigned Actions");
863 }
864
865 SCR_ScenarioFrameworkSlotTask slotTask = SCR_ScenarioFrameworkSlotTask.Cast(layerBase);
866 if (slotTask)
867 {
868 PrepareActionStrings(slotTask.m_aActionsOnFinished, layerEntity, "Finish Actions");
869 PrepareActionStrings(slotTask.m_aActionsOnCreated, layerEntity, "Created Actions");
870 PrepareActionStrings(slotTask.m_aActionsOnFailed, layerEntity, "Failed Actions");
871 PrepareActionStrings(slotTask.m_aActionsOnCancelled, layerEntity, "Cancelled Actions");
872 PrepareActionStrings(slotTask.m_aActionsOnProgress, layerEntity, "Progress Actions");
873 PrepareActionStrings(slotTask.m_aActionsOnAssigned, layerEntity, "Assigned Actions");
874 }
875 }
876 }
877 }
878 DbgUI.End();
879 }
880
881 //------------------------------------------------------------------------------------------------
886 static void ProcessAction(SCR_ScenarioFrameworkActionBase action, IEntity layerEntity, string categoryName)
887 {
888 if (action.m_bDebug)
889 {
890 DbgUI.Text(string.Format("%1 Debug Action enabled", categoryName));
891
892 if (DbgUI.Button(string.Format("%1 Disable Action debug", categoryName)))
893 action.m_bDebug = false;
894 }
895 else
896 {
897 DbgUI.Text(string.Format("%1 Debug Action disabled", categoryName));
898
899 if (DbgUI.Button(string.Format("%1 Enable Action debug", categoryName)))
900 action.m_bDebug = true;
901 }
902
903 DbgUI.Text(string.Format("%1 Number of activations %1 out of %2", categoryName, action.m_iNumberOfActivations, action.m_iMaxNumberOfActivations));
904
905 if (DbgUI.Button(string.Format("%1 Init again", categoryName)))
906 action.Init(layerEntity);
907
908 if (DbgUI.Button(string.Format("%1 Activate again", categoryName)))
909 action.OnActivate(layerEntity);
910
911 array<ref SCR_ScenarioFrameworkActionBase> subActions = action.GetSubActions();
912 if (!subActions || subActions.IsEmpty())
913 {
915 if (actionAI)
916 {
917 array<ref SCR_ScenarioFrameworkAIAction> subActionsAI = actionAI.GetSubActionsAI();
918 if (!subActionsAI || subActionsAI.IsEmpty())
919 return;
920
921 bool debugCheck;
922 DbgUI.Check(string.Format("%1 Show SubAction AI Inspector", categoryName), debugCheck);
923 if (debugCheck)
924 ProcessSubActions(actionAI, layerEntity);
925 }
926
928 if (actionMedical)
929 {
930 array<ref SCR_ScenarioFrameworkMedicalAction> subActionsMedical = actionMedical.GetSubActionsMedical();
931 if (!subActionsMedical || subActionsMedical.IsEmpty())
932 return;
933
934 bool debugCheck;
935 DbgUI.Check(string.Format("%1 Show SubAction Medical Inspector", categoryName), debugCheck);
936 if (debugCheck)
937 ProcessSubActions(actionMedical, layerEntity);
938 }
939
940 return;
941 }
942
943 bool debugCheck;
944 DbgUI.Check(string.Format("%1 Show SubAction Inspector", categoryName), debugCheck);
945 if (debugCheck)
946 ProcessSubActions(action, layerEntity);
947 }
948
949 //------------------------------------------------------------------------------------------------
954 static void ProcessAction(SCR_ScenarioFrameworkAIAction action, IEntity layerEntity, string categoryName)
955 {
956 if (action.m_bDebug)
957 {
958 DbgUI.Text(string.Format("%1 Debug Action enabled", categoryName));
959
960 if (DbgUI.Button(string.Format("%1 Disable Action debug", categoryName)))
961 action.m_bDebug = false;
962 }
963 else
964 {
965 DbgUI.Text(string.Format("%1 Debug Action disabled", categoryName));
966
967 if (DbgUI.Button(string.Format("%1 Enable Action debug", categoryName)))
968 action.m_bDebug = true;
969 }
970
971 if (DbgUI.Button(string.Format("%1 Activate again", categoryName)))
972 action.OnActivate();
973
974 array<ref SCR_ScenarioFrameworkActionBase> subActions = action.GetSubActions();
975 if (!subActions || subActions.IsEmpty())
976 return;
977
978 bool debugCheck;
979 DbgUI.Check(string.Format("%1 Show SubAction Inspector", categoryName), debugCheck);
980 if (debugCheck)
981 ProcessSubActions(action, layerEntity);
982 }
983
984 //------------------------------------------------------------------------------------------------
989 static void ProcessAction(SCR_ScenarioFrameworkMedicalAction action, IEntity layerEntity, string categoryName)
990 {
991 if (action.m_bDebug)
992 {
993 DbgUI.Text(string.Format("%1 Debug Action enabled", categoryName));
994
995 if (DbgUI.Button(string.Format("%1 Disable Action debug", categoryName)))
996 action.m_bDebug = false;
997 }
998 else
999 {
1000 DbgUI.Text(string.Format("%1 Debug Action disabled", categoryName));
1001
1002 if (DbgUI.Button(string.Format("%1 Enable Action debug", categoryName)))
1003 action.m_bDebug = true;
1004 }
1005
1006 if (DbgUI.Button(string.Format("%1 Activate again", categoryName)))
1007 action.OnActivate();
1008
1009 array<ref SCR_ScenarioFrameworkActionBase> subActions = action.GetSubActions();
1010 if (!subActions || subActions.IsEmpty())
1011 return;
1012
1013 bool debugCheck;
1014 DbgUI.Check(string.Format("%1 Show SubAction Inspector", categoryName), debugCheck);
1015 if (debugCheck)
1016 ProcessSubActions(action, layerEntity);
1017 }
1018
1019 //------------------------------------------------------------------------------------------------
1023 static void ProcessSubActions(SCR_ScenarioFrameworkActionBase action, IEntity layerEntity)
1024 {
1025 array<string> listElements = {};
1026 array<ref SCR_ScenarioFrameworkActionBase> subActions = action.GetSubActions();
1027 if (!subActions || subActions.IsEmpty())
1028 return;
1029
1030 string name = action.ToString();
1031 name.Replace("SCR_ScenarioFrameworkAction", "");
1032 name.Replace("SCR_ScenarioFrameworkAIAction", "");
1033 name.Replace("SCR_ScenarioFrameworkMedicalAction", "");
1034 DbgUI.Begin(string.Format("SubAction %1", name));
1035 {
1036 PrepareActionStrings(subActions, layerEntity, "Sub Actions");
1037 }
1038 DbgUI.End();
1039 }
1040
1041 //------------------------------------------------------------------------------------------------
1045 static void ProcessSubActions(SCR_ScenarioFrameworkActionAI action, IEntity layerEntity)
1046 {
1047 array<string> listElements = {};
1048 array<ref SCR_ScenarioFrameworkAIAction> subActions = action.GetSubActionsAI();
1049 if (!subActions || subActions.IsEmpty())
1050 return;
1051
1052 string name = action.ToString();
1053 name.Replace("SCR_ScenarioFrameworkAIAction", "");
1054 DbgUI.Begin(string.Format("SubAction %1", name));
1055 {
1056 PrepareActionStrings(subActions, layerEntity, "Sub Actions");
1057 }
1058 DbgUI.End();
1059 }
1060
1061 //------------------------------------------------------------------------------------------------
1065 static void ProcessSubActions(SCR_ScenarioFrameworkAIAction action, IEntity layerEntity)
1066 {
1067 array<string> listElements = {};
1068 array<ref SCR_ScenarioFrameworkActionBase> subActions = action.GetSubActions();
1069 if (!subActions || subActions.IsEmpty())
1070 return;
1071
1072 string name = action.ToString();
1073 name.Replace("SCR_ScenarioFrameworkAction", "");
1074 name.Replace("SCR_ScenarioFrameworkAIAction", "");
1075 name.Replace("SCR_ScenarioFrameworkMedicalAction", "");
1076 DbgUI.Begin(string.Format("SubAction %1", name));
1077 {
1078 PrepareActionStrings(subActions, layerEntity, "Sub Actions");
1079 }
1080 DbgUI.End();
1081 }
1082
1083 //------------------------------------------------------------------------------------------------
1087 static void ProcessSubActions(SCR_ScenarioFrameworkActionMedical action, IEntity layerEntity)
1088 {
1089 array<string> listElements = {};
1090 array<ref SCR_ScenarioFrameworkMedicalAction> subActions = action.GetSubActionsMedical();
1091 if (!subActions || subActions.IsEmpty())
1092 return;
1093
1094 string name = action.ToString();
1095 name.Replace("SCR_ScenarioFrameworkMedicalAction", "");
1096 DbgUI.Begin(string.Format("SubAction %1", name));
1097 {
1098 PrepareActionStrings(subActions, layerEntity, "Sub Actions");
1099 }
1100 DbgUI.End();
1101 }
1102
1103 //------------------------------------------------------------------------------------------------
1107 static void ProcessSubActions(SCR_ScenarioFrameworkMedicalAction action, IEntity layerEntity)
1108 {
1109 array<string> listElements = {};
1110 array<ref SCR_ScenarioFrameworkActionBase> subActions = action.GetSubActions();
1111 if (!subActions || subActions.IsEmpty())
1112 return;
1113
1114 string name = action.ToString();
1115 name.Replace("SCR_ScenarioFrameworkAction", "");
1116 name.Replace("SCR_ScenarioFrameworkAIAction", "");
1117 name.Replace("SCR_ScenarioFrameworkMedicalAction", "");
1118 DbgUI.Begin(string.Format("SubAction %1", name));
1119 {
1120 PrepareActionStrings(subActions, layerEntity, "Sub Actions");
1121 }
1122 DbgUI.End();
1123 }
1124
1125 //------------------------------------------------------------------------------------------------
1130 static void PrepareActionStrings(array<ref SCR_ScenarioFrameworkActionBase> actions, IEntity activationEntity, string categoryName)
1131 {
1132 array<string> listElements = {};
1133 if (!actions || actions.IsEmpty())
1134 return;
1135
1136 foreach (int index, SCR_ScenarioFrameworkActionBase action : actions)
1137 {
1138 string name = action.ToString();
1139 name.Replace("SCR_ScenarioFrameworkAction", "");
1140 name.Replace("SCR_ScenarioFrameworkAIAction", "");
1141 name.Replace("SCR_ScenarioFrameworkMedicalAction", "");
1142 listElements.Insert(string.Format("%1 - %2", index, name));
1143 }
1144
1145 if (listElements.IsEmpty())
1146 return;
1147
1148 int selectedActionIndex;
1149 DbgUI.Text(string.Format("%1 Hierarchy:", categoryName));
1150 DbgUI.List(string.Format("%1", categoryName), selectedActionIndex, listElements);
1151
1152 if (actions.IsIndexValid(selectedActionIndex))
1153 ProcessAction(actions[selectedActionIndex], activationEntity, categoryName);
1154 }
1155
1156 //------------------------------------------------------------------------------------------------
1161 static void PrepareActionStrings(array<ref SCR_ScenarioFrameworkAIAction> actions, IEntity activationEntity, string categoryName)
1162 {
1163 array<string> listElements = {};
1164 if (!actions || actions.IsEmpty())
1165 return;
1166
1167 foreach (int index, SCR_ScenarioFrameworkAIAction action : actions)
1168 {
1169 string name = action.ToString();
1170 name.Replace("SCR_ScenarioFrameworkAction", "");
1171 name.Replace("SCR_ScenarioFrameworkAIAction", "");
1172 name.Replace("SCR_ScenarioFrameworkMedicalAction", "");
1173 listElements.Insert(string.Format("%1 - %2", index, name));
1174 }
1175
1176 if (listElements.IsEmpty())
1177 return;
1178
1179 int selectedActionIndex;
1180 DbgUI.Text(string.Format("%1 Hierarchy:", categoryName));
1181 DbgUI.List(string.Format("%1", categoryName), selectedActionIndex, listElements);
1182
1183 if (actions.IsIndexValid(selectedActionIndex))
1184 ProcessAction(actions[selectedActionIndex], activationEntity, categoryName);
1185 }
1186
1187 //------------------------------------------------------------------------------------------------
1192 static void PrepareActionStrings(array<ref SCR_ScenarioFrameworkMedicalAction> actions, IEntity activationEntity, string categoryName)
1193 {
1194 array<string> listElements = {};
1195 if (!actions || actions.IsEmpty())
1196 return;
1197
1198 foreach (int index, SCR_ScenarioFrameworkMedicalAction action : actions)
1199 {
1200 string name = action.ToString();
1201 name.Replace("SCR_ScenarioFrameworkAction", "");
1202 name.Replace("SCR_ScenarioFrameworkAIAction", "");
1203 name.Replace("SCR_ScenarioFrameworkMedicalAction", "");
1204 listElements.Insert(string.Format("%1 - %2", index, name));
1205 }
1206
1207 if (listElements.IsEmpty())
1208 return;
1209
1210 int selectedActionIndex;
1211 DbgUI.Text(string.Format("%1 Hierarchy:", categoryName));
1212 DbgUI.List(string.Format("%1", categoryName), selectedActionIndex, listElements);
1213
1214 if (actions.IsIndexValid(selectedActionIndex))
1215 ProcessAction(actions[selectedActionIndex], activationEntity, categoryName);
1216 }
1217
1218 //------------------------------------------------------------------------------------------------
1221 static void LogicInspector(string inputLogicName = "")
1222 {
1223 DbgUI.Begin(string.Format("ScenarioFramework Logic Inspector %1", inputLogicName));
1224 {
1225 if (SCR_StringHelper.IsEmptyOrWhiteSpace(inputLogicName))
1226 DbgUI.InputText("Logic Name to inspect", inputLogicName);
1227
1228 IEntity logicEntity = GetGame().GetWorld().FindEntityByName(inputLogicName);
1229 if (logicEntity)
1230 {
1231 SCR_ScenarioFrameworkLogic logic = SCR_ScenarioFrameworkLogic.Cast(logicEntity);
1232 if (logic)
1233 {
1234 if (logic.m_bDebug)
1235 {
1236 DbgUI.Text("Debug Logic enabled");
1237
1238 if (DbgUI.Button("Disable Logic debug"))
1239 logic.m_bDebug = false;
1240 }
1241 else
1242 {
1243 DbgUI.Text("Debug Logic disabled");
1244
1245 if (DbgUI.Button("Enable Logic debug"))
1246 logic.m_bDebug = true;
1247 }
1248
1249 if (logic.m_bIsTerminated)
1250 DbgUI.Text("Terminated");
1251 else
1252 DbgUI.Text("Not Terminated");
1253
1254 PrepareActionStrings(logic.m_aActions, logicEntity, "Actions");
1255
1256 SCR_ScenarioFrameworkLogicCounter logicCounter = SCR_ScenarioFrameworkLogicCounter.Cast(logicEntity);
1257 if (logicCounter)
1258 {
1259 DbgUI.Text(string.Format("Logic Counter value %1 out of %2.", logicCounter.m_iCnt, logicCounter.m_iCountTo));
1260
1261 PrepareActionStrings(logicCounter.m_aOnIncreaseActions, logicEntity, "OnIncrease Action");
1262 PrepareActionStrings(logicCounter.m_aOnDecreaseActions, logicEntity, "OnDecrease Action");
1263
1264 if (DbgUI.Button("Increase Counter"))
1265 logicCounter.Increase(logicEntity);
1266
1267 if (DbgUI.Button("Decrease Counter"))
1268 logicCounter.Decrease(logicEntity);
1269 }
1270 }
1271 }
1272 }
1273 DbgUI.End();
1274 }
1275
1276 //------------------------------------------------------------------------------------------------
1279 static void PluginInspector(string inputLayerName = "")
1280 {
1281 DbgUI.Begin(string.Format("ScenarioFramework Plugin Inspector %1", inputLayerName));
1282 {
1283 if (SCR_StringHelper.IsEmptyOrWhiteSpace(inputLayerName))
1284 DbgUI.InputText("Layer Name to inspect", inputLayerName);
1285
1286 IEntity layerEntity = GetGame().GetWorld().FindEntityByName(inputLayerName);
1287 if (layerEntity)
1288 {
1290 if (layerBase)
1291 {
1292 PreparePluginStrings(layerBase.m_aPlugins, layerEntity, "Plugins");
1293 }
1294 }
1295 }
1296 DbgUI.End();
1297 }
1298
1299 //------------------------------------------------------------------------------------------------
1304 static void PreparePluginStrings(array<ref SCR_ScenarioFrameworkPlugin> plugins, IEntity activationEntity, string categoryName)
1305 {
1306 array<string> listElements = {};
1307 if (!plugins || plugins.IsEmpty())
1308 return;
1309
1310 foreach (int index, SCR_ScenarioFrameworkPlugin action : plugins)
1311 {
1312 string name = action.ToString();
1313 name.Replace("SCR_ScenarioFrameworkPlugin", "");
1314 listElements.Insert(string.Format("%1 - %2", index, name));
1315 }
1316
1317 if (listElements.IsEmpty())
1318 return;
1319
1320 int selectedPluginIndex;
1321 DbgUI.Text(string.Format("%1 Hierarchy:", categoryName));
1322 DbgUI.List(string.Format("%1", categoryName), selectedPluginIndex, listElements);
1323
1324 if (plugins.IsIndexValid(selectedPluginIndex))
1325 ProcessPlugin(plugins[selectedPluginIndex], activationEntity);
1326 }
1327
1328 //------------------------------------------------------------------------------------------------
1332 static void ProcessPlugin(SCR_ScenarioFrameworkPlugin plugin, IEntity layerEntity)
1333 {
1334 if (plugin.m_bDebug)
1335 {
1336 DbgUI.Text("Debug Plugin enabled");
1337 if (DbgUI.Button("Disable Plugin debug"))
1338 plugin.m_bDebug = false;
1339 }
1340 else
1341 {
1342 DbgUI.Text("Debug Plugin disabled");
1343 if (DbgUI.Button("Enable Plugin debug"))
1344 plugin.m_bDebug = true;
1345 }
1346
1348 if (pluginTrigger)
1349 {
1350 ProcessPluginTrigger(pluginTrigger);
1351 return;
1352 }
1353
1355 if (pluginOnInventoryChange)
1356 {
1357 ProcessPluginOnInventoryChange(pluginOnInventoryChange, layerEntity);
1358 return;
1359 }
1360
1362 if (pluginSpawnPoint)
1363 {
1364 ProcessPluginSpawnPoint(pluginSpawnPoint, layerEntity);
1365 return;
1366 }
1367
1369 if (pluginOnDestroyEvent)
1370 {
1371 ProcessPluginOnDestroyEvent(pluginOnDestroyEvent, layerEntity);
1372 return;
1373 }
1374 }
1375
1376 //------------------------------------------------------------------------------------------------
1379 static void ProcessPluginTrigger(SCR_ScenarioFrameworkPluginTrigger pluginTrigger)
1380 {
1381 IEntity entity = pluginTrigger.m_Object.GetSpawnedEntity();
1382 if (!entity)
1383 return;
1384
1385 BaseGameTriggerEntity baseGameTrigger = BaseGameTriggerEntity.Cast(entity);
1386 if (!baseGameTrigger)
1387 return;
1388
1389 if (baseGameTrigger.IsPeriodicQueriesEnabled())
1390 {
1391 DbgUI.Text("Periodic Queries Enabled");
1392 if (DbgUI.Button("Disable Periodic Queries"))
1393 baseGameTrigger.EnablePeriodicQueries(false);
1394 }
1395 else
1396 {
1397 DbgUI.Text("Periodic Queries Disabled");
1398 if (DbgUI.Button("Enable Periodic Queries"))
1399 baseGameTrigger.EnablePeriodicQueries(true);
1400 }
1401
1403 if (!frameworkTrigger)
1404 return;
1405
1406 if (DbgUI.Button("Force Finish Trigger"))
1407 frameworkTrigger.FinishTrigger(entity);
1408 }
1409
1410 //------------------------------------------------------------------------------------------------
1414 static void ProcessPluginOnInventoryChange(SCR_ScenarioFrameworkPluginOnInventoryChange pluginOnInventoryChange, IEntity layerEntity)
1415 {
1416 PrepareActionStrings(pluginOnInventoryChange.m_aActionsOnItemAdded, layerEntity, "Actions On Item Added");
1417 PrepareActionStrings(pluginOnInventoryChange.m_aActionsOnItemRemoved, layerEntity, "Actions On Item Removed");
1418 }
1419
1420 //------------------------------------------------------------------------------------------------
1424 static void ProcessPluginSpawnPoint(SCR_ScenarioFrameworkPluginSpawnPoint pluginSpawnPoint, IEntity layerEntity)
1425 {
1426 PrepareActionStrings(pluginSpawnPoint.m_aActionsOnSpawnPointUsed, layerEntity, "Actions On Spawn Point Used");
1427 }
1428
1429 //------------------------------------------------------------------------------------------------
1433 static void ProcessPluginOnDestroyEvent(SCR_ScenarioFrameworkPluginOnDestroyEvent pluginOnDestroyEvent, IEntity layerEntity)
1434 {
1435 PrepareActionStrings(pluginOnDestroyEvent.m_aActionsOnDestroy, layerEntity, "Actions On Destroy");
1436 }
1437
1438 //------------------------------------------------------------------------------------------------
1441 static void ConditionInspector(string inputLayerName = "")
1442 {
1443 DbgUI.Begin(string.Format("ScenarioFramework Condition Inspector %1", inputLayerName));
1444 {
1445 if (SCR_StringHelper.IsEmptyOrWhiteSpace(inputLayerName))
1446 DbgUI.InputText("Layer Name to inspect", inputLayerName);
1447
1448 IEntity layerEntity = GetGame().GetWorld().FindEntityByName(inputLayerName);
1449 if (layerEntity)
1450 {
1452 if (layerBase)
1453 {
1454 PrepareConditionStrings(layerBase.m_aActivationConditions, layerEntity, "Condition");
1455
1456 SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(layerBase);
1457 if (layerTask)
1458 PrepareConditionStrings(layerTask.m_aFinishConditions, layerEntity, "Finish Condition");
1459
1460 SCR_ScenarioFrameworkSlotTask slotTask = SCR_ScenarioFrameworkSlotTask.Cast(layerBase);
1461 if (slotTask)
1462 PrepareConditionStrings(slotTask.m_aFinishConditions, layerEntity, "Finish Condition");
1463 }
1464 }
1465 }
1466 DbgUI.End();
1467 }
1468
1469 //------------------------------------------------------------------------------------------------
1474 static void PrepareConditionStrings(array<ref SCR_ScenarioFrameworkActivationConditionBase> conditions, IEntity activationEntity, string categoryName)
1475 {
1476 array<string> listElements = {};
1477 if (!conditions || conditions.IsEmpty())
1478 return;
1479
1480 foreach (int index, SCR_ScenarioFrameworkActivationConditionBase condition : conditions)
1481 {
1482 string name = condition.ToString();
1483 name.Replace("SCR_ScenarioFrameworkActivationCondition", "");
1484 listElements.Insert(string.Format("%1 - %2", index, name));
1485 }
1486
1487 if (listElements.IsEmpty())
1488 return;
1489
1490 int selectedPluginIndex;
1491 DbgUI.Text(string.Format("%1 Hierarchy:", categoryName));
1492 DbgUI.List(string.Format("%1", categoryName), selectedPluginIndex, listElements);
1493
1494 if (conditions.IsIndexValid(selectedPluginIndex))
1495 ProcessCondition(conditions[selectedPluginIndex], activationEntity);
1496
1498 if (layerBase)
1499 {
1500 if (DbgUI.Button("Perform Conditon Check"))
1501 layerBase.InitActivationConditions();
1502 }
1503 }
1504
1505 //------------------------------------------------------------------------------------------------
1509 static void ProcessCondition(SCR_ScenarioFrameworkActivationConditionBase condition, IEntity layerEntity)
1510 {
1511 if (condition.m_bDebug)
1512 {
1513 DbgUI.Text("Debug Condition enabled");
1514 if (DbgUI.Button("Disable Condition debug"))
1515 condition.m_bDebug = false;
1516 }
1517 else
1518 {
1519 DbgUI.Text("Debug Condition disabled");
1520 if (DbgUI.Button("Enable Condition debug"))
1521 condition.m_bDebug = true;
1522 }
1523
1524 bool conditionCheck = false;
1525 DbgUI.Check("Check condition status", conditionCheck);
1526 if (conditionCheck)
1527 {
1528 if (condition.Init(layerEntity))
1529 DbgUI.Text("Condition: True");
1530 else
1531 DbgUI.Text("Condition: False");
1532 }
1533 }
1534}
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
ref array< SCR_ScenarioFrameworkLogic > m_aLogic
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_ScenarioFrameworkSlotBase(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
SCR_ETaskState
Definition SCR_Task.c:3
Definition DbgUI.c:66
Diagnostic and developer menu system.
Definition DiagMenu.c:18
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external BaseWorld GetWorld()
static IEntity GetLocalControlledEntity()
override void RestoreToDefault(bool includeChildren=false, bool reinitAfterRestoration=false, bool affectRandomization=true, bool deleteSpawnedEntities=true)
ref array< ref Tuple3< SCR_ScenarioFrameworkArea, vector, int > > m_aSpawnedAreas
ref array< ref Tuple3< SCR_ScenarioFrameworkArea, vector, int > > m_aDespawnedAreas
static ScriptCallQueue GetCallQueuePausable()
static SCR_ScenarioFrameworkSystem GetInstance()
ref array< SCR_ScenarioFrameworkLayerTask > m_aLayerTasksForRandomization
ref array< SCR_ScenarioFrameworkArea > m_aAreas
ref array< SCR_ESFTaskType > m_aESFTaskTypesAvailable
ref array< SCR_ScenarioFrameworkArea > m_aSelectedAreas
ref array< SCR_ScenarioFrameworkLayerTask > m_aLayerTasksToBeInitialized
ref map< string, string > m_mVariableMap
ref array< SCR_ESFTaskType > m_aESFTaskTypeForRandomization
SCR_ScenarioFrameworkLayerTask GetLayerTask()
SCR_ScenarioFrameworkSlotTask GetSlotTask()
static bool IsEmptyOrWhiteSpace(string input)