DayZ 1.24
Loading...
Searching...
No Matches
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
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 {
37
39
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 p_total = new Param1<float>(0.0);
50
51 if (m_RequestMap.Count() > 0)
52 m_LayerInfo.Clear();
53 else
54 {
55 //DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
57 m_Parent.ParamUpdateRemove(m_ParameterIndex);
58 return;
59 }
60
61 for (int i = 0; i < m_RequestMap.Count(); i++)
62 {
63 req_data = PPERequestParamDataFloat.Cast(m_RequestMap.GetElement(i));
64
65 if (req_data == null)
66 {
67 Error("Debug | PPEMatClassParameterFloat | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
68 continue;
69 }
70
71 setting_value_zero = req_data.IsSettingDefaultValues();
72
73 if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
74 {
75 //DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
76 continue;
77 }
78
80 {
81 req_data.m_FloatTarget = 0;//min;
82 //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);
83 }
84 else
86
87 //evaluation
88 //--------------------------------
89 req_data.m_FloatLast = req_data.m_FloatCurrent;
90
91 if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
92 {
93 float_value_temp = req_data.m_FloatCurrent;
94 PrepareLayerInfo(req_data.GetPriorityLayer(), float_value_temp, req_data.GetInteractionMask());
95 //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);
96 continue;
97 }
98
99 float_value_temp = req_data.m_FloatTarget;
100
101 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
102 req_data.SetUpdatingDataValues(false);
104 {
105 req_data.SetDataActive(false);
106 //RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
107 }
108 else
109 {
110 float_value_temp = req_data.m_FloatTarget;
111 PrepareLayerInfo(req_data.GetPriorityLayer(), float_value_temp, req_data.GetInteractionMask());
112 }
113
114 req_data.m_FloatCurrent = float_value_temp;
115 }
116
117 //---------------------------
118 //MASK handling and calculation
119 float value;
120 int operator;
121 bool override_active = false;
122
123 if (m_ValueMax == 0.0)
125 else
127
128 //float_value_total = Math.InverseLerp(m_ValueMin,m_ValueMax,m_ValueDefault);
130
131 for (i = 0; i < m_LayerInfo.Count(); i++)
132 {
133 if (override_active)
134 break;
135
136 value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
137 operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
138
139 switch (operator)
140 {
141 case PPOperators.LOWEST:
143 break;
144
145 case PPOperators.HIGHEST:
147 break;
148
149 case PPOperators.ADD:
150 //float_value_total = float_value_total + value - float_value_default;
152 break;
153
154 case PPOperators.ADD_RELATIVE:
156 break;
157
158 case PPOperators.SUBSTRACT:
159 //float_value_total = float_value_total - value + float_value_default;
161 break;
162
163 case PPOperators.SUBSTRACT_RELATIVE:
165 break;
166
167 case PPOperators.SUBSTRACT_REVERSE:
168 //float_value_total = value - float_value_default - float_value_total;
170 break;
171
172 case PPOperators.SUBSTRACT_REVERSE_RELATIVE:
174 break;
175
176 case PPOperators.MULTIPLICATIVE:
177 //float_value_total = Math.Lerp(float_value_default, float_value_total, value);
179 break;
180
181 case PPOperators.OVERRIDE:
183 break;
184
185 case PPOperators.SET:
187 break;
188 }
189
190 //DbgPrnt("m_LayerInfo | float_value_total pre-clamp: " + float_value_total + " | i: " + i);
192
193 if (operator == PPOperators.OVERRIDE)
194 {
195 //DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
196 override_active = true;
197 }
198
199 //RemovePriorityInfo(m_CommandLayersArray.Get(i));
200 }
201
202 m_CommandLayersArray.Clear();
203
204 //TODO - consider moving this up, if possible
205 if (active_request_count == 0)
207 else
208 {
210 Param1<float>.Cast(p_total).param1 = res; //converts back to absolute values
211 }
212
213 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
214 m_Parent.ParamUpdateRemove(m_ParameterIndex);
215
216 m_CurrentValues = p_total;
217 }
218
219 void PrepareLayerInfo(int layer, float value, int operator)
220 {
221 m_LayerInfo.Set(layer, {value, operator});
223 }
224
227 {
228 p_total = new Param1<float>(PPETemplateDefFloat.Cast(m_Defaults).param2);
229 m_CurrentValues = p_total;
230 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | exit 3 - zero value");
231 }
232}
233
235{
238 m_Dependencies = new map<int, ref array<int>>;
239 m_Dependencies.Set(PostProcessEffectType.Glow, {PPEGlow.PARAM_COLORIZATIONCOLOR, PPEGlow.PARAM_OVERLAYCOLOR});
PPOperators
PP operators, specify operation between subsequent layers.
ref map< int, ref ColorValuesData > m_LayerInfo
class PPEMatClassParameterFloat extends PPEMatClassParameterCommandData PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
float m_ValueDefault
PPETemplateDefFloat m_Float
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)
Widget m_Parent
Definition SizeToChild.c:86
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
Created once, on manager init. Script-side representation of C++ material class, separate handling.
void PrepareLayerInfo(int layer, float value, int operator)
void AddPriorityInfo(int priority)
Adds 'layers' to be iterated throug.
override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
void PrepareLayerInfo(int layer, bool value, int operator)
ref map< int, ref array< float, int > > m_LayerInfo
override void SetParameterValueDefault(inout Param p_total)
No active requests for the mat. parameter value change, sets the value to DEFAULT.
void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
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
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Min(float x, float y)
Returns smaller of two given values.
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'.