DayZ 1.24
Loading...
Searching...
No Matches
PPERequestPlatformsBase.c
Go to the documentation of this file.
3{
4 protected bool m_IsRunning; //helps determine if the requester has been stopped or not
5 protected bool m_ValuesSent;
6 protected int m_IDX;
7
8 protected bool m_Valid = false;
9
10 protected ref map<int, ref map<int, ref PPERequestParamDataBase>> m_RequestDataStructure; // <material<param_id,data>> // parameter data objects are singletons
11
21
24 {
25 if (!m_Valid)
26 {
27 Debug.Log("" + this + " not valid!");
28 return;
29 }
30
31 PPEManagerStatic.GetPPEManager().SetRequestUpdating(this, state);
32
33 //TODO - separate into its own function?
34 if (state)
35 PPEManagerStatic.GetPPEManager().SetRequestActive(this, true);
36 }
37
39 {
40 OnStart(par);
41 m_IsRunning = true;
42 }
43
45 {
47 return;
48
49 OnStop(par);
50 m_IsRunning = false;
51 }
52
54 {
55 return m_IsRunning;
56 }
57
60 {
61 m_IDX = idx;
62 }
63
66 {
67 return m_IDX;
68 }
69
72 {
73 return PPERequesterCategory.NONE;
74 }
75
76 //SETTERS//
77 //vvvvvvv//
78 protected void SetTargetValueBool(int mat_id, int param_idx, bool val, int priority_layer, int operator = PPOperators.SET)
79 {
81 return;
82
84 data.SetPriorityLayer(priority_layer);
85 data.SetInteractionMask(operator);
86
87 data.m_BoolTarget = val;
88 data.m_BoolLast = data.m_BoolCurrent;
89
90 if (data.m_BoolTarget != data.m_BoolCurrent || data.IsSettingDefaultValues())
91 {
92 data.SetSettingDefaultValues(false);
93 data.SetDataActive(true);
94
96 }
97 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueBool | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
98 }
99
101 {
102 //TODO - running check and cleanup rework (elsewhere!)
104 return;
105
107 data.m_BoolLast = data.m_BoolCurrent;
108 if (!data.IsSettingDefaultValues())
109 {
110 data.SetSettingDefaultValues(true);
111
113 }
114 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueBoolDefault | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
115 }
116
117 protected void SetTargetValueInt(int mat_id, int param_idx, bool relative, int val, int priority_layer, int operator = PPOperators.SET)
118 {
120 return;
121
122 PPERequestParamDataInt data = PPERequestParamDataInt.Cast(GetRequestData(mat_id, param_idx, PPEConstants.VAR_TYPE_INT));
123 data.SetPriorityLayer(priority_layer);
124 data.SetInteractionMask(operator);
125
126 data.m_IntTarget = val;
127 data.m_IntLast = data.m_IntCurrent;
128 if (data.m_IntTarget != data.m_IntCurrent || data.IsSettingDefaultValues())
129 {
130 data.SetSettingDefaultValues(false);
131 data.SetDataActive(true);
132
134 }
135 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueInt | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
136 }
137
139 {
140 //TODO - running check and cleanup rework (elsewhere!)
142 return;
143
144 PPERequestParamDataInt data = PPERequestParamDataInt.Cast(GetRequestData(mat_id, param_idx, PPEConstants.VAR_TYPE_INT));
145 data.m_IntLast = data.m_IntCurrent;
146 if (!data.IsSettingDefaultValues())
147 {
148 data.SetSettingDefaultValues(true);
149
151 }
152 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueIntDefault | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
153 }
154
155 protected void SetTargetValueFloat(int mat_id, int param_idx, bool relative, float val, int priority_layer, int operator = PPOperators.ADD_RELATIVE)
156 {
158 return;
159
161 data.SetPriorityLayer(priority_layer);
162 data.SetInteractionMask(operator);
163
164 data.m_FloatFormerTarget = data.m_FloatTarget;
165 data.m_FloatTarget = RelativizeValue(val, PPEConstants.VAR_TYPE_FLOAT, mat_id, param_idx, relative);
166 data.m_FloatLast = data.m_FloatCurrent;
167 data.m_FloatStart = data.m_FloatCurrent;
168 if (data.m_FloatTarget != data.m_FloatCurrent || data.IsSettingDefaultValues())
169 {
170 data.SetSettingDefaultValues(false);
171 data.SetDataActive(true);
172
174 }
175 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueFloat | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
176 }
177
179 {
180 //TODO - running check and cleanup rework (elsewhere!)
182 return;
183
185 data.m_FloatFormerTarget = data.m_FloatTarget;
186 data.m_FloatLast = data.m_FloatCurrent;
187 data.m_FloatStart = data.m_FloatCurrent;
188 if (!data.IsSettingDefaultValues())
189 {
190 data.SetSettingDefaultValues(true);
191
193 }
194 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueFloatDefault | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
195 }
196
197 protected void SetTargetValueColor(int mat_id, int param_idx, ref array<float> val, int priority_layer, int operator = PPOperators.ADD_RELATIVE)
198 {
200 return;
201
202 PPERequestParamDataColor data = PPERequestParamDataColor.Cast(GetRequestData(mat_id, param_idx, PPEConstants.VAR_TYPE_COLOR));
203 data.SetPriorityLayer(priority_layer);
204 data.SetInteractionMask(operator);
205 data.m_ColorFormerTarget = data.m_ColorTarget;
206
207 data.m_ColorTarget.Copy(val);
208
209 data.m_ColorLast = data.m_ColorCurrent;
210 data.m_ColorStart = data.m_ColorCurrent;
211 //if (data.m_ColorTarget != data.m_ColorCurrent)
212 {
213 data.SetSettingDefaultValues(false);
214 data.SetDataActive(true);
215
217 }
218 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueColor | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
219 }
220
222 {
223 //TODO - running check and cleanup rework (elsewhere!)
225 return;
226
227 PPERequestParamDataColor data = PPERequestParamDataColor.Cast(GetRequestData(mat_id, param_idx, PPEConstants.VAR_TYPE_COLOR));
228 data.m_ColorFormerTarget = data.m_ColorTarget;
229 data.m_ColorLast = data.m_ColorCurrent;
230 data.m_ColorStart = data.m_ColorCurrent;
231 if (!data.IsSettingDefaultValues())
232 {
233 data.SetSettingDefaultValues(true);
234
236 }
237 //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueColorDefault | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
238 }
239
240 /*protected void SetTargetValueVector(int mat_id, int param_idx, bool relative, vector val, int priority_layer, int operator = PPOperators.ADD_RELATIVE)
241 {
242 }
243
244 void SetTargetValueTexture(int mat_id, int param_idx, string val, int priority_layer, int mask, bool override_priority = false)
245 {
246 }*/
247
248 /*void SetTargetValueResource(int mat_id, int param_idx, string val, int priority_layer, int mask, bool override_priority = false)
249 {
250 }*/
251
253 protected void QueueValuesSend()
254 {
255 m_ValuesSent = false;
256 //m_IsRunning = true;
258 }
259
262 {
265 {
268 else
269 {
272 }
273 }
274 else
275 {
278 temp_map.Set(param_idx, data);
280 }
281
282 if (!data)
283 Error("GetRequestData | no data found in the structure");
284
285 data.m_Requester = this;
286
287 return data;
288 }
289
291 {
293 switch (type)
294 {
295 case PPEConstants.VAR_TYPE_BOOL:
297 break;
298
299 case PPEConstants.VAR_TYPE_INT:
300 data = new PPERequestParamDataInt(m_IDX, mat_id, param_idx);
301 break;
302
303 case PPEConstants.VAR_TYPE_FLOAT:
305 break;
306
307 case PPEConstants.VAR_TYPE_COLOR:
308 data = new PPERequestParamDataColor(m_IDX, mat_id, param_idx);
309 break;
310 }
311 return data;
312 }
313
314 // unused?
319
320 protected void ClearRequesterData()
321 {
323 }
324
326 {
327 PPEManagerStatic.GetPPEManager().SendMaterialValueData(data);
328 }
329
330 //EVENTS//
331 //vvvvvv//
332 void OnUpdate(float delta)
333 {
334 //DbgPrnt("PPEDebug | PPERequesterBase | OnUpdate");
335
336 if (!m_ValuesSent)
337 {
338 for (int i = 0; i < m_RequestDataStructure.Count(); i++)
339 {
340 for (int j = 0; j < m_RequestDataStructure.GetElement(i).Count(); j++)
341 {
342 SendCurrentValueData(m_RequestDataStructure.GetElement(i).GetElement(j)); //map<int,ref map<int,PPERequestParamDataBase>> //<material<param,data>>
343 }
344 }
345 m_ValuesSent = true;
346 }
348 }
349
350 protected void OnStart(Param par = null)
351 {
353 }
354
356 protected void OnStop(Param par = null)
357 {
358 //DbgPrnt("PPEDebug | " + this + " | OnStop");
361 }
362
364 protected float RelativizeValue(float value, int var_type, int mat_id, int param_id, bool relative)
365 {
366 float ret = value;
367 if (!relative) //if not already relative...
368 {
369 switch (var_type)
370 {
371 case PPEConstants.VAR_TYPE_FLOAT:
373 ret = Math.InverseLerp(p_float.param3, p_float.param4, ret);
374 ret = Math.Clamp(ret, 0.0, 1.0);
375 break;
376 }
377 }
378 //Print("RelativizeValue: " + ret);
379
380 return ret;
381 }
382
384 protected void SetDefaultValuesAll()
385 {
386 //<material<param_id,data>>
388
389 for (int i = 0; i < m_RequestDataStructure.Count(); i++)
390 {
391 for (int j = 0; j < m_RequestDataStructure.GetElement(i).Count(); j++)
392 {
393 req_data = m_RequestDataStructure.GetElement(i).GetElement(j);
394
395 if (!req_data.IsDataActive())
396 continue;
397
398 switch (req_data.GetVarType())
399 {
400 case PPEConstants.VAR_TYPE_BOOL:
401 SetTargetValueBoolDefault(req_data.GetMaterialID(), req_data.GetParameterID());
402 break;
403
404 case PPEConstants.VAR_TYPE_INT:
405 SetTargetValueIntDefault(req_data.GetMaterialID(), req_data.GetParameterID());
406 break;
407
408 case PPEConstants.VAR_TYPE_FLOAT:
409 SetTargetValueFloatDefault(req_data.GetMaterialID(), req_data.GetParameterID());
410 break;
411
412 case PPEConstants.VAR_TYPE_COLOR:
413 SetTargetValueColorDefault(req_data.GetMaterialID(), req_data.GetParameterID());
414 break;
415 }
416 }
417 }
418 }
419
420 void DbgPrnt(string text)
421 {
422 //Debug.Log(""+text);
423 }
424}
425
427// Base requester platforms //
429
431{
432 override int GetCategoryMask()
434 return PPERequesterCategory.GAMEPLAY_EFFECTS;
436}
440 override int GetCategoryMask()
442 return PPERequesterCategory.MENU_EFFECTS;
443 }
444}
PPOperators
PP operators, specify operation between subsequent layers.
PPERequesterCategory
void PPERequestParamDataBool(int requester_idx, int mat_id, int param_id, int data_type=0, int priority=0, int mask=PPOperators.SET, bool relative=false)
void PPERequestParamDataFloat(int requester_idx, int mat_id, int param_id, int data_type=0, int priority=0, int mask=PPOperators.SET, bool relative=false)
class PPERequesterBase GetCategoryMask()
mask for mass-handling methods like 'StopAllEffects'
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
Definition EnMath.c:7
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
Data for one material parameter, requester side.
base, not to be used directly, would lead to layering collisions!
void DbgPrnt(string text)
void SetTargetValueIntDefault(int mat_id, int param_idx)
int GetRequesterIDX()
Returns requester index.
void OnUpdate(float delta)
void SetTargetValueFloatDefault(int mat_id, int param_idx)
void Stop(Param par=null)
void SetDefaultValuesAll()
Sets all requested values to default, ignoring them in further calculations.
void QueueValuesSend()
Sets this requester to update in the manager.
void PPERequesterBase(int requester_IDX)
void SetTargetValueColorDefault(int mat_id, int param_idx)
void SetTargetValueFloat(int mat_id, int param_idx, bool relative, float val, int priority_layer, int operator=PPOperators.ADD_RELATIVE)
PPERequestParamDataBase GetRequestData(int mat_id, int param_idx, int type)
returns request data for specific parameter, or creates one if one does not exist in this request yet...
void OnStop(Param par=null)
automatically resets all material parameters of this requester to defaults
ref map< int, ref map< int, ref PPERequestParamDataBase > > m_RequestDataStructure
void SendCurrentValueData(PPERequestParamDataBase data)
void SetTargetValueBoolDefault(int mat_id, int param_idx)
map< int, ref map< int, ref PPERequestParamDataBase > > GetActiveRequestStructure()
PPERequestParamDataBase PrepareData(int mat_id, int param_idx, int type)
void SetTargetValueInt(int mat_id, int param_idx, bool relative, int val, int priority_layer, int operator=PPOperators.SET)
int GetCategoryMask()
mask for mass-handling methods like 'StopAllEffects'
void SetTargetValueColor(int mat_id, int param_idx, ref array< float > val, int priority_layer, int operator=PPOperators.ADD_RELATIVE)
void SetRequesterUpdating(bool state)
Has to be set for the requester to be handled.
void SetTargetValueBool(int mat_id, int param_idx, bool val, int priority_layer, int operator=PPOperators.SET)
void SetRequesterIDX(int idx)
automatically assigned by PPERequesterBank
float RelativizeValue(float value, int var_type, int mat_id, int param_id, bool relative)
converts all values used to relative values (if not relative already)
void Start(Param par=null)
void OnStart(Param par=null)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
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,...