Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CommandActionsEditorComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor", description: "Manager of Command actions in editor!", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3 {
4 };
10 class SCR_CommandActionsEditorComponent : SCR_BaseActionsEditorComponent
11 {
12  [Attribute("", uiwidget: UIWidgets.ComboBox, "When placing command instantly (e.g., Alt+RMB), choose the first action in one of these groups.\nWhen empty, all groups will be considered.", category: "Editor Command Actions", enums: ParamEnumArray.FromEnum(EEditorActionGroup))]
13  protected ref array<EEditorActionGroup> m_DefaultActionGroups;
14 
15  protected SCR_BaseEditorAction m_CurrentAction;
16 
17  protected ref ScriptInvoker Event_OnCurrentActionChanged = new ScriptInvoker();
18 
23  ScriptInvoker GetOnCurrentActionChanged()
24  {
25  return Event_OnCurrentActionChanged;
26  }
32  bool IsActionCurrent(SCR_BaseEditorAction action)
33  {
34  return action == m_CurrentAction;
35  }
40  void SetCurrentAction(SCR_BaseEditorAction currentAction)
41  {
42  m_CurrentAction = currentAction;
43  Event_OnCurrentActionChanged.Invoke();
44  }
45 
50  void PerformDefaultAction(bool isQueue)
51  {
52  EEditorCommandActionFlags flags = 0;
53  if (isQueue)
54  {
55  flags |= EEditorCommandActionFlags.IS_QUEUE;
56  }
57 
58  vector position;
59  array<ref SCR_EditorActionData> actions = {};
60  for (int i = 0, count = GetAndEvaluateActions(position, actions); i < count; i++)
61  {
62  if (m_DefaultActionGroups.IsEmpty() || m_DefaultActionGroups.Contains(actions[i].GetAction().GetActionGroup()))
63  {
64  SCR_BaseEditorAction action = actions[i].GetAction();
65  ActionPerformInstantly(action, flags);
66  break;
67  }
68  }
69  }
74  void StartPlacing(SCR_BaseEditorAction action)
75  {
76  SCR_BaseCommandAction commandAction = SCR_BaseCommandAction.Cast(action);
77  if (commandAction && commandAction.StartPlacing(m_SelectedEntities))
78  {
79  SetCurrentAction(action);
80  }
81  }
82 
83  protected void OnPlacingSelectedPrefabChange(ResourceName prefab, ResourceName prefabPrev)
84  {
85  //--- Reset variables when placing ends
86  if (prefab.IsEmpty())
87  {
88  SetCurrentAction(null);
89  }
90  }
91 
92  override int ValidateSelection(bool isInstant)
93  {
94  if (m_HoverManager)
95  m_HoveredEntity = m_HoverManager.GetFirstEntity();
96  else
97  m_HoveredEntity = null;
98 
101  else
102  m_SelectedEntities.Clear();
103 
106  bool isTaskManager = GetTaskManager() != null;
108  {
109  type = entity.GetEntityType();
110 
111  //--- At least one group is selected
112  if (entity.GetAIGroup() && !(flags & EEditorCommandActionFlags.OBJECTIVE))
113  {
114  flags = flags | EEditorCommandActionFlags.WAYPOINT;
115  }
116 
117  //--- A faction is selected (placing objectives in that case)
118  if (isTaskManager && type == EEditableEntityType.FACTION)// || entity.HasEntityState(EEditableEntityState.PLAYER))
119  {
120  flags = flags | EEditorCommandActionFlags.OBJECTIVE;
121  flags = flags & ~EEditorCommandActionFlags.WAYPOINT;
122  }
123  }
124 
125  return flags;
126  }
127  override protected TraceFlags GetInstantActionTraceFlags()
128  {
129  return TraceFlags.WORLD | TraceFlags.OCEAN;
130  }
131 
132  override bool ActionCanBeShown(SCR_BaseEditorAction action, vector cursorWorldPosition, int flags)
133  {
134  return action.GetInfo() && action.CanBeShown(m_HoveredEntity, m_SelectedEntities, cursorWorldPosition, flags);
135  }
136 
137  override bool ActionCanBePerformed(SCR_BaseEditorAction action, vector cursorWorldPosition, int flags)
138  {
139  return action.CanBePerformed(m_HoveredEntity, m_SelectedEntities, cursorWorldPosition, flags);
140  }
141 
142  override void EOnEditorActivate()
143  {
144  super.EOnEditorActivate();
145 
147  if (placingManager)
148  placingManager.GetOnSelectedPrefabChange().Insert(OnPlacingSelectedPrefabChange);
149  }
150  override void EOnEditorDeactivate()
151  {
152  super.EOnEditorDeactivate();
153 
155  if (placingManager)
156  placingManager.GetOnSelectedPrefabChange().Remove(OnPlacingSelectedPrefabChange);
157  }
158 };
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_BaseEditorAction
Definition: SCR_BaseEditorAction.c:24
ActionPerformInstantly
void ActionPerformInstantly(SCR_BaseEditorAction action, int flags=0)
Definition: SCR_BaseActionsEditorComponent.c:251
SCR_BaseActionsEditorComponentClass
Definition: SCR_BaseActionsEditorComponent.c:20
GetAndEvaluateActions
int GetAndEvaluateActions(vector cursorWorldPosition, out notnull array< ref SCR_EditorActionData > filteredActions, out int flags=0)
Definition: SCR_BaseActionsEditorComponent.c:207
m_HoverManager
SCR_BaseActionsEditorComponentClass m_HoverManager
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_HoveredEntity
protected SCR_EditableEntityComponent m_HoveredEntity
Definition: SCR_BaseActionsEditorComponent.c:154
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
m_SelectedManager
protected SCR_BaseEditableEntityFilter m_SelectedManager
Definition: SCR_BaseActionsEditorComponent.c:151
EEditorCommandActionFlags
EEditorCommandActionFlags
Simplified action conditions.
Definition: EEditorCommandActionFlags.c:5
EEditorActionGroup
EEditorActionGroup
Definition: SCR_BaseEditorAction.c:7
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_CommandActionsEditorComponentClass
Definition: SCR_CommandActionsEditorComponent.c:2
SCR_BaseCommandAction
Definition: SCR_BaseCommandAction.c:2
m_SelectedEntities
protected ref set< SCR_EditableEntityComponent > m_SelectedEntities
Definition: SCR_BaseActionsEditorComponent.c:155
SCR_PlacingEditorComponent
Definition: SCR_PlacingEditorComponent.c:118
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
SCR_CommandActionsEditorComponent
Definition: SCR_CommandActionsEditorComponent.c:10
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180