10 ref SCR_SortedArray<SCR_BaseEditorAction> m_aActions;
14 class SCR_EditorActionList
17 ref array<ref SCR_BaseEditorAction>
m_Actions;
23 protected ref array<ref SCR_EditorActionList> m_ActionsLists;
26 protected ref array<ref SCR_EditorActionGroup> m_ActionGroups;
28 protected ref array<SCR_BaseEditorAction> m_ActionsSorted = {};
34 int GetActions(out notnull array<SCR_BaseEditorAction> outActions)
36 return outActions.Copy(m_ActionsSorted);
45 if (!m_ActionsSorted.IsIndexValid(
index))
48 return m_ActionsSorted[
index];
57 return m_ActionsSorted.Find(action);
63 void SetShortcuts(SCR_BaseActionsEditorComponent manager,
bool toAdd)
69 action.AddShortcut(manager);
76 action.RemoveShortcut();
86 if (!m_ActionGroups || m_ActionGroups.IsEmpty())
90 SCR_SortedArray<SCR_BaseEditorAction> actionsSorted =
new SCR_SortedArray<SCR_BaseEditorAction>();
91 foreach (SCR_EditorActionList list: m_ActionsLists)
93 for (
int i = 0, count = list.m_Actions.Count(); i < count; i++)
95 action = list.m_Actions[i];
96 if (action.IsEnabled())
97 actionsSorted.Insert(action.GetOrder(), action);
100 actionsSorted.ToArray(m_ActionsSorted);
106 SCR_SortedArray<SCR_EditorActionGroup> actionGroupsSorted =
new SCR_SortedArray<SCR_EditorActionGroup>();
107 map<EEditorActionGroup, SCR_EditorActionGroup> actionGroupsMap =
new map<EEditorActionGroup, SCR_EditorActionGroup>();
108 int actionGroupCount = m_ActionGroups.Count();
109 for (
int g = 0; g < actionGroupCount; g++)
111 actionGroup = m_ActionGroups[g];
112 actionGroup.m_aActions =
new SCR_SortedArray<SCR_BaseEditorAction>();
113 actionGroupsSorted.Insert(actionGroup.m_iOrder, actionGroup);
114 actionGroupsMap.Insert(actionGroup.m_ActionGroup, actionGroup);
119 foreach (SCR_EditorActionList list: m_ActionsLists)
121 for (
int a = 0, count = list.m_Actions.Count(); a < count; a++)
123 action = list.m_Actions[a];
124 if (action.IsEnabled())
126 if (actionGroupsMap.Find(action.GetActionGroup(), actionGroup))
127 actionGroup.m_aActions.Insert(action.GetOrder(), action);
129 Debug.Error2(
"SCR_BaseActionsEditorComponentClass.SCR_BaseActionsEditorComponentClass()",
string.Format(
"Cannot register action %1, its group %2 is not configured!", Type(),
typename.EnumToString(
EEditorActionGroup, action.GetActionGroup())));
135 for (
int g; g < actionGroupCount; g++)
137 actionGroup = actionGroupsSorted[g];
138 for (
int a, actionCount = actionGroup.m_aActions.Count(); a < actionCount; a++)
140 m_ActionsSorted.Insert(actionGroup.m_aActions[a]);
144 m_ActionGroups =
null;
155 protected ref set<SCR_EditableEntityComponent>
m_SelectedEntities =
new set<SCR_EditableEntityComponent>();
168 int GetActions(out notnull array<SCR_BaseEditorAction> actions)
172 return prefabData.GetActions(actions);
184 void EvaluateActions(notnull array<SCR_BaseEditorAction> actions, vector cursorWorldPosition, out notnull array<ref SCR_EditorActionData> filteredActions, out
int flags = 0)
186 filteredActions.Clear();
207 int GetAndEvaluateActions(vector cursorWorldPosition, out notnull array<ref SCR_EditorActionData> filteredActions, out
int flags = 0)
209 array<SCR_BaseEditorAction> actions = {};
212 return filteredActions.Count();
255 vector cursorWorldPosition;
271 if (
GetGame().GetMenuManager().IsAnyDialogOpen())
290 int param = action.GetParam();
293 if (action.CheckAndSetCooldown())
315 int actionIndex = prefabData.FindAction(action);
316 if (actionIndex == -1)
319 RplId hoveredEntityID = -1;
320 array<RplId> selectedEntityIds = {};
323 Rpc(
ActionPerformServer, actionIndex, hoveredEntityID, selectedEntityIds, cursorWorldPosition, flags, param);
329 action.Perform(hoveredEntityComponent, selectedEntityComponents, cursorWorldPosition, flags, param);
337 SCR_BaseEditorEffect.Activate(action.GetEffects(),
this, cursorWorldPosition, selectedEntityComponents);
348 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
349 protected void ActionPerformServer(
int actionIndex, RplId hoveredEntityID, array<RplId> selectedEntityIds, vector cursorWorldPosition,
int flags,
int param)
358 Print(
"Action with index: " + actionIndex +
" not found on server", LogLevel.ERROR);
363 set<SCR_EditableEntityComponent> selectedEntityComponents =
new set<SCR_EditableEntityComponent>;
364 DeSerializeEntities(hoveredEntityID, selectedEntityIds, hoveredEntityComponent, selectedEntityComponents);
366 ActionPerform(action, hoveredEntityComponent, selectedEntityComponents, cursorWorldPosition, flags, param);
373 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
383 Print(
"Action with index: " + actionIndex +
" returned from server, not found on client", LogLevel.ERROR);
397 Print(
"Entity " +
m_HoveredEntity.GetDisplayName() +
" does not have replication component or is not registered for replication", LogLevel.WARNING);
408 RplId selectedEntityId;
411 Print(
"Entity " + selectedEntity.GetDisplayName() +
" does not have replication component or is not registered for replication", LogLevel.WARNING);
414 selectedEntityIds.Insert(selectedEntityId);
421 entityRplId = Replication.FindId(entity);
422 return entityRplId != -1;
429 if (hoveredEntityId != -1)
432 Print(
string.Format(
"Hovered entity with RplID: %1 not found on server", hoveredEntityId), LogLevel.NORMAL);
436 foreach (RplId selectedEntityRplId : selectedEntityIds)
441 Print(
string.Format(
"Selected entity with RplID: %1 not found on server", selectedEntityRplId), LogLevel.NORMAL );
444 selectedEntityComponents.Insert(selectedEntityComponent);
451 Managed entityComponent = Replication.FindItem(entityRplId);
452 if (!entityComponent)
454 Print(
string.Format(
"Entity with RplID: %1 not found on server", entityRplId), LogLevel.NORMAL);
459 return editableEntityComponent !=
null;
478 prefabData.SetShortcuts(
this,
true);
488 prefabData.SetShortcuts(
this,
false);