Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
GadgetsSystem.c
Go to the documentation of this file.
2{
3 override static void InitInfo(WorldSystemInfo outInfo)
4 {
5 outInfo
6 .SetAbstract(false)
7 .AddPoint(ESystemPoint.Frame);
8 }
9
10 protected bool m_bUpdating = false;
11 protected ref array<SCR_GadgetComponent> m_Components = {};
12 protected ref array<SCR_GadgetComponent> m_DeletedComponents = {};
13
14 //------------------------------------------------------------------------------------------------
15 protected override void OnUpdatePoint(WorldUpdatePointArgs args)
16 {
17 float timeSlice = args.GetTimeSliceSeconds();
18
19 m_bUpdating = true;
20
21 foreach (SCR_GadgetComponent comp: m_Components)
22 {
23 comp.Update(timeSlice);
24 }
25
26 m_bUpdating = false;
27
28 foreach (SCR_GadgetComponent comp: m_DeletedComponents)
29 {
30 Unregister(comp);
31 }
32 m_DeletedComponents.Clear();
33 }
34
35 //------------------------------------------------------------------------------------------------
36 protected override void OnDiag(float timeSlice)
37 {
38 DbgUI.Begin("GadgetsSystem");
39
40 DbgUI.Text("Items: " + m_Components.Count());
41
42 if (DbgUI.Button("Dump active components"))
43 {
44 foreach (SCR_GadgetComponent comp: m_Components)
45 {
46 Print(comp.GetOwner(), LogLevel.ERROR);
47 }
48 }
49
50 DbgUI.End();
51 }
52
53 //------------------------------------------------------------------------------------------------
55 void Register(SCR_GadgetComponent component)
56 {
57 //About to be deleted
58 if (component.GetOwner().IsDeleted() || (component.GetOwner().GetFlags() & EntityFlags.USER5))
59 return;
60
61 if (m_Components.Find(component) != -1)
62 return;
63
64 m_Components.Insert(component);
65 }
66
67 //------------------------------------------------------------------------------------------------
68 void Unregister(SCR_GadgetComponent component)
69 {
70 int idx = m_Components.Find(component);
71 if (idx == -1)
72 return;
73
74 if (m_bUpdating)
75 m_DeletedComponents.Insert(component);
76 else
77 m_Components.Remove(idx);
78 }
79}
Definition DbgUI.c:66
ref array< SCR_GadgetComponent > m_DeletedComponents
void Register(SCR_GadgetComponent component)
void Unregister(SCR_GadgetComponent component)
ref array< SCR_GadgetComponent > m_Components
override void OnDiag(float timeSlice)
override void OnUpdatePoint(WorldUpdatePointArgs args)
Structure holding world system meta-information required by the engine.
Structure holding extra data of WorldSystem update point.
WorldSystemPoint ESystemPoint
Definition gameLib.c:7
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
EntityFlags
Various entity flags.
Definition EntityFlags.c:14