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

◆ Execute()

override void UniversalTemperatureSourceLambdaEngine::Execute ( UniversalTemperatureSourceSettings pSettings,
UniversalTemperatureSourceResult resultValues )
protected

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

349{
350 override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
351 {
352 float distanceToTemperatureSource;
353
354 foreach (Object nearestObject : nearestObjects)
355 {
356 ItemBase nearestItem = ItemBase.Cast(nearestObject);
357
359 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
360 {
361 distanceToTemperatureSource = vector.Distance(nearestItem.GetPosition(), position);
362 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.3); //min distance cannot be 0 (division by zero)
363
364 float dryModifier = 0;
365
366 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
367 {
368 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
369 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
370 nearestItem.AddWet(dryModifier);
371 }
372
373 array<EntityAI> cargoEntities = new array<EntityAI>();
374 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
375 foreach (EntityAI cargoEntity : cargoEntities)
376 {
377 ItemBase cargoItem = ItemBase.Cast(cargoEntity);
378 if (cargoItem)
379 {
380 dryModifier = 0;
381 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
382 {
383 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
384 Math.Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
385 cargoItem.AddWet(dryModifier);
386 }
387 }
388 }
389 }
390 }
391 }
392
393 override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
394 {
395 float distanceToTemperatureSource;
396 float tempTarget = pSettings.m_TemperatureItemCap;
397 EntityAI nearestEntity;
398
399 foreach (Object nearestObject : nearestObjects)
400 {
401 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
402 {
403 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
404
405 distanceToTemperatureSource = vector.Distance(nearestEntity.GetPosition(), position);
406 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1);
407
408 float time = m_ExecuteInterval;
409 if (m_ExecuteInterval == -1) //bogus time in the first execute
410 time = 1;
411
412 float distFactor = 1;
413 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
414 {
415 distFactor = Math.InverseLerp(pSettings.m_RangeMax,pSettings.m_RangeFull,distanceToTemperatureSource);
416 distFactor = Math.Max(distFactor, 0.0);
417 }
418
419 TemperatureDataInterpolated dta = new TemperatureDataInterpolated(tempTarget,ETemperatureAccessTypes.ACCESS_UTS,time,pSettings.m_TemperatureItemCoef * distFactor);
420
421 if (nearestEntity.GetInventory())
422 {
423 UpdateVicinityTemperatureRecursive(nearestEntity,dta);
424 }
425 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
426 {
427 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
428
429 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !nearestEntity.IsFreezeThawProgressFinished()) //ignoring insignificant increments
430 nearestEntity.SetTemperatureEx(dta);
431 else
432 nearestEntity.RefreshTemperatureAccess(dta);
433 }
434 }
435 }
436 }
437
438 protected void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef = 1.0)
439 {
440 float heatPermCoef = heatPermeabilityCoef;
441 heatPermCoef *= ent.GetHeatPermeabilityCoef();
442 dta.m_HeatPermeabilityCoef = heatPermCoef;
443
444 //handle temperature of this entity
445 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
446 {
447 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
448 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !ent.IsFreezeThawProgressFinished()) //ignoring insignificant increments
449 ent.SetTemperatureEx(dta);
450 else
451 ent.RefreshTemperatureAccess(dta);
452 }
453
454 // go through any attachments and cargo, recursive
455 int inventoryAttCount = ent.GetInventory().AttachmentCount();
456 if (inventoryAttCount > 0)
457 {
458 EntityAI attachmentEnt;
459 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
460 {
461 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
462 {
463 UpdateVicinityTemperatureRecursive(attachmentEnt,dta,heatPermCoef);
464 }
465 }
466 }
467
468 if (ent.GetInventory().GetCargo())
469 {
470 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
471 if (inventoryItemCount > 0)
472 {
473 EntityAI cargoEnt;
474 for (int j = 0; j < inventoryItemCount; ++j)
475 {
476 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
477 {
478 UpdateVicinityTemperatureRecursive(cargoEnt,dta,heatPermCoef);
479 }
480 }
481 }
482 }
483 }
484
485 override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
486 {
487 resultValues.m_TemperatureItem = pSettings.m_TemperatureItemCap;
488 resultValues.m_TemperatureHeatcomfort = pSettings.m_TemperatureCap;
489
490 vector pos = pSettings.m_Position;
491 if (pSettings.m_Parent != null)
492 pos = pSettings.m_Parent.GetPosition();
493
494 // Define half-size (range)
495 float halfRange = pSettings.m_RangeMax;
496
497 // Calculate min and max positions of the box
498 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
499 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
500
501 array<EntityAI> nearestObjects = {};
502 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
503
504 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
505 {
506 EntityAI entity = nearestObjects[i];
507 if (entity)
508 {
509 vector objPos = entity.GetPosition();
510 float distance = vector.Distance(objPos, pos);
511 if (distance > pSettings.m_RangeMax)
512 nearestObjects.Remove(i);
513 }
514 }
515
516 if (nearestObjects.Count() > 0)
517 {
518 DryItemsInVicinity(pSettings, pos, nearestObjects);
519 WarmAndCoolItemsInVicinity(pSettings, pos, nearestObjects);
520 }
521 }
522
525 {
526 vector pos = pSettings.m_Position;
527 if (pSettings.m_Parent != null)
528 pos = pSettings.m_Parent.GetPosition();
529
530 // Define half-size (range)
531 float halfRange = pSettings.m_RangeMax;
532
533 // Calculate min and max positions of the box
534 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
535 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
536
537 array<EntityAI> nearestObjects = {};
538 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
539
540 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
541 {
542 EntityAI entity = nearestObjects[i];
543 if (entity)
544 {
545 vector objPos = entity.GetPosition();
546 float distance = vector.Distance(objPos, pos);
547 if (distance > pSettings.m_RangeMax)
548 nearestObjects.Remove(i);
549 }
550 }
551
552 DryItemsInVicinity(pSettings, pos, nearestObjects);
553 }
554}
555
556class UniversalTemperatureSourceLambdaConstant : UniversalTemperatureSourceLambdaBaseImpl {}
558{
560 {
561 m_AffectsPlayer = false;
562 }
563}
564
void DayZPlayerUtils()
cannot be instantiated
Определения DayZPlayerUtils.c:465
QueryFlags
Определения DayZPlayerUtils.c:2
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< EntityAI > nearestObjects)
override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< EntityAI > nearestObjects)
void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef=1.0)
UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine()
override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения EnMath.c:7
Определения ObjectTyped.c:2
float m_AdjustedTarget
Определения TemperatureData.c:6
float m_HeatPermeabilityCoef
Определения TemperatureData.c:9
Определения TemperatureData.c:2
vector m_Position
if the stats can be overriden by coefficient/variables from WorldData (currently TemperatureCap only)
Определения UniversalTemperatureSource.c:18
float m_RangeFull
temperature cap that will limit the return value from GetTemperature method
Определения UniversalTemperatureSource.c:7
float m_TemperatureCap
used to determine speed of temperature change, and some temperature subsystems
Определения UniversalTemperatureSource.c:6
float m_TemperatureItemCoef
max temperature 'non-IsSelfAdjustingTemperature' entity in vicinity will get per update (cap);
Определения UniversalTemperatureSource.c:5
float m_RangeMax
range where the full temperature is given to receiver
Определения UniversalTemperatureSource.c:8
float m_TemperatureItemCap
how often the Update is ticking
Определения UniversalTemperatureSource.c:4
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:106
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static const float TEMPERATURE_SENSITIVITY_THRESHOLD
Определения 3_Game/constants.c:940
const float STATE_DAMP
Определения 3_Game/constants.c:875
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Max(float x, float y)
Returns bigger 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'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float AbsFloat(float f)
Returns absolute value.