Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BaseCommandAction.c
Go to the documentation of this file.
3 {
4  [Attribute("", UIWidgets.ResourcePickerThumbnail, "Objective or waypoint prefab", "et")]
5  protected ResourceName m_CommandPrefab;
6 
7  protected void FilterEntities(notnull set<SCR_EditableEntityComponent> inEntities, out notnull set<SCR_EditableEntityComponent> outEntities)
8  {
9  outEntities.Copy(inEntities);
10  }
11 
12  protected set<SCR_EditableEntityComponent> GetSelectedEntities(notnull set<SCR_EditableEntityComponent> inEntities)
13  {
14  set<SCR_EditableEntityComponent> selectedEnities = new set<SCR_EditableEntityComponent>();
15  FilterEntities(inEntities, selectedEnities);
16  return selectedEnities;
17  }
18 
19  //--- Called from command toolbar, initiates placing mode
20  bool StartPlacing(notnull set<SCR_EditableEntityComponent> selectedEntities)
21  {
23  if (!placingManager)
24  {
25  return false;
26  }
27  return placingManager.SetSelectedPrefab(m_CommandPrefab, recipients: GetSelectedEntities(selectedEntities));
28  }
29  //--- Called from radial menu, places the command instantly
30  override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags, int param = -1)
31  {
32  if (cursorWorldPosition == vector.Zero)
33  return;
34 
36  if (!placingManager)
37  return;
38 
39  bool isQueue = flags & EEditorCommandActionFlags.IS_QUEUE;
40 
41  vector transform[4];
42  Math3D.MatrixIdentity3(transform);
43  transform[3] = cursorWorldPosition;
44  SCR_EditorPreviewParams params = SCR_EditorPreviewParams.CreateParams(transform);
45 
46  placingManager.CreateEntity(m_CommandPrefab, params, !isQueue, false, GetSelectedEntities(selectedEntities));
47  }
48  /*
49  protected SCR_EditableEntityComponent CreatePrefab(vector position, typename expectedType)
50  {
51  Resource resource = Resource.Load(m_CommandPrefab);
52  if (!resource || !resource.IsValid())
53  {
54  Print(string.Format("Unable to load prefab '%1'!", m_CommandPrefab), LogLevel.ERROR);
55  return null;
56  }
57 
58  if (!resource.GetResource().ToEntitySource().GetClassName().ToType().IsInherited(expectedType))
59  {
60  Print(string.Format("Prefab '%1' must contain entity of type %1!", m_CommandPrefab, expectedType), LogLevel.ERROR);
61  return null;
62  }
63 
64  vector transform[4];
65  Math3D.MatrixIdentity3(transform);
66  transform[3] = position;
67 
68  return SCR_PlacingEditorComponent.SpawnEntityResource(m_CommandPrefab, transform);
69  }
70  protected void GetOffsets(int count, out notnull array<vector> outOffsets)
71  {
72  if (count == 0)
73  {
74  return;
75  }
76  if (count == 1)
77  {
78  outOffsets.Insert(vector.Zero);
79  return;
80  }
81 
82  int rowCount = Math.Round(Math.Sqrt(count));
83  int columnCount = Math.Ceil(Math.Sqrt(count));
84  vector offset = -Vector((rowCount - 1) * m_fSpacing / 2, 0, (columnCount - 1) * m_fSpacing / 2);
85 
86  int row, column;
87  for (int i = 0; i < count; i++)
88  {
89  row = Math.Floor(i / columnCount);
90  column = i % columnCount;
91  outOffsets.Insert(offset + Vector(row * m_fSpacing, 0, column * m_fSpacing));
92  }
93  }
94  */
95  protected void OnCurrentActionChanged()
96  {
98  if (commandActionsManager)
99  Toggle(0, commandActionsManager.IsActionCurrent(this))
100  }
101  override void Track()
102  {
104  if (commandActionsManager)
105  {
106  commandActionsManager.GetOnCurrentActionChanged().Insert(OnCurrentActionChanged);
107  OnCurrentActionChanged();
108  }
109  }
110  override void Untrack()
111  {
113  if (commandActionsManager)
114  commandActionsManager.GetOnCurrentActionChanged().Remove(OnCurrentActionChanged);
115  }
116  override bool IsServer()
117  {
118  //--- Must be called on client, placing handles server communication itself
119  return false;
120  }
121 };
SCR_BaseContainerCustomTitleResourceName
SCR_CampaignMilitaryBaseComponent SCR_MilitaryBaseComponent SCR_BaseContainerCustomTitleResourceName("m_sBaseName", true)
Definition: SCR_CampaignMilitaryBaseComponent.c:2522
Toggle
void Toggle()
Toggle hint. Hide it if it's shown, and open it again if it's hidden.
Definition: SCR_HintManagerComponent.c:216
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_BaseToggleToolbarAction
Definition: SCR_BaseToggleToolbarAction.c:3
EEditorCommandActionFlags
EEditorCommandActionFlags
Simplified action conditions.
Definition: EEditorCommandActionFlags.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_BaseCommandAction
Definition: SCR_BaseCommandAction.c:2
SCR_PlacingEditorComponent
Definition: SCR_PlacingEditorComponent.c:118
SCR_EditorPreviewParams
Network packet of variables for entity placing and transformation.
Definition: SCR_EditorPreviewParams.c:4
SCR_CommandActionsEditorComponent
Definition: SCR_CommandActionsEditorComponent.c:10
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