Dayz Explorer 1.29.162510
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 {
126
127 int count = m_ChangedQueue.Count();
128 int idx;
129
131 {
132 if (!component)
133 continue;
134
135 if (component.IsActive())
136 {
138 }
139 else
140 {
141 idx = m_ActiveComponents.Find(component);
142 if (idx != -1)
143 m_ActiveComponents.Remove(idx);
144 }
145 }
146 m_ChangedQueue.Clear();
147 }
148
149 protected void CheckUpdating()
150 {
151 m_Update = m_ActiveComponents.Count() != 0;
152 }
153
155 {
156 return m_LiquidAmountCoef;
157 }
158
161 {
162 return g_Game.GetWeather().GetRain().GetActual() + g_Game.GetWeather().GetSnowfall().GetActual();
163 }
164};
Param3 int
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
DayZGame g_Game
Definition dayzgame.c:3942
Mission mission
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.