220{
222 {
223 float distanceToTemperatureSource;
224
225 foreach (
Object nearestObject : nearestObjects)
226 {
228
230 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.
m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
231 {
232 distanceToTemperatureSource =
vector.
Distance(nearestItem.GetPosition(), position);
233 distanceToTemperatureSource =
Math.
Max(distanceToTemperatureSource, 0.3);
234
235 float dryModifier = 0;
236
238 {
239 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
240 Math.
Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
241 nearestItem.AddWet(dryModifier);
242 }
243
246 foreach (
EntityAI cargoEntity : cargoEntities)
247 {
249 if (cargoItem)
250 {
251 dryModifier = 0;
253 {
254 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
255 Math.
Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
256 cargoItem.AddWet(dryModifier);
257 }
258 }
259 }
260 }
261 }
262 }
263
265 {
266 float distanceToTemperatureSource;
269
270 foreach (
Object nearestObject : nearestObjects)
271 {
272 if (
Class.
CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.
m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
273 {
274 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
275
276 distanceToTemperatureSource =
vector.
Distance(nearestEntity.GetPosition(), position);
277 distanceToTemperatureSource =
Math.
Max(distanceToTemperatureSource, 0.1);
278
279 float time = m_ExecuteInterval;
280 if (m_ExecuteInterval == -1)
281 time = 1;
282
283 float distFactor = 1;
285 {
287 distFactor =
Math.
Max(distFactor, 0.0);
288 }
289
291
292 if (nearestEntity.GetInventory())
293 {
295 }
296 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
297 {
298 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
299
301 nearestEntity.SetTemperatureEx(dta);
302 else
303 nearestEntity.RefreshTemperatureAccess(dta);
304 }
305 }
306 }
307 }
308
310 {
311 float heatPermCoef = heatPermeabilityCoef;
312 heatPermCoef *= ent.GetHeatPermeabilityCoef();
314
315
316 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
317 {
320 ent.SetTemperatureEx(dta);
321 else
322 ent.RefreshTemperatureAccess(dta);
323 }
324
325
326 int inventoryAttCount = ent.GetInventory().AttachmentCount();
327 if (inventoryAttCount > 0)
328 {
330 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
331 {
332 if (
Class.
CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
333 {
335 }
336 }
337 }
338
339 if (ent.GetInventory().GetCargo())
340 {
341 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
342 if (inventoryItemCount > 0)
343 {
345 for (int j = 0; j < inventoryItemCount; ++j)
346 {
347 if (
Class.
CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
348 {
350 }
351 }
352 }
353 }
354 }
355
357 {
360
362
365 pos = pSettings.
m_Parent.GetPosition();
366
368 if (nearestObjects.Count() > 0)
369 {
372 }
373 }
374
377 {
379
382 pos = pSettings.
m_Parent.GetPosition();
383
385
387 }
388}
389
392{
394 {
395 m_AffectsPlayer = false;
396 }
397}
398
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.