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

◆ DryItemsInVicinity() [1/2]

override void UniversalTemperatureSourceLambdaEngine::DryItemsInVicinity ( UniversalTemperatureSourceSettings pSettings)
protected

DEPRECATED.

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

388{
389 override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
390 {
391 float distanceToTemperatureSource;
392
393 foreach (Object nearestObject : nearestObjects)
394 {
395 ItemBase nearestItem = ItemBase.Cast(nearestObject);
396
398 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
399 {
400 distanceToTemperatureSource = vector.Distance(nearestItem.GetPosition(), position);
401 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.3); //min distance cannot be 0 (division by zero)
402
403 float dryModifier = 0;
404
405 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
406 {
407 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
408 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
409 nearestItem.AddWet(dryModifier);
410 }
411
412 array<EntityAI> cargoEntities = new array<EntityAI>();
413 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
414 foreach (EntityAI cargoEntity : cargoEntities)
415 {
416 ItemBase cargoItem = ItemBase.Cast(cargoEntity);
417 if (cargoItem)
418 {
419 dryModifier = 0;
420 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
421 {
422 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
423 Math.Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
424 cargoItem.AddWet(dryModifier);
425 }
426 }
427 }
428 }
429 }
430 }
431
432 override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
433 {
434 float distanceToTemperatureSource;
435 float tempTarget = pSettings.m_TemperatureItemCap;
436 EntityAI nearestEntity;
437
438 foreach (Object nearestObject : nearestObjects)
439 {
440 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
441 {
442 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
443
444 distanceToTemperatureSource = vector.Distance(nearestEntity.GetPosition(), position);
445 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1);
446
447 float time = m_ExecuteInterval;
448 if (m_ExecuteInterval == -1) //bogus time in the first execute
449 time = 1;
450
451 float distFactor = 1;
452 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
453 {
454 distFactor = Math.InverseLerp(pSettings.m_RangeMax,pSettings.m_RangeFull,distanceToTemperatureSource);
455 distFactor = Math.Max(distFactor, 0.0);
456 }
457
458 TemperatureDataInterpolated dta = new TemperatureDataInterpolated(tempTarget,ETemperatureAccessTypes.ACCESS_UTS,time,pSettings.m_TemperatureItemCoef * distFactor);
459
460 if (nearestEntity.GetInventory())
461 {
462 UpdateVicinityTemperatureRecursive(nearestEntity,dta);
463 }
464 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
465 {
466 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
467
468 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !nearestEntity.IsFreezeThawProgressFinished()) //ignoring insignificant increments
469 nearestEntity.SetTemperatureEx(dta);
470 else
471 nearestEntity.RefreshTemperatureAccess(dta);
472 }
473 }
474 }
475 }
476
477 protected void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef = 1.0)
478 {
479 float heatPermCoef = heatPermeabilityCoef;
480 heatPermCoef *= ent.GetHeatPermeabilityCoef();
481 dta.m_HeatPermeabilityCoef = heatPermCoef;
482
483 //handle temperature of this entity
484 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
485 {
486 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
487 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !ent.IsFreezeThawProgressFinished()) //ignoring insignificant increments
488 ent.SetTemperatureEx(dta);
489 else
490 ent.RefreshTemperatureAccess(dta);
491 }
492
493 // go through any attachments and cargo, recursive
494 int inventoryAttCount = ent.GetInventory().AttachmentCount();
495 if (inventoryAttCount > 0)
496 {
497 EntityAI attachmentEnt;
498 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
499 {
500 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
501 {
502 UpdateVicinityTemperatureRecursive(attachmentEnt,dta,heatPermCoef);
503 }
504 }
505 }
506
507 if (ent.GetInventory().GetCargo())
508 {
509 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
510 if (inventoryItemCount > 0)
511 {
512 EntityAI cargoEnt;
513 for (int j = 0; j < inventoryItemCount; ++j)
514 {
515 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
516 {
517 UpdateVicinityTemperatureRecursive(cargoEnt,dta,heatPermCoef);
518 }
519 }
520 }
521 }
522 }
523
524 override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
525 {
526 resultValues.m_TemperatureItem = pSettings.m_TemperatureItemCap;
527 resultValues.m_TemperatureHeatcomfort = pSettings.m_TemperatureCap;
528
529 vector pos = pSettings.m_Position;
530 if (pSettings.m_Parent != null)
531 pos = pSettings.m_Parent.GetPosition();
532
533 // Define half-size (range)
534 float halfRange = pSettings.m_RangeMax;
535
536 // Calculate min and max positions of the box
537 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
538 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
539
540 array<EntityAI> nearestObjects = {};
541 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
542
543 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
544 {
545 EntityAI entity = nearestObjects[i];
546 if (entity)
547 {
548 vector objPos = entity.GetPosition();
549 float distance = vector.Distance(objPos, pos);
550 if (distance > pSettings.m_RangeMax)
551 nearestObjects.Remove(i);
552 }
553 }
554
555 if (nearestObjects.Count() > 0)
556 {
557 DryItemsInVicinity(pSettings, pos, nearestObjects);
558 WarmAndCoolItemsInVicinity(pSettings, pos, nearestObjects);
559 }
560 }
561
564 {
565 vector pos = pSettings.m_Position;
566 if (pSettings.m_Parent != null)
567 pos = pSettings.m_Parent.GetPosition();
568
569 // Define half-size (range)
570 float halfRange = pSettings.m_RangeMax;
571
572 // Calculate min and max positions of the box
573 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
574 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
575
576 array<EntityAI> nearestObjects = {};
577 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
578
579 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
580 {
581 EntityAI entity = nearestObjects[i];
582 if (entity)
583 {
584 vector objPos = entity.GetPosition();
585 float distance = vector.Distance(objPos, pos);
586 if (distance > pSettings.m_RangeMax)
587 nearestObjects.Remove(i);
588 }
589 }
590
591 DryItemsInVicinity(pSettings, pos, nearestObjects);
592 }
593}
594
595class UniversalTemperatureSourceLambdaConstant : UniversalTemperatureSourceLambdaBaseImpl {}
597{
599 {
600 m_AffectsPlayer = false;
601 }
602}
603
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.