Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
rainprocurementhandler.c
Go to the documentation of this file.
2{
4 protected ref set<RainProcurementComponentBase> m_ActiveComponents;
5 protected ref set<RainProcurementComponentBase> m_ChangedQueue;
6 protected ref set<int> m_CleanupQueue;
7 protected const int UPDATE_BATCH_SIZE = 20; //Tweak this to adjust max batch size
8 const int UPDATE_TIME = 10; //seconds
9 protected bool m_Update;
10 protected bool m_ProcessComponents;
11 protected bool m_ProcessingFinished;
12 protected int m_NextToProcessIdx;
13 protected float m_UpdateTimer;
14 protected float m_LiquidAmountCoef;
15
17 {
19 m_Update = false;
20 m_ProcessComponents = false;
22 m_ActiveComponents = new set<RainProcurementComponentBase>;
23 m_ChangedQueue = new set<RainProcurementComponentBase>;
24 m_CleanupQueue = new set<int>;
26 m_UpdateTimer = 0;
27 }
28
34
40
41 void Update(float timeslice)
42 {
43 if (!m_Update)
44 return;
45
47 {
48 if (m_ProcessingFinished) //do on start and after the batch is finished
49 {
51 if (m_LiquidAmountCoef == 0) //skip processing when not raining
52 {
53 Reset();
54 return;
55 }
56 }
57
59
61 {
62 Reset();
63 }
64 }
65 else
66 {
67 m_UpdateTimer += timeslice;
69 {
71 Cleanup();
74 if (!m_Update)
75 Reset();
76 }
77 }
78 }
79
81 protected bool ProcessBatch()
82 {
83 bool ret = false;
84 int count = m_ActiveComponents.Count();
85 int target = (int)Math.Clamp(m_NextToProcessIdx + UPDATE_BATCH_SIZE,0,count);
86
88 {
91 else
93 }
94
95 ret = target == count;
96 if (ret)
97 {
99 }
100
101 return ret;
102 }
103
104 protected void Cleanup()
105 {
106 int count = m_CleanupQueue.Count();
107 if (count == 0)
108 return;
109
110 for (int i = count - 1; i > -1; i--)
111 {
113 }
114 m_CleanupQueue.Clear();
115 }
116
117 protected void Reset()
118 {
119 m_ProcessComponents = false;
121 m_UpdateTimer = 0;
122 }
123
124 protected void HandleChangedComponents()
125 {
127 int count = m_ChangedQueue.Count();
128 int idx;
129
130 for (int i = 0; i < count; i++)
131 {
133 if (!component)
134 continue;
135
136 if (component.IsActive())
137 {
139 }
140 else
141 {
142 idx = m_ActiveComponents.Find(component);
143 if (idx != -1)
144 m_ActiveComponents.Remove(idx);
145 }
146 }
147 m_ChangedQueue.Clear();
148 }
149
150 protected void CheckUpdating()
151 {
152 m_Update = m_ActiveComponents.Count() != 0;
153 }
154
156 {
157 return m_LiquidAmountCoef;
158 }
159
162 {
163 return GetGame().GetWeather().GetRain().GetActual() + GetGame().GetWeather().GetSnowfall().GetActual();
164 }
165};
Param3 int
proto native Weather GetWeather()
Returns weather controller object.
TODO doc.
Definition enscript.c:118
Definition enmath.c:7
float DetermineAmountCoef()
scalable on handler level. Now also handles SNOW, total value can exceed 1.0
void QueueStart(RainProcurementComponentBase component)
void RainProcurementHandler(MissionBaseWorld mission)
bool ProcessBatch()
returns 'true' when all the batches are finished
void Update(float timeslice)
ref set< RainProcurementComponentBase > m_ActiveComponents
void QueueStop(RainProcurementComponentBase component)
ref set< RainProcurementComponentBase > m_ChangedQueue
Mission mission
proto native CGame GetGame()
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.