Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ppematclassparameterbool.c
Go to the documentation of this file.
1 class PPEMatClassParameterBool extends PPEMatClassParameterCommandData
2 {
3  protected ref map<int,ref array<bool,int>> m_LayerInfo; //<priority,<value,operator>>
4 
5  protected PPETemplateDefBool m_Bool;
6  protected bool m_ValueDefault;
7 
8  void PPEMatClassParameterBool(int mat_idx, int parameter_idx, PPEClassBase parent)
9  {
11  }
12 
13  override void InitDefaults()
14  {
15  Class.CastTo(m_Bool,m_Defaults);
16  m_ValueDefault = m_Bool.param2;
17  }
18 
19  override void InitCuttent()
20  {
21  m_CurrentValues = new Param1<bool>(m_ValueDefault);
22  }
23 
24  override int GetParameterVarType()
25  {
26  return PPEConstants.VAR_TYPE_BOOL;
27  }
28 
29  override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
30  {
31  super.Update(timeslice,p_total,setting_defaults,order);
32 
33  int active_request_count = 0;
34 
35  PPERequestParamDataBool req_data;
36 
37  bool setting_value_zero = false;
38 
39  bool bool_value_temp = false;
40  bool bool_value_total = m_ValueDefault;
41 
42  if (p_total == null)
43  {
44  p_total = new Param1<bool>(false);
45  }
46 
47  if (m_RequestMap.Count() > 0)
48  {
49  m_LayerInfo.Clear();
50  }
51  else
52  {
53  //DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
54  SetParameterValueDefault(p_total);
55  m_Parent.ParamUpdateRemove(m_ParameterIndex);
56  return;
57  }
58 
59  for ( int i = 0; i < m_RequestMap.Count(); i++ )
60  {
61  req_data = PPERequestParamDataBool.Cast(m_RequestMap.GetElement(i));
62 
63  if (req_data == null)
64  {
65  Error("PPEMatClassParameterBool | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
66  continue;
67  }
68 
69  setting_value_zero = req_data.IsSettingDefaultValues();
70 
71  if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
72  {
73  //DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
74  continue;
75  }
76 
77  if (setting_value_zero)
78  {
79  req_data.m_BoolTarget = false;
80  //DbgPrnt("PPEDebug | PPEMatClassParameterBool - UpdateParameterValues | !data.m_DefaultTargetSet | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | req_data.m_BoolTarget: " + req_data.m_BoolTarget);
81  }
82  else
83  {
84  active_request_count++;
85  }
86 
87  //evaluation
88  //--------------------------------
89  req_data.m_BoolLast = req_data.m_BoolCurrent;
90 
91  if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
92  {
93  bool_value_temp = req_data.m_BoolCurrent;
94  PrepareLayerInfo(req_data.GetPriorityLayer(),bool_value_temp,req_data.GetInteractionMask());
95  //DbgPrnt("PPEDebug | PPEMatClassParameterBool - UpdateParameterValues | !req_data.m_UpdatingData | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | not updating, addaing current value into mix: " + bool_value_temp);
96  continue;
97  }
98 
99  bool_value_temp = req_data.m_BoolTarget;
100 
101  //DbgPrnt("PPEDebug | PPEMatClassParameterBool - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
102  req_data.SetUpdatingDataValues(false);
103  if (setting_value_zero)
104  {
105  req_data.SetDataActive(false);
106  //RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
107  }
108  else
109  {
110  bool_value_temp = req_data.m_BoolTarget;
111  PrepareLayerInfo(req_data.GetPriorityLayer(),bool_value_temp,req_data.GetInteractionMask());
112  }
113 
114  req_data.m_BoolCurrent = bool_value_temp;
115  }
116 
117  if (active_request_count == 0)
118  {
119  SetParameterValueDefault(p_total);
120  }
121  else
122  {
123  //---------------------------
124  //MASK handling and calculation
125  bool value;
126  int operator;
127  bool override_active = false;
128 
129  for ( i = 0; i < m_LayerInfo.Count(); i++ )
130  {
131  if ( override_active )
132  break;
133 
134  value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
135  operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
136 
137  switch (operator)
138  {
139  case PPOperators.LOWEST:
140  bool_value_total = Math.Min(bool_value_total,value);
141  break;
142 
143  case PPOperators.HIGHEST:
144  bool_value_total = Math.Max(bool_value_total,value);
145  break;
146 
147  case PPOperators.OVERRIDE:
148  bool_value_total = value;
149  break;
150 
151  case PPOperators.SET:
152  bool_value_total = value;
153  break;
154 
155  default:
156  Error("PPEMatClassParameterBool | Invalid operator " + operator + " in mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
157  break;
158  }
159 
160  if ( operator == PPOperators.OVERRIDE )
161  {
162  //DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
163  override_active = true;
164  }
165  }
166 
167  m_CommandLayersArray.Clear();
168 
169  Param1<bool>.Cast(p_total).param1 = bool_value_total;
170  }
171 
172  //DbgPrnt("PPEDebug | PPEMatClassParameterBool - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
173  m_Parent.ParamUpdateRemove(m_ParameterIndex);
174 
175  m_CurrentValues = p_total;
176  }
177 
178  void PrepareLayerInfo(int layer, bool value, int operator)
179  {
180  m_LayerInfo.Set(layer,{value,operator});
181  AddPriorityInfo(layer);
182  }
183 
185  override void SetParameterValueDefault(inout Param p_total)
186  {
187  p_total = new Param1<bool>(PPETemplateDefBool.Cast(m_Defaults).param2);
188  m_CurrentValues = p_total;
189  //DbgPrnt("PPEDebug | PPEMatClassParameterBool - UpdateParameterValues | exit 3 - zero value");
190  }
191 }
Param2
Definition: ppeconstants.c:66
m_LayerInfo
protected ref map< int, ref ColorValuesData > m_LayerInfo
Definition: ppematclassparametercolor.c:44
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
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
PPEMatClassParameterCommandData
Definition: ppematclassparameterbool.c:1
SetParameterValueDefault
override void SetParameterValueDefault(inout Param p_total)
Definition: ppematclassparametercolor.c:300
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
map
map
Definition: controlsxboxnew.c:3
GetParameterVarType
override int GetParameterVarType()
Definition: ppematclassparametercolor.c:64
InitCuttent
override void InitCuttent()
Definition: ppematclassparametercolor.c:59
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
PrepareLayerInfo
void PrepareLayerInfo(int layer, ref array< float > values, int operator)
Fills relative values into arrays/member variables.
Definition: ppematclassparametercolor.c:282
PPOperators
PPOperators
PP operators, specify operation between subsequent layers.
Definition: ppeconstants.c:51
InitDefaults
override void InitDefaults()
Definition: ppematclassparametercolor.c:53
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