DayZ 1.24
Loading...
Searching...
No Matches
PPEMatClassParameterInt.c
Go to the documentation of this file.
1class PPEMatClassParameterInt extends PPEMatClassParameterCommandData
2{
3 protected ref map<int, ref array<int, int>> m_LayerInfo; //<priority,<value,operator>>
4
6 protected int m_ValueDefault;
7
12
13 override void InitDefaults()
14 {
15 Class.CastTo(m_Int, m_Defaults);
16 m_ValueDefault = m_Int.param2;
17 }
18
19 override void InitCuttent()
20 {
21 m_CurrentValues = new Param1<int>(m_ValueDefault);
22 }
23
24 override int GetParameterVarType()
25 {
26 return PPEConstants.VAR_TYPE_INT;
27 }
28
29 override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
30 {
32
34
35 PPERequestParamDataInt req_data;
36
37 bool setting_value_zero = false;
38
39 bool int_value_temp = false;
41
42 if (p_total == null)
43 p_total = new Param1<int>(0);
44
45 if (m_RequestMap.Count() > 0)
46 m_LayerInfo.Clear();
47 else
48 {
49 //DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
51 m_Parent.ParamUpdateRemove(m_ParameterIndex);
52 return;
53 }
54
55 for (int i = 0; i < m_RequestMap.Count(); i++)
56 {
57 req_data = PPERequestParamDataInt.Cast(m_RequestMap.GetElement(i));
58
59 if (req_data == null)
60 {
61 Error("Debug | PPEMatClassParameterInt | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
62 continue;
63 }
64
65 setting_value_zero = req_data.IsSettingDefaultValues();
66
67 if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
68 {
69 //DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
70 continue;
71 }
72
74 {
75 req_data.m_IntTarget = false;
76 //DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | !data.m_DefaultTargetSet | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | req_data.m_IntTarget: " + req_data.m_IntTarget);
77 }
78 else
80
81 //evaluation
82 //--------------------------------
83 req_data.m_IntLast = req_data.m_IntCurrent;
84
85 if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
86 {
87 int_value_temp = req_data.m_IntCurrent;
88 PrepareLayerInfo(req_data.GetPriorityLayer(), int_value_temp, req_data.GetInteractionMask());
89 //DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | !req_data.m_UpdatingData | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | not updating, addaing current value into mix: " + int_value_temp);
90 continue;
91 }
92
93 int_value_temp = req_data.m_IntTarget;
94
95 //DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
96 req_data.SetUpdatingDataValues(false);
98 {
99 req_data.SetDataActive(false);
100 //RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
101 }
102 else
103 {
104 int_value_temp = req_data.m_IntTarget;
105 PrepareLayerInfo(req_data.GetPriorityLayer(), int_value_temp, req_data.GetInteractionMask());
106 }
107
108 req_data.m_IntCurrent = int_value_temp;
109 }
110
111 if (active_request_count == 0)
113 else
114 {
115 //---------------------------
116 //MASK handling and calculation
117 int value;
118 int operator;
119 bool override_active = false;
120
121 for (i = 0; i < m_LayerInfo.Count(); i++)
122 {
123 if (override_active)
124 break;
125
126 value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
127 operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
128
129 switch (operator)
130 {
131 case PPOperators.LOWEST:
133 break;
134
135 case PPOperators.HIGHEST:
137 break;
138
139 case PPOperators.OVERRIDE:
141 break;
142
143 case PPOperators.SET:
145 break;
146
147 default:
148 Error("PPEMatClassParameterInt | Invalid operator " + operator + " in mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
149 break;
150 }
151
152 if (operator == PPOperators.OVERRIDE)
153 {
154 //DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
155 override_active = true;
156 }
157 }
158
159 m_CommandLayersArray.Clear();
160
161 Param1<int>.Cast(p_total).param1 = int_value_total;
162 }
163
164 //DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
165 m_Parent.ParamUpdateRemove(m_ParameterIndex);
166
167 m_CurrentValues = p_total;
168 }
169
170 void PrepareLayerInfo(int layer, int value, int operator)
171 {
172 m_LayerInfo.Set(layer, {value, operator});
174 }
175
178 {
179 p_total = new Param1<int>(PPETemplateDefInt.Cast(m_Defaults).param2);
180 m_CurrentValues = p_total;
181 //DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | exit 3 - zero value");
182 }
183}
PPOperators
PP operators, specify operation between subsequent layers.
ref map< int, ref ColorValuesData > m_LayerInfo
float m_ValueDefault
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 AddPriorityInfo(int priority)
Adds 'layers' to be iterated throug.
void PrepareLayerInfo(int layer, int value, int operator)
void PPEMatClassParameterInt(int mat_idx, int parameter_idx, PPEClassBase parent)
override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
void PrepareLayerInfo(int layer, bool value, int operator)
override void SetParameterValueDefault(inout Param p_total)
No active requests for the mat. parameter value change, sets the value to DEFAULT.
ref map< int, ref array< int, int > > m_LayerInfo
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 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 Min(float x, float y)
Returns smaller of two given values.