Dayz Explorer 1.28.160049
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
47 if (DbgBleedingIndicationStaticInfo.m_DbgUseOverrideValues)
48 {
49 m_Duration = DbgBleedingIndicationStaticInfo.m_DbgDropDurationBase;
51 m_ProgressBreakpoint = DbgBleedingIndicationStaticInfo.m_DbgDropProgressTreshold;
54 m_RandomSizeMin = DbgBleedingIndicationStaticInfo.m_DbgDropSizeVariationMin;
55 m_RandomSizeMax = DbgBleedingIndicationStaticInfo.m_DbgDropSizeVariationMax;
57 m_SlideDistance = DbgBleedingIndicationStaticInfo.m_DbgDropSlideDistance;
58 }
59 else
60#endif
61 {
62 switch (m_Severity)
63 {
64 case BleedingIndicationConstants.INDICATOR_SEVERITY_LOW:
65 {
66 m_Duration = BleedingIndicationConstants.DROP_DURATION_LOW;
67 m_StartSizeCoef = BleedingIndicationConstants.DROP_SIZE_START_LOW;
69 m_RandomSizeMin = BleedingIndicationConstants.DROP_SIZE_VARIATION_MIN_LOW;
70 m_RandomSizeMax = BleedingIndicationConstants.DROP_SIZE_VARIATION_MAX_LOW;
72 m_SlideDistance = BleedingIndicationConstants.DROP_SLIDE_DISTANCE_LOW;
73 break;
74 }
75 case BleedingIndicationConstants.INDICATOR_SEVERITY_MEDIUM:
76 {
77 m_Duration = BleedingIndicationConstants.DROP_DURATION_MEDIUM;
78 m_StartSizeCoef = BleedingIndicationConstants.DROP_SIZE_START_MEDIUM;
79 m_EndSizeCoef = BleedingIndicationConstants.DROP_SIZE_END_MEDIUM;
80 m_RandomSizeMin = BleedingIndicationConstants.DROP_SIZE_VARIATION_MIN_MEDIUM;
81 m_RandomSizeMax = BleedingIndicationConstants.DROP_SIZE_VARIATION_MAX_MEDIUM;
82 m_ScatterPx = BleedingIndicationConstants.DROP_SCATTER_MEDIUM;
83 m_SlideDistance = BleedingIndicationConstants.DROP_SLIDE_DISTANCE_MEDIUM;
84 break;
85 }
86 case BleedingIndicationConstants.INDICATOR_SEVERITY_HIGH:
87 {
88 m_Duration = BleedingIndicationConstants.DROP_DURATION_HIGH;
89 m_StartSizeCoef = BleedingIndicationConstants.DROP_SIZE_START_HIGH;
90 m_EndSizeCoef = BleedingIndicationConstants.DROP_SIZE_END_HIGH;
91 m_RandomSizeMin = BleedingIndicationConstants.DROP_SIZE_VARIATION_MIN_HIGH;
92 m_RandomSizeMax = BleedingIndicationConstants.DROP_SIZE_VARIATION_MAX_HIGH;
93 m_ScatterPx = BleedingIndicationConstants.DROP_SCATTER_HIGH;
94 m_SlideDistance = BleedingIndicationConstants.DROP_SLIDE_DISTANCE_HIGH;
95 break;
96 }
97 }
98
100 m_ProgressBreakpoint = BleedingIndicationConstants.DROP_PROGRESS_THRESHOLD;
101 }
103
104 m_SpeedCoef = 1.0; //TODO ??
105#ifdef DIAG_DEVELOPER
106 if (DbgBleedingIndicationStaticInfo.m_DbgUseOverrideValues)
107 {
108 m_ColorAlphaStart = DbgBleedingIndicationStaticInfo.m_DbgDropColorAlphaStart / 255;
109 m_ColorAlphaEnd = DbgBleedingIndicationStaticInfo.m_DbgDropColorAlphaEnd / 255;
110 }
111 else
112#endif
113 {
114 m_ColorAlphaStart = BleedingIndicationConstants.DROP_COLOR_ALPHA_START / 255;
115 m_ColorAlphaEnd = BleedingIndicationConstants.DROP_COLOR_ALPHA_END / 255;
116 }
120 }
121
123 {
124 }
125
126 protected void InitImageScale()
127 {
129 float randomScaleCoef = Math.RandomFloatInclusive(m_RandomSizeMin,m_RandomSizeMax);
130
132 m_ImageEndSizeX = m_ImageBaseSizeX * m_EndSizeCoef * randomScaleCoef;
134 m_ImageEndSizeY = m_ImageBaseSizeY * m_EndSizeCoef * randomScaleCoef;
135 }
136
138 {
139#ifdef DIAG_DEVELOPER
140 if (DbgBleedingIndicationStaticInfo.m_DbgUseOverrideValues)
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
161 if (DbgBleedingIndicationStaticInfo.m_DbgUseOverrideValues && !DbgBleedingIndicationStaticInfo.m_DbgDropRotationRandom)
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
202 float r = BleedingIndicationConstants.DROP_COLOR_RED;
203 float g = BleedingIndicationConstants.DROP_COLOR_GREEN;
204 float b = BleedingIndicationConstants.DROP_COLOR_BLUE;
205 float desaturationEnd = BleedingIndicationConstants.DROP_COLOR_DESATURATIONEND;
206#ifdef DIAG_DEVELOPER
207 if (DbgBleedingIndicationStaticInfo.m_DbgUseOverrideValues)
208 {
209 r = DbgBleedingIndicationStaticInfo.m_DbgDropColorRed;
210 g = DbgBleedingIndicationStaticInfo.m_DbgDropColorGreen;
211 b = DbgBleedingIndicationStaticInfo.m_DbgDropColorBlue;
212 desaturationEnd = DbgBleedingIndicationStaticInfo.m_DbgDesaturationEnd;
213 }
214#endif
215
216 //saturation adjustment
217#ifdef DIAG_DEVELOPER
218 if (!DbgBleedingIndicationStaticInfo.m_DbgUseOverrideValues || (DbgBleedingIndicationStaticInfo.m_DbgUseOverrideValues && DbgBleedingIndicationStaticInfo.m_DbgDropDesaturate) )
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 BleedingIndicatorDropData(ImageWidget image, int severity)
void Update(float timeSlice)
void SetBasePosition(vector pos)
void UpdateAlpha(float progress, float progressFade)
void ScatterPosition(vector pos)
void UpdateTransform(float progress, float progressFade)
scaling and transformation
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition easing.c:3
Definition enmath.c:7
Glow - PostProcessEffectType.Glow.
Definition ppeglow.c:8
Static component of PPE manager, used to hold the instance.
Definition ppemanager.c:3
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
PostProcessEffectType
Post-process effect type.
Definition enworld.c:72
proto void GetScreenSize(out int x, out int y)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322