10 protected int m_LastDropIdx;
11 protected int m_ImageWidgetCount;
14 protected Widget m_BloodDropsFrame;
16 protected int m_LastPositionFrameUsed;
18 void GameplayEffectsDataBleeding(
array<ref Widget> input,
int type,
int user_override = -1)
28 super.Init(input, type, layout_root, user_override);
30 m_WidgetArray.ShuffleArray();
31 m_ImageWidgetCount = m_WidgetArray.Count();
32 m_BloodDropsFrame = m_LayoutRoot.FindAnyWidgetById(EffectWidgetsTypes.BLEEDING_LAYER);
36 m_LastPositionFrameUsed = -1;
41 BuildPositioningData();
44 override bool HasDefinedHandle()
49 override bool DataInitialized()
54 override void RegisterData(
Param p)
59 ErrorEx(
"" +
this +
" is already initialized, further registration not possible!");
61 Debug.Log(
"ERROR: " +
this +
" is already initialized, further registration not possible!");
68 if (
Class.CastTo(par,p))
70 if (par.param1 ==
true)
76 RegisterBleedingIndicatorInstance(par.param2,par.param3);
80 void RegisterBleedingIndicatorInstance(
int bit,
float flow_modifier)
82 int severity = CalculateSeverity(flow_modifier);
83 BleedingIndicator indicator =
new BleedingIndicator(bit,severity,
this);
84 m_RegisteredInstances.Set(bit,indicator);
87 void SpawnBleedingIndicator(
int source_ID,
vector position)
89 if (m_RunningIndicators.Find(source_ID) != -1)
93 BleedingIndicator indicator = m_RegisteredInstances.Get(source_ID);
95 indicator.InitIndicator(GenerateSequenceRandomPosition());
96 m_RunningIndicators.Insert(source_ID);
99 int CalculateSeverity(
float flow_modifier)
101 switch (flow_modifier)
115 ImageWidget GetNextDropImage()
118 if (m_LastDropIdx > (m_ImageWidgetCount - 1))
123 return ImageWidget.Cast(m_WidgetArray[m_LastDropIdx]);
126 void StopBleedingIndicator(
int source_ID,
bool instant =
false)
128 m_RegisteredInstances.Get(source_ID).StopIndicator(instant);
131 void UpdateBleedingIndicators(
float timeSlice)
133 BleedingIndicator bib;
134 for (
int i = 0; i < m_RunningIndicators.Count(); i++)
136 bib = m_RegisteredInstances.Get(m_RunningIndicators[i]);
137 bib.Update(timeSlice);
138 if ( bib.GetEndNow() )
140 m_CleanupQueue.Insert(m_RunningIndicators[i]);
145 void CleanupBleedingIndicators()
147 for (
int i = 0; i < m_CleanupQueue.Count(); i++)
149 m_RunningIndicators.RemoveItem(m_CleanupQueue[i]);
151 m_CleanupQueue.Clear();
154 override void Update(
float timeSlice = 0,
Param p =
null,
int handle = -1)
161 Param4<bool,int,vector,bool> par;
165 Param1<bool> parShow;
167 if (
Class.CastTo(par,p))
169 bool state = par.param1;
172 SpawnBleedingIndicator(par.param2,par.param3);
176 StopBleedingIndicator(par.param2,par.param4);
187 UpdateBleedingIndicators(timeSlice);
188 CleanupBleedingIndicators();
190 if (m_RunningIndicators.Count() <= 0)
192 GetGame().GetMission().GetEffectWidgets().RemoveActiveEffects({EffectWidgetsTypes.BLEEDING_LAYER});
193 m_WidgetArray.ShuffleArray();
197 override void UpdateVisibility(
bool state)
201 Widget w = m_BloodDropsFrame;
202 while (w && w != m_LayoutRoot &&
m_Visible == state && w.IsVisibleHierarchy() != state)
210 override void ForceStop()
214 foreach (
int i: m_RunningIndicators)
216 m_RegisteredInstances.Get(i).StopIndicator(
true);
221 void BuildProbabilityData(
int severity,
float frequency)
223 if (!m_ProbabilityMap)
232 probabilities.Insert(
Math.Poisson(frequency,i));
235 m_ProbabilityMap.Insert(severity,probabilities);
243 ErrorEx(
"No defined data for the selected severity!");
248 void BuildPositioningData()
250 Widget frameParent = m_LayoutRoot.FindAnyWidget(
"PoisitioningFrames");
253 if (!m_PositioningFramesArray)
258 Widget frame = frameParent.GetChildren();
261 m_PositioningFramesArray.Insert(frame);
262 frame = frame.GetSibling();
267 vector GenerateSequenceRandomPosition()
269 if (m_PositioningFramesArray)
271 int arrayCount = m_PositioningFramesArray.Count();
272 int index =
Math.RandomInt(0,arrayCount);
273 if (index == m_LastPositionFrameUsed)
276 if (index >= arrayCount)
282 Widget frame = m_PositioningFramesArray[index];
283 m_LastPositionFrameUsed = index;
288 float x,
y,x_size,y_size;
289 frame.GetScreenPos(
x,
y);
290 frame.GetScreenSize(x_size,y_size);
292 x =
Math.RandomFloatInclusive(
x,
x+x_size);
293 y =
Math.RandomFloatInclusive(
y,
y+y_size);