Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditableEntityUIRuleTracker.c
Go to the documentation of this file.
1 
9 {
10  protected SCR_EntitiesEditorUIRule m_Rule;
11  protected SCR_EditableEntitySlotManagerUIComponent m_SlotManager;
12 
13  SCR_EntitiesEditorUIRule GetRule()
14  {
15  return m_Rule;
16  }
17  bool HasState(SCR_EditableEntityComponent entity)
18  {
19  return (entity.GetEntityStates() | m_SlotManager.GetForcedStates()) & m_Rule.GetStates();
20  }
21  void AddEntity(SCR_EditableEntityComponent entity)
22  {
23  if (!HasState(entity))
24  return;
25 
26  SCR_EditableEntityBaseSlotUIComponent entitySlot = m_SlotManager.FindSlot(entity, true);
27  if (!entitySlot)
28  return;
29 
30  entitySlot.CreateWidget(entity, m_Rule);
31  }
32  protected void OnChanged(EEditableEntityState state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
33  {
34  if (entitiesRemove)
35  {
36  foreach (SCR_EditableEntityComponent entity: entitiesRemove)
37  {
38  //--- If some other state is active, don't delete
39  if (HasState(entity))
40  continue;
41 
42  SCR_EditableEntityBaseSlotUIComponent entitySlot = m_SlotManager.FindSlot(entity);
43  if (!entitySlot)
44  continue;
45 
46  entitySlot.DeleteWidget(m_Rule);
47  m_SlotManager.DeleteSlot(entity);
48  }
49  }
50  if (entitiesInsert)
51  {
52  foreach (SCR_EditableEntityComponent entity: entitiesInsert)
53  {
54  SCR_EditableEntityBaseSlotUIComponent entitySlot = m_SlotManager.FindSlot(entity, true);
55  if (entitySlot)
56  entitySlot.CreateWidget(entity, m_Rule);
57  }
58  }
59  }
61  {
63  if (!filterManager)
64  return;
65 
66  m_Rule = rule;
67  m_SlotManager = slotManager;
68 
69  //--- Register entities
70  array<int> states = {};
71  m_Rule.GetStatesArray(states);
72  foreach (EEditableEntityState state: states)
73  {
74  SCR_BaseEditableEntityFilter filter = filterManager.GetFilter(state);
75  if (!filter)
76  continue;
77 
78  filter.GetOnChanged().Insert(OnChanged);
79 
80  if (canAddAllEntities)
81  {
82  set<SCR_EditableEntityComponent> entities = new set<SCR_EditableEntityComponent>;
83  filter.GetEntities(entities);
84  OnChanged(state, entities, null);
85  }
86  }
87  }
89  {
91  if (!filterManager)
92  return;
93 
94  array<int> states = {};
95  m_Rule.GetStatesArray(states);
96  foreach (EEditableEntityState state: states)
97  {
98  SCR_BaseEditableEntityFilter filter = filterManager.GetFilter(state);
99  if (!filter)
100  continue;
101 
102  if (filter && filter.GetOnChanged())
103  filter.GetOnChanged().Remove(OnChanged);
104  }
105  }
106 };
EEditableEntityState
EEditableEntityState
Definition: EEditableEntityState.c:37
SCR_EntitiesManagerEditorComponent
Definition: SCR_EntitiesManagerEditorComponent.c:13
SCR_EntitiesEditorUIRule
Definition: SCR_EditableEntityUIRule.c:8
SCR_EditableEntityBaseSlotUIComponent
Definition: SCR_EditableEntityBaseSlotUIComponent.c:6
SCR_EditableEntityUIRuleTracker
Definition: SCR_EditableEntityUIRuleTracker.c:8
SCR_EditableEntitySlotManagerUIComponent
Definition: SCR_EditableEntitySlotManagerUIComponent.c:1
m_SlotManager
SCR_SlotServiceComponentClass m_SlotManager
Service with basic slot handling functionalities.
SCR_BaseEditableEntityFilter
Definition: SCR_BaseEditableEntityFilter.c:13
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13