Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SelectContextAction.c
Go to the documentation of this file.
3 {
4  [Attribute("1", UIWidgets.ComboBox, "Entity filter", "", ParamEnumArray.FromEnum(EEditableEntityState) )]
5  EEditableEntityState m_EditableEntityFilter;
6  [Attribute(desc: "Filter entities based on hovered type")]
7  bool m_UseEntityTypeFilter;
8  [Attribute(desc: "Filter entities only in view")]
9  bool m_OnlyInView;
10 
11  protected EEditableEntityType m_FilterType = EEditableEntityType.GENERIC;
12 
13  protected bool IsEntityIsInView(WorkspaceWidget workspace, SCR_EditableEntityComponent entity, int screenW, int screenH)
14  {
15  vector posWorld;
16  if (!entity.GetPos(posWorld)) return false;
17 
18  vector posScreen = workspace.ProjWorldToScreenNative(posWorld, entity.GetOwner().GetWorld()); //--- ToDo: Also check for distance visibility
19  return (posScreen[2] > 0 && posScreen[0] > 0 && posScreen[0] < screenW && posScreen[1] > 0 && posScreen[1] < screenH);
20  }
21 
22  override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
23  {
24  if (m_UseEntityTypeFilter && hoveredEntity == null)
25  {
26  return false;
27  }
28  return true;
29  }
30 
31  override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
32  {
33  return true;
34  }
35 
36  override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,int flags, int param = -1)
37  {
39  SCR_SelectedEditableEntityFilter selectedEntitiesManager = SCR_SelectedEditableEntityFilter.Cast(entitiesManager.GetFilter(EEditableEntityState.SELECTED));
40 
41  if (!entitiesManager || !selectedEntitiesManager)
42  {
43  return;
44  }
45 
46  if (m_UseEntityTypeFilter)
47  {
48  m_FilterType = hoveredEntity.GetEntityType();
49  }
50 
51  WorkspaceWidget workspace = GetGame().GetWorkspace();
52 
53  int screenW, screenH;
54  screenW = workspace.GetWidth();
55  screenH = workspace.GetHeight();
56 
57  set<SCR_EditableEntityComponent> filteredEntities = new set<SCR_EditableEntityComponent>;
58  entitiesManager.GetEntities(m_EditableEntityFilter, filteredEntities);
59 
60  for (int i = 0; i < filteredEntities.Count(); i++)
61  {
62  if (m_UseEntityTypeFilter && filteredEntities[i].GetEntityType() != m_FilterType)
63  {
64  continue;
65  }
66  if (m_OnlyInView && !IsEntityIsInView(workspace, filteredEntities[i], screenW, screenH))
67  {
68  continue;
69  }
70  selectedEntitiesManager.Add(filteredEntities[i]);
71  }
72  }
73 };
EEditableEntityState
EEditableEntityState
Definition: EEditableEntityState.c:37
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EntitiesManagerEditorComponent
Definition: SCR_EntitiesManagerEditorComponent.c:13
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_SelectContextAction
Definition: SCR_SelectContextAction.c:2
SCR_SelectedEditableEntityFilter
Definition: SCR_SelectedEditableEntityFilter.c:6
SCR_BaseContextAction
Definition: SCR_BaseContextAction.c:7
Attribute
typedef Attribute
Post-process effect of scripted camera.
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
GetEntityType
override EEditableEntityType GetEntityType(IEntity owner=null)
Definition: SCR_EditablePlayerDelegateComponent.c:131
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
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