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

◆ Update()

override void PPEMatClassParameterFloatSaturation::Update ( float timeslice,
out Param p_total,
out bool setting_defaults,
int order )
protected

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

277{
278 protected ref map<int,ref array<float,int>> m_LayerInfo; //<priority,<value,operator>>
279
281 protected float m_ValueDefault;
282 protected float m_ValueMin;
283 protected float m_ValueMax;
284
285 void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
286 {
288 }
289
290 override void InitDefaults()
291 {
292 Class.CastTo(m_Float,m_Defaults);
293 //m_Float = PPETemplateDefFloat.Cast(m_Defaults);
294 m_ValueDefault = m_Float.param2;
295 m_ValueMin = m_Float.param3;
296 m_ValueMax = m_Float.param4;
297 }
298
299 override void InitCuttent()
300 {
301 m_CurrentValues = new Param1<float>(m_ValueDefault);
302 }
303
304 override int GetParameterVarType()
305 {
306 return PPEConstants.VAR_TYPE_FLOAT;
307 }
308
309 override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
310 {
311 super.Update(timeslice,p_total,setting_defaults,order);
312
313 int active_request_count = 0;
314
316
317 bool setting_value_zero = false;
318
319 float float_value_temp = 0.0;
320 float float_value_default = 0.0;
321 float float_value_total = 0.0;
322
323 if (p_total == null)
324 {
325 p_total = new Param1<float>(0.0);
326 }
327
328 if (m_RequestMap.Count() > 0)
329 {
330 m_LayerInfo.Clear();
331 }
332 else
333 {
334 //DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
336 m_Parent.ParamUpdateRemove(m_ParameterIndex);
337 return;
338 }
339
340 for ( int i = 0; i < m_RequestMap.Count(); i++ )
341 {
342 req_data = PPERequestParamDataFloat.Cast(m_RequestMap.GetElement(i));
343
344 if (req_data == null)
345 {
346 Error("Debug | PPEMatClassParameterFloat | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
347 continue;
348 }
349
350 setting_value_zero = req_data.IsSettingDefaultValues();
351
352 if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
353 {
354 //DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
355 continue;
356 }
357
358 if (setting_value_zero)
359 {
360 req_data.m_FloatTarget = 0;//min;
361 //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);
362 }
363 else
364 {
365 active_request_count++;
366 }
367
368 //evaluation
369 //--------------------------------
370 req_data.m_FloatLast = req_data.m_FloatCurrent;
371
372 if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
373 {
374 float_value_temp = req_data.m_FloatCurrent;
375 PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
376 //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);
377 continue;
378 }
379
380 float_value_temp = req_data.m_FloatTarget;
381
382 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
383 req_data.SetUpdatingDataValues(false);
384 if (setting_value_zero)
385 {
386 req_data.SetDataActive(false);
387 //RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
388 }
389 else
390 {
391 float_value_temp = req_data.m_FloatTarget;
392 PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
393 }
394
395 req_data.m_FloatCurrent = float_value_temp;
396 }
397
398 //---------------------------
399 //MASK handling and calculation
400 float value;
401 int operator;
402 bool override_active = false;
403
404 if ( m_ValueMax == 0.0 )
405 float_value_total = m_ValueDefault; //?
406 else
407 float_value_total = m_ValueDefault / m_ValueMax;
408
409 //float_value_total = Math.InverseLerp(m_ValueMin,m_ValueMax,m_ValueDefault);
410 float_value_default = float_value_total;
411
412 for ( i = 0; i < m_LayerInfo.Count(); i++ )
413 {
414 if ( override_active )
415 break;
416
417 value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
418 operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
419
420 switch (operator)
421 {
422 case PPOperators.LOWEST:
423 float_value_total = Math.Min(float_value_total,value);
424 break;
425
426 case PPOperators.HIGHEST:
427 float_value_total = Math.Max(float_value_total,value);
428 break;
429
430 case PPOperators.ADD:
431 //float_value_total = float_value_total + value - float_value_default;
432 float_value_total = float_value_total + value;
433 break;
434
435 case PPOperators.ADD_RELATIVE:
436 float_value_total = (1 - float_value_total) * value + float_value_total;
437 break;
438
439 case PPOperators.SUBSTRACT:
440 //float_value_total = float_value_total - value + float_value_default;
441 float_value_total = float_value_total - value;
442 break;
443
444 case PPOperators.SUBSTRACT_RELATIVE:
445 float_value_total = float_value_total - value * float_value_total;
446 break;
447
448 case PPOperators.SUBSTRACT_REVERSE:
449 //float_value_total = value - float_value_default - float_value_total;
450 float_value_total = value - float_value_total;
451 break;
452
453 case PPOperators.SUBSTRACT_REVERSE_RELATIVE:
454 float_value_total = value * float_value_total - float_value_total;
455 break;
456
457 case PPOperators.MULTIPLICATIVE:
458 //float_value_total = Math.Lerp(float_value_default, float_value_total, value);
459 float_value_total = float_value_total * value;
460 break;
461
462 case PPOperators.OVERRIDE:
463 float_value_total = value;
464 break;
465
466 case PPOperators.SET:
467 float_value_total = value;
468 break;
469 }
470
471 //DbgPrnt("m_LayerInfo | float_value_total pre-clamp: " + float_value_total + " | i: " + i);
472 float_value_total = Math.Clamp(float_value_total,0,1);
473
474 if ( operator == PPOperators.OVERRIDE )
475 {
476 //DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
477 override_active = true;
478 }
479
480 //RemovePriorityInfo(m_CommandLayersArray.Get(i));
481 }
482
483 m_CommandLayersArray.Clear();
484
485 //TODO - consider moving this up, if possible
486 if (active_request_count == 0)
487 {
489 }
490 else
491 {
492 float res = Math.Lerp(m_ValueMin,m_ValueMax,float_value_total);
493 Param1<float>.Cast(p_total).param1 = res; //converts back to absolute values
494 }
495
496 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
497 m_Parent.ParamUpdateRemove(m_ParameterIndex);
498
499 m_CurrentValues = p_total;
500 }
501
502 void PrepareLayerInfo(int layer, float value, int operator)
503 {
504 m_LayerInfo.Set(layer,{value,operator});
505 AddPriorityInfo(layer);
506 }
507
509 override void SetParameterValueDefault(inout Param p_total)
510 {
511 p_total = new Param1<float>(PPETemplateDefFloat.Cast(m_Defaults).param2);
512 m_CurrentValues = p_total;
513 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | exit 3 - zero value");
514 }
515}
516
518{
519 void PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
520 {
521 m_Dependencies = new map<int,ref array<int>>;
522 m_Dependencies.Set(PostProcessEffectType.Glow,{PPEGlow.PARAM_COLORIZATIONCOLOR, PPEGlow.PARAM_OVERLAYCOLOR});
523 }
524}
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