Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
bleedingdrop.c
Go to the documentation of this file.
1
3{
4 protected ImageWidget m_Widget;
5 protected int m_Severity;
6 protected float m_TimeTotal;
7 protected float m_ProgressBreakpointTime;
8 protected float m_ProgressFadingDuration; //remaining duration AFTER breakpoint
9 protected float m_ProgressBreakpoint;
10 protected float m_Duration;
11 protected float m_SpeedCoef;
12 protected int m_ScatterPx;
13 protected float m_SlideDistance;
14
15 protected float m_ColorAlphaStart;
16 protected float m_ColorAlphaEnd;
17 protected float m_ColorAlphaCurrent;
18
19 protected float m_ImageBaseSizeX;
20 protected float m_ImageBaseSizeY;
21 protected float m_ImageStartingSizeX; //adjusted by percentage
22 protected float m_ImageStartingSizeY; //adjusted by percentage
23 protected float m_ImageEndSizeX; //adjusted by percentage
24 protected float m_ImageEndSizeY; //adjusted by percentage
25 protected float m_ImageMaxSizeX;
26 protected float m_ImageMaxSizeY;
27 protected float m_ImageBaseRotation;
28 protected bool m_IsRunning;
30 protected int m_ScreenSizeX;
31 protected int m_ScreenSizeY;
32 protected float m_PosX, m_PosY;
33 protected float m_StartSizeCoef;
34 protected float m_EndSizeCoef;
35 protected float m_RandomSizeMin;
36 protected float m_RandomSizeMax;
37
38 //Written with relative positioning in mind
39 void BleedingIndicatorDropData(ImageWidget image, int severity)
40 {
41 m_Widget = image;
42 m_Severity = severity;
43 m_TimeTotal = 0;
44 m_IsRunning = false;
45
46#ifdef DIAG_DEVELOPER
48 {
58 }
59 else
60#endif
61 {
62 switch (m_Severity)
63 {
65 {
73 break;
74 }
76 {
84 break;
85 }
87 {
95 break;
96 }
97 }
98
101 }
103
104 m_SpeedCoef = 1.0; //TODO ??
105#ifdef DIAG_DEVELOPER
107 {
110 }
111 else
112#endif
113 {
116 }
120 }
121
123 {
124 }
125
126 protected void InitImageScale()
127 {
130
132 m_ImageEndSizeX = m_ImageBaseSizeX * m_EndSizeCoef * randomScaleCoef;
134 m_ImageEndSizeY = m_ImageBaseSizeY * m_EndSizeCoef * randomScaleCoef;
135 }
136
138 {
139#ifdef DIAG_DEVELOPER
141 {
143 }
144#endif
145 float rndRadius = Math.RandomFloatInclusive(0.0,m_ScatterPx);
146 float rndPos = Math.RandomFloatInclusive(0.0,Math.PI2);
147 m_PosX = pos[0];
148 m_PosX = m_PosX + rndRadius * Math.Sin(rndPos);
149
150 m_PosY = pos[1];
151 m_PosY = m_PosY + rndRadius * Math.Cos(rndPos);
152 }
153
155 {
156 m_TimeTotal = 0;
157
159 m_Widget.SetPos(m_PosX,m_PosY);
160#ifdef DIAG_DEVELOPER
162 {
163 m_Widget.SetRotation(0,0,0);
164 }
165 else
166#endif
167 {
168 m_Widget.SetRotation(0,0,Math.RandomFloatInclusive(0.0,360.0));
169 }
170
171 m_Widget.Show(true);
172 m_IsRunning = true;
173 }
174
175 void StopDrop()
176 {
177 m_IsRunning = false;
178 m_Widget.SetSize(m_ImageBaseSizeX,m_ImageBaseSizeY); //resets image size
179 m_Widget.Show(false);
180 }
181
188
190 {
191 return m_IsRunning;
192 }
193
194 ImageWidget GetImage()
195 {
196 return m_Widget;
197 }
198
200 {
201 //color adjustment
206#ifdef DIAG_DEVELOPER
208 {
213 }
214#endif
215
216 //saturation adjustment
217#ifdef DIAG_DEVELOPER
219 {
220#endif
221 Param par = PPEManagerStatic.GetPPEManager().GetPostProcessCurrentValues(PostProcessEffectType.Glow,PPEGlow.PARAM_SATURATION);
222 float saturationProgress = Param1<float>.Cast(par).param1;
223 saturationProgress = Easing.EaseOutSine(saturationProgress);
224 saturationProgress = Math.Lerp(desaturationEnd,1.0,saturationProgress);
225 float lowest_channel = Math.Min(Math.Min(r,g),b);
226 r = Math.Lerp(lowest_channel,r,saturationProgress);
227 g = Math.Lerp(lowest_channel,g,saturationProgress);
228 b = Math.Lerp(lowest_channel,b,saturationProgress);
229#ifdef DIAG_DEVELOPER
230 }
231#endif
232
233 int color = ARGB(0x00,r,g,b);
234 m_Widget.SetColor(color);
235 }
236
237 void UpdateAlpha(float progress,float progressFade)
238 {
239 if (progress <= m_ProgressBreakpoint)
240 {
242 }
243 else
244 {
246 }
247
249 }
250
252 void UpdateTransform(float progress, float progressFade)
253 {
254 float breakProgress = Math.Clamp(Math.InverseLerp(0.0,m_ProgressBreakpoint,progress),0,1);
255 float sizeX = Math.Lerp(m_ImageStartingSizeX,m_ImageEndSizeX,breakProgress);
256 float sizeY = Math.Lerp(m_ImageStartingSizeY,m_ImageEndSizeY,breakProgress);
257 m_Widget.SetSize(sizeX,sizeY);
258
259 if (progress <= m_ProgressBreakpoint)
260 {
261 //do stuff before breakpoint
262 }
263 else
264 {
265 //do stuff after breakpoint
266 float posYTemp = Math.Lerp(m_PosY,m_PosY + m_SlideDistance, progressFade);
267 m_Widget.SetPos(m_PosX,posYTemp);
268 }
269 }
270
271 void Update(float timeSlice)
272 {
273 if (m_IsRunning)
274 {
275 float progress, progressFade;
276 progress = m_TimeTotal / m_Duration;
278
279 //alpha
280 UpdateAlpha(progress,progressFade);
281 //transform + scaling
282 UpdateTransform(progress,progressFade);
283
284 m_TimeTotal += (timeSlice * m_SpeedCoef);
285
286 if (m_TimeTotal >= m_Duration)
287 {
288 //deletes this;
289 StopDrop();
290 }
291 }
292 }
293}
void UpdateTransform(float progress, float progressFade)
scaling and transformation
void UpdateAlpha(float progress, float progressFade)
void SetBasePosition(vector pos)
void Update(float timeSlice)
void ScatterPosition(vector pos)
void BleedingIndicatorDropData(ImageWidget image, int severity)
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition easing.c:3
static float EaseOutSine(float t)
Definition easing.c:9
Definition enmath.c:7
Glow - PostProcessEffectType.Glow.
Definition ppeglow.c:8
static const int PARAM_SATURATION
Definition ppeglow.c:31
Static component of PPE manager, used to hold the instance.
Definition ppemanager.c:3
static PPEManager GetPPEManager()
Returns the manager instance singleton.
Definition ppemanager.c:27
Base Param Class with no parameters.
Definition param.c:12
PostProcessEffectType
Post-process effect type.
Definition enworld.c:72
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition enmath.c:106
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static const float PI2
Definition enmath.c:13
static proto float Sin(float angle)
Returns sinus of angle in radians.
proto void GetScreenSize(out int x, out int y)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322