Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ppematclassparameterfloat.c
Go to the documentation of this file.
2 {
3  protected ref map<int,ref array<float,int>> m_LayerInfo; //<priority,<value,operator>>
4 
6  protected float m_ValueDefault;
7  protected float m_ValueMin;
8  protected float m_ValueMax;
9 
10  void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
11  {
13  }
14 
15  override void InitDefaults()
16  {
17  Class.CastTo(m_Float,m_Defaults);
18  //m_Float = PPETemplateDefFloat.Cast(m_Defaults);
19  m_ValueDefault = m_Float.param2;
20  m_ValueMin = m_Float.param3;
21  m_ValueMax = m_Float.param4;
22  }
23 
24  override void InitCuttent()
25  {
26  m_CurrentValues = new Param1<float>(m_ValueDefault);
27  }
28 
29  override int GetParameterVarType()
30  {
31  return PPEConstants.VAR_TYPE_FLOAT;
32  }
33 
34  override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
35  {
36  super.Update(timeslice,p_total,setting_defaults,order);
37 
38  int active_request_count = 0;
39 
40  PPERequestParamDataFloat req_data;
41 
42  bool setting_value_zero = false;
43 
44  float float_value_temp = 0.0;
45  float float_value_default = 0.0;
46  float float_value_total = 0.0;
47 
48  if (p_total == null)
49  {
50  p_total = new Param1<float>(0.0);
51  }
52 
53  if (m_RequestMap.Count() > 0)
54  {
55  m_LayerInfo.Clear();
56  }
57  else
58  {
59  //DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
60  SetParameterValueDefault(p_total);
61  m_Parent.ParamUpdateRemove(m_ParameterIndex);
62  return;
63  }
64 
65  for ( int i = 0; i < m_RequestMap.Count(); i++ )
66  {
67  req_data = PPERequestParamDataFloat.Cast(m_RequestMap.GetElement(i));
68 
69  if (req_data == null)
70  {
71  Error("Debug | PPEMatClassParameterFloat | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
72  continue;
73  }
74 
75  setting_value_zero = req_data.IsSettingDefaultValues();
76 
77  if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
78  {
79  //DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
80  continue;
81  }
82 
83  if (setting_value_zero)
84  {
85  req_data.m_FloatTarget = 0;//min;
86  //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | !data.m_DefaultTargetSet | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | req_data.m_FloatTarget: " + req_data.m_FloatTarget);
87  }
88  else
89  {
90  active_request_count++;
91  }
92 
93  //evaluation
94  //--------------------------------
95  req_data.m_FloatLast = req_data.m_FloatCurrent;
96 
97  if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
98  {
99  float_value_temp = req_data.m_FloatCurrent;
100  PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
101  //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | !req_data.m_UpdatingData | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | not updating, addaing current value into mix: " + float_value_temp);
102  continue;
103  }
104 
105  float_value_temp = req_data.m_FloatTarget;
106 
107  //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
108  req_data.SetUpdatingDataValues(false);
109  if (setting_value_zero)
110  {
111  req_data.SetDataActive(false);
112  //RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
113  }
114  else
115  {
116  float_value_temp = req_data.m_FloatTarget;
117  PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
118  }
119 
120  req_data.m_FloatCurrent = float_value_temp;
121  }
122 
123  //---------------------------
124  //MASK handling and calculation
125  float value;
126  int operator;
127  bool override_active = false;
128 
129  if ( m_ValueMax == 0.0 )
130  float_value_total = m_ValueDefault; //?
131  else
132  float_value_total = m_ValueDefault / m_ValueMax;
133 
134  //float_value_total = Math.InverseLerp(m_ValueMin,m_ValueMax,m_ValueDefault);
135  float_value_default = float_value_total;
136 
137  for ( i = 0; i < m_LayerInfo.Count(); i++ )
138  {
139  if ( override_active )
140  break;
141 
142  value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
143  operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
144 
145  switch (operator)
146  {
147  case PPOperators.LOWEST:
148  float_value_total = Math.Min(float_value_total,value);
149  break;
150 
151  case PPOperators.HIGHEST:
152  float_value_total = Math.Max(float_value_total,value);
153  break;
154 
155  case PPOperators.ADD:
156  //float_value_total = float_value_total + value - float_value_default;
157  float_value_total = float_value_total + value;
158  break;
159 
160  case PPOperators.ADD_RELATIVE:
161  float_value_total = (1 - float_value_total) * value + float_value_total;
162  break;
163 
164  case PPOperators.SUBSTRACT:
165  //float_value_total = float_value_total - value + float_value_default;
166  float_value_total = float_value_total - value;
167  break;
168 
169  case PPOperators.SUBSTRACT_RELATIVE:
170  float_value_total = float_value_total - value * float_value_total;
171  break;
172 
173  case PPOperators.SUBSTRACT_REVERSE:
174  //float_value_total = value - float_value_default - float_value_total;
175  float_value_total = value - float_value_total;
176  break;
177 
178  case PPOperators.SUBSTRACT_REVERSE_RELATIVE:
179  float_value_total = value * float_value_total - float_value_total;
180  break;
181 
182  case PPOperators.MULTIPLICATIVE:
183  //float_value_total = Math.Lerp(float_value_default, float_value_total, value);
184  float_value_total = float_value_total * value;
185  break;
186 
187  case PPOperators.OVERRIDE:
188  float_value_total = value;
189  break;
190 
191  case PPOperators.SET:
192  float_value_total = value;
193  break;
194  }
195 
196  //DbgPrnt("m_LayerInfo | float_value_total pre-clamp: " + float_value_total + " | i: " + i);
197  float_value_total = Math.Clamp(float_value_total,0,1);
198 
199  if ( operator == PPOperators.OVERRIDE )
200  {
201  //DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
202  override_active = true;
203  }
204 
205  //RemovePriorityInfo(m_CommandLayersArray.Get(i));
206  }
207 
208  m_CommandLayersArray.Clear();
209 
210  //TODO - consider moving this up, if possible
211  if (active_request_count == 0)
212  {
213  SetParameterValueDefault(p_total);
214  }
215  else
216  {
217  float res = Math.Lerp(m_ValueMin,m_ValueMax,float_value_total);
218  Param1<float>.Cast(p_total).param1 = res; //converts back to absolute values
219  }
220 
221  //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
222  m_Parent.ParamUpdateRemove(m_ParameterIndex);
223 
224  m_CurrentValues = p_total;
225  }
226 
227  void PrepareLayerInfo(int layer, float value, int operator)
228  {
229  m_LayerInfo.Set(layer,{value,operator});
230  AddPriorityInfo(layer);
231  }
232 
234  override void SetParameterValueDefault(inout Param p_total)
235  {
236  p_total = new Param1<float>(PPETemplateDefFloat.Cast(m_Defaults).param2);
237  m_CurrentValues = p_total;
238  //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | exit 3 - zero value");
239  }
240 }
241 
243 {
244  void PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
245  {
246  m_Dependencies = new map<int,ref array<int>>;
247  m_Dependencies.Set(PostProcessEffectType.Glow,{PPEGlow.PARAM_COLORIZATIONCOLOR, PPEGlow.PARAM_OVERLAYCOLOR});
248  }
249 }
PostProcessEffectType
PostProcessEffectType
Post-process effect type.
Definition: enworld.c:71
m_ValueMin
protected float m_ValueMin
Definition: ppematclassparameterfloat.c:6
PPEClassBase
Created once, on manager init. Script-side representation of C++ material class, separate handling.
Definition: ppematclassesbase.c:2
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
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
InitCuttent
override void InitCuttent()
Definition: ppematclassparameterfloat.c:23
PPEMatClassParameterCommandData
Definition: ppematclassparameterbool.c:1
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
PPEMatClassParameterFloatSaturation
class PPEMatClassParameterFloat extends PPEMatClassParameterCommandData PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
Definition: ppematclassparameterfloat.c:244
GetParameterVarType
override int GetParameterVarType()
Definition: ppematclassparameterfloat.c:28
map
map
Definition: controlsxboxnew.c:3
InitDefaults
override void InitDefaults()
Definition: ppematclassparameterfloat.c:14
PrepareLayerInfo
void PrepareLayerInfo(int layer, float value, int operator)
Definition: ppematclassparameterfloat.c:226
m_ValueMax
protected float m_ValueMax
Definition: ppematclassparameterfloat.c:7
PPEMatClassParameterFloat
void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
Definition: ppematclassparameterfloat.c:9
m_LayerInfo
protected ref map< int, ref array< float, int > > m_LayerInfo
Definition: ppematclassparameterfloat.c:2
Update
override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
Definition: ppematclassparameterfloat.c:33
m_Float
protected PPETemplateDefFloat m_Float
Definition: ppematclassparameterfloat.c:4
PPOperators
PPOperators
PP operators, specify operation between subsequent layers.
Definition: ppeconstants.c:51
SetParameterValueDefault
override void SetParameterValueDefault(inout Param p_total)
No active requests for the mat. parameter value change, sets the value to DEFAULT (zero?...
Definition: ppematclassparameterfloat.c:233
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_ValueDefault
protected float m_ValueDefault
Definition: ppematclassparameterfloat.c:5
PPETemplateDefFloat
Param4< string, float, float, float > PPETemplateDefFloat
Definition: ppeconstants.c:86