312{
314 {
315 float distanceToTemperatureSource;
316
317 foreach (
Object nearestObject : nearestObjects)
318 {
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);
326
327 float dryModifier = 0;
328
330 {
331 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
332 Math.
Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
333 nearestItem.AddWet(dryModifier);
334 }
335
338 foreach (
EntityAI cargoEntity : cargoEntities)
339 {
341 if (cargoItem)
342 {
343 dryModifier = 0;
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
357 {
358 float distanceToTemperatureSource;
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)
373 time = 1;
374
375 float distFactor = 1;
377 {
379 distFactor =
Math.
Max(distFactor, 0.0);
380 }
381
383
384 if (nearestEntity.GetInventory())
385 {
387 }
388 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
389 {
390 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
391
393 nearestEntity.SetTemperatureEx(dta);
394 else
395 nearestEntity.RefreshTemperatureAccess(dta);
396 }
397 }
398 }
399 }
400
402 {
403 float heatPermCoef = heatPermeabilityCoef;
404 heatPermCoef *= ent.GetHeatPermeabilityCoef();
406
407
408 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
409 {
412 ent.SetTemperatureEx(dta);
413 else
414 ent.RefreshTemperatureAccess(dta);
415 }
416
417
418 int inventoryAttCount = ent.GetInventory().AttachmentCount();
419 if (inventoryAttCount > 0)
420 {
422 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
423 {
424 if (
Class.
CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
425 {
427 }
428 }
429 }
430
431 if (ent.GetInventory().GetCargo())
432 {
433 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
434 if (inventoryItemCount > 0)
435 {
437 for (int j = 0; j < inventoryItemCount; ++j)
438 {
439 if (
Class.
CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
440 {
442 }
443 }
444 }
445 }
446 }
447
449 {
452
454
457 pos = pSettings.
m_Parent.GetPosition();
458
460 if (nearestObjects.Count() > 0)
461 {
464 }
465 }
466
469 {
471
474 pos = pSettings.
m_Parent.GetPosition();
475
477
479 }
480}
481
484{
486 {
487 m_AffectsPlayer = false;
488 }
489}
490
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.
float m_HeatPermeabilityCoef
vector m_Position
if the stats can be overriden by coefficient/variables from WorldData (currently TemperatureCap only)
float m_RangeFull
temperature cap that will limit the return value from GetTemperature method
float m_TemperatureCap
used to determine speed of temperature change, and some temperature subsystems
float m_TemperatureItemCoef
max temperature 'non-IsSelfAdjustingTemperature' entity in vicinity will get per update (cap);
float m_RangeMax
range where the full temperature is given to receiver
float m_TemperatureItemCap
how often the Update is ticking
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.
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
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
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.