3 class BleedingIndicator
extends Managed
6 protected bool m_Terminating =
false;
7 protected bool m_EndNow =
false;
9 protected int m_DropSpawnsQueued;
10 protected int m_ActiveDropsCount;
11 protected int m_Severity;
12 protected int m_SourceID;
13 protected GameplayEffectsDataBleeding m_ParentMetaData;
16 protected float m_AverageFrequency;
17 protected float m_SequenceTick;
18 protected float m_SequenceDuration;
19 protected float m_TimeElapsedTotal;
20 protected float m_TimeElapsedSequence;
21 protected float m_LastDropSpawnTime;
22 protected float m_DropSpawnMinDelay;
23 protected float m_DropSpawnMaxDelay;
24 protected int m_CurrentDropProbabilityStep;
25 protected int m_DropProbabilityRollsCount;
26 protected vector m_BasePosition;
28 ref set<ref BleedingIndicatorDropData> m_ActiveDrops;
29 ref set<int> m_CleanupQueue;
31 void BleedingIndicator(
int source_ID,
int severity, GameplayEffectsDataBleeding parent)
34 m_SourceID = source_ID;
35 m_Severity = severity;
36 m_ParentMetaData = parent;
37 m_CurrentDropProbabilityStep = 0;
38 m_ActiveDrops =
new set<ref BleedingIndicatorDropData>;
39 m_CleanupQueue =
new set<int>;
40 m_DropProbabilityArray = m_ParentMetaData.GetProbabilities(m_Severity);
41 m_DropProbabilityRollsCount = m_DropProbabilityArray.Count();
75 Debug.Log(
"Unknown severity value!");
87 m_TimeElapsedTotal = 0;
88 m_TimeElapsedSequence = 0;
91 void InitIndicator(
vector position)
93 m_BasePosition = position;
98 void StopIndicator(
bool instant =
false)
108 m_Terminating =
true;
112 protected void StartRunningDrops()
114 m_ActiveDropsCount = 0;
117 m_DropSpawnsQueued = 0;
119 m_CurrentDropProbabilityStep = (
int)(m_DropProbabilityRollsCount - (m_DropProbabilityRollsCount / m_AverageFrequency));
123 protected bool IsRunningDrops()
125 return m_ActiveDropsCount > 0;
128 void TrySpawnNextDrop()
130 ImageWidget dropImage;
131 if (
Class.CastTo(dropImage,m_ParentMetaData.GetNextDropImage()) && !dropImage.IsVisible())
134 data.SetBasePosition(m_BasePosition);
137 m_ActiveDrops.Insert(data);
138 m_ActiveDropsCount++;
141 m_LastDropSpawnTime = m_TimeElapsedTotal;
142 m_DropSpawnsQueued--;
145 protected void ResetSequence()
147 m_CurrentDropProbabilityStep = 0;
148 m_TimeElapsedSequence = 0;
149 m_DropSpawnsQueued = 0;
152 void ResetIndicator()
154 m_Terminating =
false;
156 m_TimeElapsedTotal = 0;
157 m_CurrentDropProbabilityStep = 0;
158 m_TimeElapsedSequence = 0;
159 m_LastDropSpawnTime = 0;
160 m_DropSpawnsQueued = 0;
163 void Update(
float timeSlice)
170 #ifdef DIAG_DEVELOPER
176 m_SequenceTick = m_SequenceDuration / m_DropProbabilityRollsCount;
183 if (m_TimeElapsedSequence > (m_SequenceTick * m_CurrentDropProbabilityStep))
185 if (m_CurrentDropProbabilityStep < m_DropProbabilityRollsCount)
187 float rnd =
Math.RandomFloat01();
188 if (rnd < m_DropProbabilityArray[m_CurrentDropProbabilityStep])
190 m_DropSpawnsQueued++;
193 m_CurrentDropProbabilityStep++;
197 float sinceLastDrop = m_TimeElapsedTotal - m_LastDropSpawnTime;
198 if (m_TimeElapsedSequence > m_SequenceDuration)
202 else if (m_DropSpawnsQueued > 0)
204 if (sinceLastDrop >= m_DropSpawnMinDelay)
209 else if (sinceLastDrop > m_DropSpawnMaxDelay)
212 m_CurrentDropProbabilityStep++;
221 for (
int i = 0; i < m_ActiveDropsCount; i++)
226 m_ActiveDrops[i].Update(timeSlice);
230 m_ActiveDrops[i].StopDrop();
235 m_CleanupQueue.Insert(i);
240 for (i = m_CleanupQueue.Count() - 1; i >= 0; i--)
242 m_ActiveDrops.Remove(m_CleanupQueue[i]);
243 m_ActiveDropsCount--;
245 m_CleanupQueue.Clear();
247 if (m_Terminating && !IsRunningDrops())
252 m_TimeElapsedTotal += timeSlice;
253 m_TimeElapsedSequence += timeSlice;