DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ InitDefaults()

override void PPEMatClassParameterFloatSaturation::InitDefaults ( )
protected

См. определение в файле PPEMatClassParameterFloat.c строка 257

258{
259 protected ref map<int,ref array<float,int>> m_LayerInfo; //<priority,<value,operator>>
260
262 protected float m_ValueDefault;
263 protected float m_ValueMin;
264 protected float m_ValueMax;
265
266 void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
267 {
269 }
270
271 override void InitDefaults()
272 {
273 Class.CastTo(m_Float,m_Defaults);
274 //m_Float = PPETemplateDefFloat.Cast(m_Defaults);
275 m_ValueDefault = m_Float.param2;
276 m_ValueMin = m_Float.param3;
277 m_ValueMax = m_Float.param4;
278 }
279
280 override void InitCuttent()
281 {
282 m_CurrentValues = new Param1<float>(m_ValueDefault);
283 }
284
285 override int GetParameterVarType()
286 {
287 return PPEConstants.VAR_TYPE_FLOAT;
288 }
289
290 override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
291 {
292 super.Update(timeslice,p_total,setting_defaults,order);
293
294 int active_request_count = 0;
295
297
298 bool setting_value_zero = false;
299
300 float float_value_temp = 0.0;
301 float float_value_default = 0.0;
302 float float_value_total = 0.0;
303
304 if (p_total == null)
305 {
306 p_total = new Param1<float>(0.0);
307 }
308
309 if (m_RequestMap.Count() > 0)
310 {
311 m_LayerInfo.Clear();
312 }
313 else
314 {
315 //DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
317 m_Parent.ParamUpdateRemove(m_ParameterIndex);
318 return;
319 }
320
321 for ( int i = 0; i < m_RequestMap.Count(); i++ )
322 {
323 req_data = PPERequestParamDataFloat.Cast(m_RequestMap.GetElement(i));
324
325 if (req_data == null)
326 {
327 Error("Debug | PPEMatClassParameterFloat | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
328 continue;
329 }
330
331 setting_value_zero = req_data.IsSettingDefaultValues();
332
333 if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
334 {
335 //DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
336 continue;
337 }
338
339 if (setting_value_zero)
340 {
341 req_data.m_FloatTarget = 0;//min;
342 //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);
343 }
344 else
345 {
346 active_request_count++;
347 }
348
349 //evaluation
350 //--------------------------------
351 req_data.m_FloatLast = req_data.m_FloatCurrent;
352
353 if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
354 {
355 float_value_temp = req_data.m_FloatCurrent;
356 PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
357 //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);
358 continue;
359 }
360
361 float_value_temp = req_data.m_FloatTarget;
362
363 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
364 req_data.SetUpdatingDataValues(false);
365 if (setting_value_zero)
366 {
367 req_data.SetDataActive(false);
368 //RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
369 }
370 else
371 {
372 float_value_temp = req_data.m_FloatTarget;
373 PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
374 }
375
376 req_data.m_FloatCurrent = float_value_temp;
377 }
378
379 //---------------------------
380 //MASK handling and calculation
381 float value;
382 int operator;
383 bool override_active = false;
384
385 if ( m_ValueMax == 0.0 )
386 float_value_total = m_ValueDefault; //?
387 else
388 float_value_total = m_ValueDefault / m_ValueMax;
389
390 //float_value_total = Math.InverseLerp(m_ValueMin,m_ValueMax,m_ValueDefault);
391 float_value_default = float_value_total;
392
393 for ( i = 0; i < m_LayerInfo.Count(); i++ )
394 {
395 if ( override_active )
396 break;
397
398 value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
399 operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
400
401 switch (operator)
402 {
403 case PPOperators.LOWEST:
404 float_value_total = Math.Min(float_value_total,value);
405 break;
406
407 case PPOperators.HIGHEST:
408 float_value_total = Math.Max(float_value_total,value);
409 break;
410
411 case PPOperators.ADD:
412 //float_value_total = float_value_total + value - float_value_default;
413 float_value_total = float_value_total + value;
414 break;
415
416 case PPOperators.ADD_RELATIVE:
417 float_value_total = (1 - float_value_total) * value + float_value_total;
418 break;
419
420 case PPOperators.SUBSTRACT:
421 //float_value_total = float_value_total - value + float_value_default;
422 float_value_total = float_value_total - value;
423 break;
424
425 case PPOperators.SUBSTRACT_RELATIVE:
426 float_value_total = float_value_total - value * float_value_total;
427 break;
428
429 case PPOperators.SUBSTRACT_REVERSE:
430 //float_value_total = value - float_value_default - float_value_total;
431 float_value_total = value - float_value_total;
432 break;
433
434 case PPOperators.SUBSTRACT_REVERSE_RELATIVE:
435 float_value_total = value * float_value_total - float_value_total;
436 break;
437
438 case PPOperators.MULTIPLICATIVE:
439 //float_value_total = Math.Lerp(float_value_default, float_value_total, value);
440 float_value_total = float_value_total * value;
441 break;
442
443 case PPOperators.OVERRIDE:
444 float_value_total = value;
445 break;
446
447 case PPOperators.SET:
448 float_value_total = value;
449 break;
450 }
451
452 //DbgPrnt("m_LayerInfo | float_value_total pre-clamp: " + float_value_total + " | i: " + i);
453 float_value_total = Math.Clamp(float_value_total,0,1);
454
455 if ( operator == PPOperators.OVERRIDE )
456 {
457 //DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
458 override_active = true;
459 }
460
461 //RemovePriorityInfo(m_CommandLayersArray.Get(i));
462 }
463
464 m_CommandLayersArray.Clear();
465
466 //TODO - consider moving this up, if possible
467 if (active_request_count == 0)
468 {
470 }
471 else
472 {
473 float res = Math.Lerp(m_ValueMin,m_ValueMax,float_value_total);
474 Param1<float>.Cast(p_total).param1 = res; //converts back to absolute values
475 }
476
477 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
478 m_Parent.ParamUpdateRemove(m_ParameterIndex);
479
480 m_CurrentValues = p_total;
481 }
482
483 void PrepareLayerInfo(int layer, float value, int operator)
484 {
485 m_LayerInfo.Set(layer,{value,operator});
486 AddPriorityInfo(layer);
487 }
488
490 override void SetParameterValueDefault(inout Param p_total)
491 {
492 p_total = new Param1<float>(PPETemplateDefFloat.Cast(m_Defaults).param2);
493 m_CurrentValues = p_total;
494 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | exit 3 - zero value");
495 }
496}
497
499{
500 void PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
501 {
502 m_Dependencies = new map<int,ref array<int>>;
503 m_Dependencies.Set(PostProcessEffectType.Glow,{PPEGlow.PARAM_COLORIZATIONCOLOR, PPEGlow.PARAM_OVERLAYCOLOR});
504 }
505}
map
Определения ControlsXboxNew.c:4
PPOperators
PP operators, specify operation between subsequent layers.
Определения PPEConstants.c:53
Param4< string, float, float, float > PPETemplateDefFloat
Определения PPEConstants.c:87
ref map< int, ref ColorValuesData > m_LayerInfo
Определения PPEMatClassParameterColor.c:44
override void SetParameterValueDefault(inout Param p_total)
No active requests for the mat. parameter value change, sets the value to DEFAULT (zero?...
Определения PPEMatClassParameterFloat.c:476
class PPEMatClassParameterFloat extends PPEMatClassParameterCommandData PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
Определения PPEMatClassParameterFloat.c:244
override void InitCuttent()
Определения PPEMatClassParameterFloat.c:266
override int GetParameterVarType()
Определения PPEMatClassParameterFloat.c:271
void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
Определения PPEMatClassParameterFloat.c:252
float m_ValueMax
Определения PPEMatClassParameterFloat.c:250
float m_ValueMin
Определения PPEMatClassParameterFloat.c:249
void PrepareLayerInfo(int layer, float value, int operator)
Определения PPEMatClassParameterFloat.c:469
float m_ValueDefault
Определения PPEMatClassParameterFloat.c:248
PPETemplateDefFloat m_Float
Определения PPEMatClassParameterFloat.c:247
override void InitDefaults()
Определения PPEMatClassParameterFloat.c:257
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)
Определения PPERequestData.c:142
Widget m_Parent
Определения SizeToChild.c:92
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения EnMath.c:7
Created once, on manager init. Script-side representation of C++ material class, separate handling.
Определения PPEMatClassesBase.c:3
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
PostProcessEffectType
Post-process effect type.
Определения EnWorld.c:72
void Error(string err)
Messagebox with error message.
Определения 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'.
proto native volatile void Update()
Определения PlayerSoundManager.c:125