Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
GadgetsSystem.c
Go to the documentation of this file.
2 {
3  protected bool m_bUpdating = false;
4  protected ref array<SCR_GadgetComponent> m_Components = {};
5  protected ref array<SCR_GadgetComponent> m_DeletedComponents = {};
6 
7  //------------------------------------------------------------------------------------------------
8  protected override void OnUpdate(ESystemPoint point)
9  {
10  float timeSlice = GetWorld().GetTimeSlice();
11 
12  m_bUpdating = true;
13 
14  foreach (SCR_GadgetComponent comp: m_Components)
15  {
16  comp.Update(timeSlice);
17  }
18 
19  m_bUpdating = false;
20 
21  foreach (SCR_GadgetComponent comp: m_DeletedComponents)
22  {
23  Unregister(comp);
24  }
25  m_DeletedComponents.Clear();
26  }
27 
28  //------------------------------------------------------------------------------------------------
29  protected override void OnDiag(float timeSlice)
30  {
31  DbgUI.Begin("GadgetsSystem");
32 
33  DbgUI.Text("Items: " + m_Components.Count());
34 
35  if (DbgUI.Button("Dump active components"))
36  {
37  foreach (SCR_GadgetComponent comp: m_Components)
38  {
39  Print(comp.GetOwner(), LogLevel.ERROR);
40  }
41  }
42 
43  DbgUI.End();
44  }
45 
46  //------------------------------------------------------------------------------------------------
48  void Register(SCR_GadgetComponent component)
49  {
50  //About to be deleted
51  if (component.GetOwner().IsDeleted() || (component.GetOwner().GetFlags() & EntityFlags.USER5))
52  return;
53 
54  if (m_Components.Find(component) != -1)
55  return;
56 
57  m_Components.Insert(component);
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  void Unregister(SCR_GadgetComponent component)
62  {
63  int idx = m_Components.Find(component);
64  if (idx == -1)
65  return;
66 
67  if (m_bUpdating)
68  m_DeletedComponents.Insert(component);
69  else
70  m_Components.Remove(idx);
71  }
72 }
GadgetsSystem
Definition: GadgetsSystem.c:1
GameSystem
Definition: GameSystem.c:12