265{
267 {
268 float distanceToTemperatureSource;
269
270 foreach (
Object nearestObject : nearestObjects)
271 {
273
275 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.
m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
276 {
277 distanceToTemperatureSource =
vector.
Distance(nearestItem.GetPosition(), position);
278 distanceToTemperatureSource =
Math.
Max(distanceToTemperatureSource, 0.3);
279
280 float dryModifier = 0;
281
283 {
284 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
285 Math.
Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
286 nearestItem.AddWet(dryModifier);
287 }
288
291 foreach (
EntityAI cargoEntity : cargoEntities)
292 {
294 if (cargoItem)
295 {
296 dryModifier = 0;
298 {
299 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
300 Math.
Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
301 cargoItem.AddWet(dryModifier);
302 }
303 }
304 }
305 }
306 }
307 }
308
310 {
311 float distanceToTemperatureSource;
314
315 foreach (
Object nearestObject : nearestObjects)
316 {
317 if (
Class.
CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.
m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
318 {
319 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
320
321 distanceToTemperatureSource =
vector.
Distance(nearestEntity.GetPosition(), position);
322 distanceToTemperatureSource =
Math.
Max(distanceToTemperatureSource, 0.1);
323
324 float time = m_ExecuteInterval;
325 if (m_ExecuteInterval == -1)
326 time = 1;
327
328 float distFactor = 1;
330 {
332 distFactor =
Math.
Max(distFactor, 0.0);
333 }
334
336
337 if (nearestEntity.GetInventory())
338 {
340 }
341 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
342 {
343 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
344
346 nearestEntity.SetTemperatureEx(dta);
347 else
348 nearestEntity.RefreshTemperatureAccess(dta);
349 }
350 }
351 }
352 }
353
355 {
356 float heatPermCoef = heatPermeabilityCoef;
357 heatPermCoef *= ent.GetHeatPermeabilityCoef();
359
360
361 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
362 {
365 ent.SetTemperatureEx(dta);
366 else
367 ent.RefreshTemperatureAccess(dta);
368 }
369
370
371 int inventoryAttCount = ent.GetInventory().AttachmentCount();
372 if (inventoryAttCount > 0)
373 {
375 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
376 {
377 if (
Class.
CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
378 {
380 }
381 }
382 }
383
384 if (ent.GetInventory().GetCargo())
385 {
386 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
387 if (inventoryItemCount > 0)
388 {
390 for (int j = 0; j < inventoryItemCount; ++j)
391 {
392 if (
Class.
CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
393 {
395 }
396 }
397 }
398 }
399 }
400
402 {
405
407
410 pos = pSettings.
m_Parent.GetPosition();
411
413 if (nearestObjects.Count() > 0)
414 {
417 }
418 }
419
422 {
424
427 pos = pSettings.
m_Parent.GetPosition();
428
430
432 }
433}
434
437{
439 {
440 m_AffectsPlayer = false;
441 }
442}
443
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.