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

◆ Execute()

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

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

345{
346 override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
347 {
348 float distanceToTemperatureSource;
349
350 foreach (Object nearestObject : nearestObjects)
351 {
352 ItemBase nearestItem = ItemBase.Cast(nearestObject);
353 ItemBase temperatureSource = ItemBase.Cast(pSettings.m_Parent);
354
356 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
357 {
358 distanceToTemperatureSource = vector.Distance(nearestItem.GetPosition(), position);
359 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.001);
360 distanceToTemperatureSource = 1 / distanceToTemperatureSource;
361 distanceToTemperatureSource = Math.Clamp(distanceToTemperatureSource, 0.0, 1.0);
362
363 float dryValue = 0;
364
365 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
366 {
367 dryValue = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) * pSettings.m_ItemDryModifier * distanceToTemperatureSource;
368 Math.Clamp(dryValue, nearestItem.GetWetMin(), nearestItem.GetWetMax());
369 nearestItem.AddWet(dryValue);
370 }
371
372 array<EntityAI> cargoEntities = new array<EntityAI>();
373 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
374 foreach (EntityAI cargoEntity : cargoEntities)
375 {
376 ItemBase cargoItem = ItemBase.Cast(cargoEntity);
377 if (cargoItem)
378 {
379 dryValue = 0;
380 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
381 {
382 dryValue = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) * pSettings.m_ItemDryModifier * distanceToTemperatureSource;
383 Math.Clamp(dryValue, cargoItem.GetWetMin(), cargoItem.GetWetMax());
384 cargoItem.AddWet(dryValue);
385 }
386 }
387 }
388 }
389 }
390 }
391
392 override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
393 {
394 float distanceToTemperatureSource;
395 float tempTarget = pSettings.m_TemperatureItemCap;
396 EntityAI nearestEntity;
397
398 foreach (Object nearestObject : nearestObjects)
399 {
400 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
401 {
402 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
403
404 distanceToTemperatureSource = vector.Distance(nearestEntity.GetPosition(), position);
405 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1);
406
407 float time = m_ExecuteInterval;
408 if (m_ExecuteInterval == -1) //bogus time in the first execute
409 time = 1;
410
411 float distFactor = 1;
412 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
413 {
414 distFactor = Math.InverseLerp(pSettings.m_RangeMax,pSettings.m_RangeFull,distanceToTemperatureSource);
415 distFactor = Math.Max(distFactor, 0.0);
416 }
417
418 TemperatureDataInterpolated dta = new TemperatureDataInterpolated(tempTarget,ETemperatureAccessTypes.ACCESS_UTS,time,pSettings.m_TemperatureItemCoef * distFactor);
419
420 if (nearestEntity.GetInventory())
421 {
422 UpdateVicinityTemperatureRecursive(nearestEntity,dta);
423 }
424 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
425 {
426 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
427
428 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !nearestEntity.IsFreezeThawProgressFinished()) //ignoring insignificant increments
429 nearestEntity.SetTemperatureEx(dta);
430 else
431 nearestEntity.RefreshTemperatureAccess(dta);
432 }
433 }
434 }
435 }
436
437 protected void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef = 1.0)
438 {
439 float heatPermCoef = heatPermeabilityCoef;
440 heatPermCoef *= ent.GetHeatPermeabilityCoef();
441 dta.m_HeatPermeabilityCoef = heatPermCoef;
442
443 //handle temperature of this entity
444 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
445 {
446 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
447 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !ent.IsFreezeThawProgressFinished()) //ignoring insignificant increments
448 ent.SetTemperatureEx(dta);
449 else
450 ent.RefreshTemperatureAccess(dta);
451 }
452
453 // go through any attachments and cargo, recursive
454 int inventoryAttCount = ent.GetInventory().AttachmentCount();
455 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
456 {
457 EntityAI attachmentEnt;
458 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
459 {
460 UpdateVicinityTemperatureRecursive(attachmentEnt,dta,heatPermCoef);
461 }
462 }
463
464 CargoBase cargo = ent.GetInventory().GetCargo();
465 if (cargo)
466 {
467 int inventoryItemCount = cargo.GetItemCount();
468 for (int j = 0; j < inventoryItemCount; ++j)
469 {
470 EntityAI cargoEnt;
471 if (Class.CastTo(cargoEnt, cargo.GetItem(j)))
472 {
473 UpdateVicinityTemperatureRecursive(cargoEnt, dta, heatPermCoef);
474 }
475 }
476 }
477 }
478
479 override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
480 {
481 resultValues.m_TemperatureItem = pSettings.m_TemperatureItemCap;
482 resultValues.m_TemperatureHeatcomfort = pSettings.m_TemperatureCap;
483
484 vector pos = pSettings.m_Position;
485 if (pSettings.m_Parent != null)
486 pos = pSettings.m_Parent.GetPosition();
487
488 // Define half-size (range)
489 float halfRange = pSettings.m_RangeMax;
490
491 // Calculate min and max positions of the box
492 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
493 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
494
495 array<EntityAI> nearestObjects = {};
496 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
497
498 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
499 {
500 EntityAI entity = nearestObjects[i];
501 if (entity)
502 {
503 vector objPos = entity.GetPosition();
504 float distance = vector.Distance(objPos, pos);
505 if (distance > pSettings.m_RangeMax)
506 nearestObjects.Remove(i);
507 }
508 }
509
510 if (nearestObjects.Count() > 0)
511 {
512 DryItemsInVicinity(pSettings, pos, nearestObjects);
513 WarmAndCoolItemsInVicinity(pSettings, pos, nearestObjects);
514 }
515 }
516
519 {
520 vector pos = pSettings.m_Position;
521 if (pSettings.m_Parent != null)
522 pos = pSettings.m_Parent.GetPosition();
523
524 // Define half-size (range)
525 float halfRange = pSettings.m_RangeMax;
526
527 // Calculate min and max positions of the box
528 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
529 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
530
531 array<EntityAI> nearestObjects = {};
532 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
533
534 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
535 {
536 EntityAI entity = nearestObjects[i];
537 if (entity)
538 {
539 vector objPos = entity.GetPosition();
540 float distance = vector.Distance(objPos, pos);
541 if (distance > pSettings.m_RangeMax)
542 nearestObjects.Remove(i);
543 }
544 }
545
546 DryItemsInVicinity(pSettings, pos, nearestObjects);
547 }
548}
549
550class UniversalTemperatureSourceLambdaConstant : UniversalTemperatureSourceLambdaBaseImpl {}
552{
554 {
555 m_AffectsPlayer = false;
556 }
557}
558
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)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
represents base for cargo storage for entities
Определения Cargo.c:7
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:19
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_ItemDryModifier
maximum range where the receiver can get some temperature
Определения UniversalTemperatureSource.c:9
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:119
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/DayZ/constants.c:943
const float STATE_DAMP
Определения 3_Game/DayZ/constants.c:878
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.