Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pperequestplatformsbase.c
Go to the documentation of this file.
1 
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 
12  void PPERequesterBase(int requester_IDX)
13  {
14  m_Valid = PPERequesterBank.VerifyRequester(this);
15 
16  m_IDX = requester_IDX;
17  m_ValuesSent = true;
18  m_IsRunning = false;
20  }
21 
23  void SetRequesterUpdating(bool state)
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 
38  void Start(Param par = null)
39  {
40  OnStart(par);
41  m_IsRunning = true;
42  }
43 
44  void Stop(Param par = null)
45  {
47  return;
48 
49  OnStop(par);
50  m_IsRunning = false;
51  }
52 
53  bool IsRequesterRunning()
54  {
55  return m_IsRunning;
56  }
57 
59  void SetRequesterIDX(int idx)
60  {
61  m_IDX = idx;
62  }
63 
65  int GetRequesterIDX()
66  {
67  return m_IDX;
68  }
69 
71  int GetCategoryMask()
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 
83  PPERequestParamDataBool data = PPERequestParamDataBool.Cast(GetRequestData(mat_id,param_idx,PPEConstants.VAR_TYPE_BOOL));
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 
95  QueueValuesSend();
96  }
97  //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueBool | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
98  }
99 
100  protected void SetTargetValueBoolDefault(int mat_id, int param_idx)
101  {
102  //TODO - running check and cleanup rework (elsewhere!)
103  if ( !m_RequestDataStructure || !m_RequestDataStructure.Get(mat_id) || !m_RequestDataStructure.Get(mat_id).Get(param_idx))
104  return;
105 
106  PPERequestParamDataBool data = PPERequestParamDataBool.Cast(GetRequestData(mat_id,param_idx,PPEConstants.VAR_TYPE_BOOL));
107  data.m_BoolLast = data.m_BoolCurrent;
108  if (!data.IsSettingDefaultValues())
109  {
110  data.SetSettingDefaultValues(true);
111 
112  QueueValuesSend();
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  {
119  if ( !m_RequestDataStructure )
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 
133  QueueValuesSend();
134  }
135  //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueInt | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
136  }
137 
138  protected void SetTargetValueIntDefault(int mat_id, int param_idx)
139  {
140  //TODO - running check and cleanup rework (elsewhere!)
141  if ( !m_RequestDataStructure || !m_RequestDataStructure.Get(mat_id) || !m_RequestDataStructure.Get(mat_id).Get(param_idx))
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 
150  QueueValuesSend();
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  {
157  if ( !m_RequestDataStructure )
158  return;
159 
160  PPERequestParamDataFloat data = PPERequestParamDataFloat.Cast(GetRequestData(mat_id,param_idx,PPEConstants.VAR_TYPE_FLOAT));
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 
173  QueueValuesSend();
174  }
175  //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueFloat | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
176  }
177 
178  protected void SetTargetValueFloatDefault(int mat_id, int param_idx)
179  {
180  //TODO - running check and cleanup rework (elsewhere!)
181  if ( !m_RequestDataStructure || !m_RequestDataStructure.Get(mat_id) || !m_RequestDataStructure.Get(mat_id).Get(param_idx))
182  return;
183 
184  PPERequestParamDataFloat data = PPERequestParamDataFloat.Cast(GetRequestData(mat_id,param_idx,PPEConstants.VAR_TYPE_FLOAT));
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 
192  QueueValuesSend();
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  {
199  if ( !m_RequestDataStructure )
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 
216  QueueValuesSend();
217  }
218  //DbgPrnt("PPEDebug | PPERequesterBase - SetTargetValueColor | mat/par/req: " + mat_id + "/" + param_idx + "/" + m_IDX + " | data: " + data);
219  }
220 
221  protected void SetTargetValueColorDefault(int mat_id, int param_idx)
222  {
223  //TODO - running check and cleanup rework (elsewhere!)
224  if ( !m_RequestDataStructure || !m_RequestDataStructure.Get(mat_id) || !m_RequestDataStructure.Get(mat_id).Get(param_idx))
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 
235  QueueValuesSend();
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;
257  SetRequesterUpdating(true);
258  }
259 
261  PPERequestParamDataBase GetRequestData(int mat_id, int param_idx, int type)
262  {
264  if ( m_RequestDataStructure.Get(mat_id) )
265  {
266  if (m_RequestDataStructure.Get(mat_id).Get(param_idx))
267  {
268  data = m_RequestDataStructure.Get(mat_id).Get(param_idx);
269  }
270  else
271  {
272  data = PrepareData(mat_id,param_idx,type);
273  m_RequestDataStructure.Get(mat_id).Set(param_idx,data);
274  }
275  }
276  else
277  {
278  data = PrepareData(mat_id,param_idx,type);
280  temp_map.Set(param_idx,data);
281  m_RequestDataStructure.Set(mat_id, temp_map);
282  }
283 
284  if (!data)
285  {
286  Error("GetRequestData | no data found in the structure");
287  }
288 
289  data.m_Requester = this;
290 
291  return data;
292  }
293 
294  protected PPERequestParamDataBase PrepareData(int mat_id, int param_idx, int type)
295  {
297  switch (type)
298  {
299  case PPEConstants.VAR_TYPE_BOOL:
300  data = new PPERequestParamDataBool(m_IDX, mat_id, param_idx);
301  break;
302 
303  case PPEConstants.VAR_TYPE_INT:
304  data = new PPERequestParamDataInt(m_IDX, mat_id, param_idx);
305  break;
306 
307  case PPEConstants.VAR_TYPE_FLOAT:
308  data = new PPERequestParamDataFloat(m_IDX, mat_id, param_idx);
309  break;
310 
311  case PPEConstants.VAR_TYPE_COLOR:
312  data = new PPERequestParamDataColor(m_IDX, mat_id, param_idx);
313  break;
314  }
315  return data;
316  }
317 
318  // unused?
319  map<int,ref map<int,ref PPERequestParamDataBase>> GetActiveRequestStructure()
320  {
321  return m_RequestDataStructure;
322  }
323 
324  protected void ClearRequesterData()
325  {
326  m_RequestDataStructure.Clear();
327  }
328 
329  protected void SendCurrentValueData(PPERequestParamDataBase data)
330  {
331  PPEManagerStatic.GetPPEManager().SendMaterialValueData(data);
332  }
333 
334  //EVENTS//
335  //vvvvvv//
336  void OnUpdate(float delta)
337  {
338  //DbgPrnt("PPEDebug | PPERequesterBase | OnUpdate");
339 
340  if ( !m_ValuesSent )
341  {
342  for (int i = 0; i < m_RequestDataStructure.Count(); i++)
343  {
344  for (int j = 0; j < m_RequestDataStructure.GetElement(i).Count(); j++)
345  {
346  SendCurrentValueData(m_RequestDataStructure.GetElement(i).GetElement(j)); //map<int,ref map<int,PPERequestParamDataBase>> //<material<param,data>>
347  }
348  }
349  m_ValuesSent = true;
350  }
351  SetRequesterUpdating(false);
352  }
353 
354  protected void OnStart(Param par = null)
355  {
356  SetRequesterUpdating(true);
357  }
358 
360  protected void OnStop(Param par = null)
361  {
362  //DbgPrnt("PPEDebug | " + this + " | OnStop");
363  SetRequesterUpdating(true);
364  SetDefaultValuesAll();
365  }
366 
368  protected float RelativizeValue(float value, int var_type, int mat_id, int param_id, bool relative)
369  {
370  float ret = value;
371  if (!relative) //if not already relative...
372  {
373  switch (var_type)
374  {
375  case PPEConstants.VAR_TYPE_FLOAT:
376  PPETemplateDefFloat p_float = PPETemplateDefFloat.Cast(PPEManagerStatic.GetPPEManager().GetPostProcessDefaultValues(mat_id,param_id));
377  ret = Math.InverseLerp(p_float.param3, p_float.param4, ret);
378  ret = Math.Clamp(ret,0.0,1.0);
379  break;
380  }
381  }
382  //Print("RelativizeValue: " + ret);
383 
384  return ret;
385  }
386 
388  protected void SetDefaultValuesAll()
389  {
390  //<material<param_id,data>>
391  PPERequestParamDataBase req_data;
392 
393  for (int i = 0; i < m_RequestDataStructure.Count(); i++)
394  {
395  for (int j = 0; j < m_RequestDataStructure.GetElement(i).Count(); j++)
396  {
397  req_data = m_RequestDataStructure.GetElement(i).GetElement(j);
398 
399  if (!req_data.IsDataActive())
400  continue;
401 
402  switch (req_data.GetVarType())
403  {
404  case PPEConstants.VAR_TYPE_BOOL:
405  SetTargetValueBoolDefault(req_data.GetMaterialID(),req_data.GetParameterID());
406  break;
407 
408  case PPEConstants.VAR_TYPE_INT:
409  SetTargetValueIntDefault(req_data.GetMaterialID(),req_data.GetParameterID());
410  break;
411 
412  case PPEConstants.VAR_TYPE_FLOAT:
413  SetTargetValueFloatDefault(req_data.GetMaterialID(),req_data.GetParameterID());
414  break;
415 
416  case PPEConstants.VAR_TYPE_COLOR:
417  SetTargetValueColorDefault(req_data.GetMaterialID(),req_data.GetParameterID());
418  break;
419  }
420  }
421  }
422  }
423 
424  void DbgPrnt(string text)
425  {
426  //Debug.Log(""+text);
427  }
428 }
429 
431 // Base requester platforms //
433 
435 {
436  override int GetCategoryMask()
437  {
438  return PPERequesterCategory.GAMEPLAY_EFFECTS;
439  }
440 }
441 
443 {
444  override int GetCategoryMask()
445  {
446  return PPERequesterCategory.MENU_EFFECTS;
447  }
448 }
GetCategoryMask
class PPERequesterBase GetCategoryMask()
mask for mass-handling methods like 'StopAllEffects'
Definition: pperequestplatformsbase.c:436
m_ValuesSent
protected bool m_ValuesSent
Definition: pperequestplatformsbase.c:3
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
PPERequestParamDataBool
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)
Definition: pperequestdata.c:111
m_Valid
protected bool m_Valid
Definition: pperequestplatformsbase.c:6
PPERequestParamDataFloat
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)
Definition: pperequestdata.c:142
PPERequester_MenuBase
Definition: ppercontrollerdisconnectblur.c:1
m_RequestDataStructure
protected ref map< int, ref map< int, ref PPERequestParamDataBase > > m_RequestDataStructure
Definition: pperequestplatformsbase.c:8
PPEManagerStatic
Static component of PPE manager, used to hold the instance.
Definition: ppemanager.c:2
m_IDX
protected int m_IDX
Definition: pperequestplatformsbase.c:4
map
map
Definition: controlsxboxnew.c:3
PPERequester_GameplayBase
base, not to be used directly, would lead to layering collisions!
Definition: pperbloodloss.c:1
PPERequesterBase
Definition: pperequestplatformsbase.c:2
PPERequestParamDataBase
Data for one material parameter, requester side.
Definition: pperequestdata.c:2
array< float >
PPERequesterCategory
PPERequesterCategory
Definition: ppeconstants.c:27
m_IsRunning
protected bool m_IsRunning
Definition: pperequestplatformsbase.c:2
Debug
Definition: debug.c:13
PPOperators
PPOperators
PP operators, specify operation between subsequent layers.
Definition: ppeconstants.c:51
Math
Definition: enmath.c:6
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
PPETemplateDefFloat
Param4< string, float, float, float > PPETemplateDefFloat
Definition: ppeconstants.c:86