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

◆ Execute()

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

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

312{
313 override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<Object> nearestObjects)
314 {
315 float distanceToTemperatureSource;
316
317 foreach (Object nearestObject : nearestObjects)
318 {
319 ItemBase nearestItem = ItemBase.Cast(nearestObject);
320
322 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
323 {
324 distanceToTemperatureSource = vector.Distance(nearestItem.GetPosition(), position);
325 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.3); //min distance cannot be 0 (division by zero)
326
327 float dryModifier = 0;
328
329 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
330 {
331 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
332 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
333 nearestItem.AddWet(dryModifier);
334 }
335
336 array<EntityAI> cargoEntities = new array<EntityAI>();
337 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
338 foreach (EntityAI cargoEntity : cargoEntities)
339 {
340 ItemBase cargoItem = ItemBase.Cast(cargoEntity);
341 if (cargoItem)
342 {
343 dryModifier = 0;
344 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
345 {
346 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
347 Math.Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
348 cargoItem.AddWet(dryModifier);
349 }
350 }
351 }
352 }
353 }
354 }
355
356 override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<Object> nearestObjects)
357 {
358 float distanceToTemperatureSource;
359 float tempTarget = pSettings.m_TemperatureItemCap;
360 EntityAI nearestEntity;
361
362 foreach (Object nearestObject : nearestObjects)
363 {
364 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
365 {
366 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
367
368 distanceToTemperatureSource = vector.Distance(nearestEntity.GetPosition(), position);
369 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1);
370
371 float time = m_ExecuteInterval;
372 if (m_ExecuteInterval == -1) //bogus time in the first execute
373 time = 1;
374
375 float distFactor = 1;
376 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
377 {
378 distFactor = Math.InverseLerp(pSettings.m_RangeMax,pSettings.m_RangeFull,distanceToTemperatureSource);
379 distFactor = Math.Max(distFactor, 0.0);
380 }
381
382 TemperatureDataInterpolated dta = new TemperatureDataInterpolated(tempTarget,ETemperatureAccessTypes.ACCESS_UTS,time,pSettings.m_TemperatureItemCoef * distFactor);
383
384 if (nearestEntity.GetInventory())
385 {
386 UpdateVicinityTemperatureRecursive(nearestEntity,dta);
387 }
388 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
389 {
390 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
391
392 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !nearestEntity.IsFreezeThawProgressFinished()) //ignoring insignificant increments
393 nearestEntity.SetTemperatureEx(dta);
394 else
395 nearestEntity.RefreshTemperatureAccess(dta);
396 }
397 }
398 }
399 }
400
401 protected void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef = 1.0)
402 {
403 float heatPermCoef = heatPermeabilityCoef;
404 heatPermCoef *= ent.GetHeatPermeabilityCoef();
405 dta.m_HeatPermeabilityCoef = heatPermCoef;
406
407 //handle temperature of this entity
408 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
409 {
410 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
411 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !ent.IsFreezeThawProgressFinished()) //ignoring insignificant increments
412 ent.SetTemperatureEx(dta);
413 else
414 ent.RefreshTemperatureAccess(dta);
415 }
416
417 // go through any attachments and cargo, recursive
418 int inventoryAttCount = ent.GetInventory().AttachmentCount();
419 if (inventoryAttCount > 0)
420 {
421 EntityAI attachmentEnt;
422 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
423 {
424 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
425 {
426 UpdateVicinityTemperatureRecursive(attachmentEnt,dta,heatPermCoef);
427 }
428 }
429 }
430
431 if (ent.GetInventory().GetCargo())
432 {
433 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
434 if (inventoryItemCount > 0)
435 {
436 EntityAI cargoEnt;
437 for (int j = 0; j < inventoryItemCount; ++j)
438 {
439 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
440 {
441 UpdateVicinityTemperatureRecursive(cargoEnt,dta,heatPermCoef);
442 }
443 }
444 }
445 }
446 }
447
448 override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
449 {
450 resultValues.m_TemperatureItem = pSettings.m_TemperatureItemCap;
451 resultValues.m_TemperatureHeatcomfort = pSettings.m_TemperatureCap;
452
453 array<Object> nearestObjects = new array<Object>();
454
455 vector pos = pSettings.m_Position;
456 if (pSettings.m_Parent != null)
457 pos = pSettings.m_Parent.GetPosition();
458
459 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
460 if (nearestObjects.Count() > 0)
461 {
462 DryItemsInVicinity(pSettings, pos, nearestObjects);
463 WarmAndCoolItemsInVicinity(pSettings, pos, nearestObjects);
464 }
465 }
466
469 {
470 array<Object> nearestObjects = new array<Object>();
471
472 vector pos = pSettings.m_Position;
473 if (pSettings.m_Parent != null)
474 pos = pSettings.m_Parent.GetPosition();
475
476 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
477
478 DryItemsInVicinity(pSettings, pos, nearestObjects);
479 }
480}
481
482class UniversalTemperatureSourceLambdaConstant : UniversalTemperatureSourceLambdaBaseImpl {}
484{
486 {
487 m_AffectsPlayer = false;
488 }
489}
490
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< Object > nearestObjects)
void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef=1.0)
UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine()
override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< Object > nearestObjects)
proto native void GetObjectsAtPosition(vector pos, float radius, out array< Object > objects, out array< CargoBase > proxyCargos)
Returns list of all objects in circle "radius" around position "pos".
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Building.c:6
Определения constants.c:659
Определения InventoryItem.c:731
Определения 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
proto native CGame GetGame()
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
Определения constants.c:938
const float STATE_DAMP
Определения constants.c:873
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.