DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл UniversalTemperatureSourceLambdaBaseImpl.c

См. исходные тексты.

Структуры данных

class  UniversalTemperatureSourceLambdaBaseImpl
 

Функции

UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine ()
 
override void DryItemsInVicinity (UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< Object > nearestObjects)
 
override void WarmAndCoolItemsInVicinity (UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< Object > nearestObjects)
 
void UpdateVicinityTemperatureRecursive (EntityAI ent, TemperatureData dta, float heatPermeabilityCoef=1.0)
 
override void Execute (UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
 
override void DryItemsInVicinity (UniversalTemperatureSourceSettings pSettings)
 DEPRECATED.
 

Функции

◆ DryItemsInVicinity() [1/2]

override void DryItemsInVicinity ( UniversalTemperatureSourceSettings pSettings)
protected

DEPRECATED.

◆ DryItemsInVicinity() [2/2]

override void DryItemsInVicinity ( UniversalTemperatureSourceSettings pSettings,
vector position,
out notnull array< Object > nearestObjects )

heat transfer to items (not in player possession)

176 {
177 m_AffectsPlayer = false;
178 }
179}
180

◆ Execute()

override void Execute ( UniversalTemperatureSourceSettings pSettings,
UniversalTemperatureSourceResult resultValues )
protected
313{
315 {
317
319 {
321
323 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
324 {
326 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1); //min distance cannot be 0 (division by zero)
327
328 float dryModifier = 0;
329
330 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
331 {
332 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
333 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
334 nearestItem.AddWet(dryModifier);
335 }
336
338 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
340 {
342 if (cargoItem)
343 {
344 dryModifier = 0;
345 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
346 {
347 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
348 Math.Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
349 cargoItem.AddWet(dryModifier);
350 }
351 }
352 }
353 }
354 }
355 }
356
358 {
360 float tempTarget = pSettings.m_TemperatureItemCap;
363
365 {
366 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
367 {
368 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
369
372
373 float time = m_ExecuteInterval;
374 if (m_ExecuteInterval == -1) //bogus time in the first execute
375 time = 1;
376
377 float distFactor = 1;
378 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
379 {
381 distFactor = Math.Max(distFactor, 0.0);
382 }
383
385
386 if (nearestEntity.GetInventory())
387 {
389 }
390 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
391 {
392 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
393
394 if (Math.AbsFloat(temperatureDifference) < GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD) //ignoring insignificant increments
395 nearestEntity.RefreshTemperatureAccess(dta);
396 else
397 nearestEntity.SetTemperatureEx(dta);
398 }
399 }
400 }
401 }
402
404 {
406 heatPermCoef *= ent.GetHeatPermeabilityCoef();
407 dta.m_HeatPermeabilityCoef = heatPermCoef;
408
409 //handle temperature of this entity
410 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
411 {
412 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
413 if (Math.AbsFloat(temperatureDifference) < GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD) //ignoring insignificant increments
414 ent.RefreshTemperatureAccess(dta);
415 else
416 ent.SetTemperatureEx(dta);
417 }
418
419 // go through any attachments and cargo, recursive
420 int inventoryAttCount = ent.GetInventory().AttachmentCount();
421 if (inventoryAttCount > 0)
422 {
424 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
425 {
426 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
427 {
429 }
430 }
431 }
432
433 if (ent.GetInventory().GetCargo())
434 {
435 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
436 if (inventoryItemCount > 0)
437 {
439 for (int j = 0; j < inventoryItemCount; ++j)
440 {
441 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
442 {
444 }
445 }
446 }
447 }
448 }
449
451 {
452 resultValues.m_Temperature = pSettings.m_TemperatureMax;
453
455
456 vector pos = pSettings.m_Position;
457 if (pSettings.m_Parent != null)
458 pos = pSettings.m_Parent.GetPosition();
459
460 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
461 if (nearestObjects.Count() > 0)
462 {
465 }
466 }
467
470 {
472
473 vector pos = pSettings.m_Position;
474 if (pSettings.m_Parent != null)
475 pos = pSettings.m_Parent.GetPosition();
476
477 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
478
480 }
481}
482
485{
487 {
488 m_AffectsPlayer = false;
489 }
490}
491
ETemperatureAccessTypes
Definition TemperatureAccessConstants.c:2
override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< Object > nearestObjects)
Definition UniversalTemperatureSourceLambdaBaseImpl.c:219
override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< Object > nearestObjects)
Definition UniversalTemperatureSourceLambdaBaseImpl.c:176
void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef=1.0)
Definition UniversalTemperatureSourceLambdaBaseImpl.c:265
UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine()
Definition UniversalTemperatureSourceLambdaBaseImpl.c:175
override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
Definition UniversalTemperatureSourceLambdaBaseImpl.c:312
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Building.c:6
Definition constants.c:638
Definition InventoryItem.c:731
Definition EnMath.c:7
Definition ObjectTyped.c:2
Definition EntityAI.c:95
Definition TemperatureData.c:2
Definition UniversalTemperatureSourceLambdaBase.c:2
Definition UniversalTemperatureSourceLambdaBaseImpl.c:2
Definition UniversalTemperatureSource.c:2
Definition EnConvert.c:106
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
Definition 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
Definition constants.c:898
const float STATE_DAMP
Definition constants.c:834
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.

◆ UniversalTemperatureSourceLambdaEngine()

176 {
177 m_AffectsPlayer = false;
178 }

Используется в ItemBase::EEInit(), Boat_01_ColorBase::EEInit(), CarScript::EEInit() и OnDebugSpawn().

◆ UpdateVicinityTemperatureRecursive()

void UpdateVicinityTemperatureRecursive ( EntityAI ent,
TemperatureData dta,
float heatPermeabilityCoef = 1.0 )
protected
266{
268 {
270
272 {
274
276 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
277 {
279 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1); //min distance cannot be 0 (division by zero)
280
281 float dryModifier = 0;
282
283 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
284 {
285 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
286 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
287 nearestItem.AddWet(dryModifier);
288 }
289
291 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
293 {
295 if (cargoItem)
296 {
297 dryModifier = 0;
298 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
299 {
300 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
301 Math.Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
302 cargoItem.AddWet(dryModifier);
303 }
304 }
305 }
306 }
307 }
308 }
309
311 {
313 float tempTarget = pSettings.m_TemperatureItemCap;
316
318 {
319 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
320 {
321 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
322
325
326 float time = m_ExecuteInterval;
327 if (m_ExecuteInterval == -1) //bogus time in the first execute
328 time = 1;
329
330 float distFactor = 1;
331 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
332 {
334 distFactor = Math.Max(distFactor, 0.0);
335 }
336
338
339 if (nearestEntity.GetInventory())
340 {
342 }
343 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
344 {
345 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
346
347 if (Math.AbsFloat(temperatureDifference) < GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD) //ignoring insignificant increments
348 nearestEntity.RefreshTemperatureAccess(dta);
349 else
350 nearestEntity.SetTemperatureEx(dta);
351 }
352 }
353 }
354 }
355
357 {
359 heatPermCoef *= ent.GetHeatPermeabilityCoef();
360 dta.m_HeatPermeabilityCoef = heatPermCoef;
361
362 //handle temperature of this entity
363 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
364 {
365 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
366 if (Math.AbsFloat(temperatureDifference) < GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD) //ignoring insignificant increments
367 ent.RefreshTemperatureAccess(dta);
368 else
369 ent.SetTemperatureEx(dta);
370 }
371
372 // go through any attachments and cargo, recursive
373 int inventoryAttCount = ent.GetInventory().AttachmentCount();
374 if (inventoryAttCount > 0)
375 {
377 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
378 {
379 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
380 {
382 }
383 }
384 }
385
386 if (ent.GetInventory().GetCargo())
387 {
388 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
389 if (inventoryItemCount > 0)
390 {
392 for (int j = 0; j < inventoryItemCount; ++j)
393 {
394 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
395 {
397 }
398 }
399 }
400 }
401 }
402
404 {
405 resultValues.m_Temperature = pSettings.m_TemperatureMax;
406
408
409 vector pos = pSettings.m_Position;
410 if (pSettings.m_Parent != null)
411 pos = pSettings.m_Parent.GetPosition();
412
413 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
414 if (nearestObjects.Count() > 0)
415 {
418 }
419 }
420
423 {
425
426 vector pos = pSettings.m_Position;
427 if (pSettings.m_Parent != null)
428 pos = pSettings.m_Parent.GetPosition();
429
430 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
431
433 }
434}
435
438{
440 {
441 m_AffectsPlayer = false;
442 }
443}
444

◆ WarmAndCoolItemsInVicinity()

override void WarmAndCoolItemsInVicinity ( UniversalTemperatureSourceSettings pSettings,
vector position,
out notnull array< Object > nearestObjects )

dist factor minimum should be at 0

220{
222 {
224
226 {
228
230 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
231 {
233 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1); //min distance cannot be 0 (division by zero)
234
235 float dryModifier = 0;
236
237 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
238 {
239 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
240 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
241 nearestItem.AddWet(dryModifier);
242 }
243
245 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
247 {
249 if (cargoItem)
250 {
251 dryModifier = 0;
252 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
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 {
267 float tempTarget = pSettings.m_TemperatureItemCap;
270
272 {
273 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
274 {
275 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
276
279
280 float time = m_ExecuteInterval;
281 if (m_ExecuteInterval == -1) //bogus time in the first execute
282 time = 1;
283
284 float distFactor = 1;
285 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
286 {
288 distFactor = Math.Max(distFactor, 0.0);
289 }
290
292
293 if (nearestEntity.GetInventory())
294 {
296 }
297 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
298 {
299 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
300
301 if (Math.AbsFloat(temperatureDifference) < GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD) //ignoring insignificant increments
302 nearestEntity.RefreshTemperatureAccess(dta);
303 else
304 nearestEntity.SetTemperatureEx(dta);
305 }
306 }
307 }
308 }
309
311 {
313 heatPermCoef *= ent.GetHeatPermeabilityCoef();
314 dta.m_HeatPermeabilityCoef = heatPermCoef;
315
316 //handle temperature of this entity
317 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
318 {
319 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
320 if (Math.AbsFloat(temperatureDifference) < GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD) //ignoring insignificant increments
321 ent.RefreshTemperatureAccess(dta);
322 else
323 ent.SetTemperatureEx(dta);
324 }
325
326 // go through any attachments and cargo, recursive
327 int inventoryAttCount = ent.GetInventory().AttachmentCount();
328 if (inventoryAttCount > 0)
329 {
331 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
332 {
333 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
334 {
336 }
337 }
338 }
339
340 if (ent.GetInventory().GetCargo())
341 {
342 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
343 if (inventoryItemCount > 0)
344 {
346 for (int j = 0; j < inventoryItemCount; ++j)
347 {
348 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
349 {
351 }
352 }
353 }
354 }
355 }
356
358 {
359 resultValues.m_Temperature = pSettings.m_TemperatureMax;
360
362
363 vector pos = pSettings.m_Position;
364 if (pSettings.m_Parent != null)
365 pos = pSettings.m_Parent.GetPosition();
366
367 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
368 if (nearestObjects.Count() > 0)
369 {
372 }
373 }
374
377 {
379
380 vector pos = pSettings.m_Position;
381 if (pSettings.m_Parent != null)
382 pos = pSettings.m_Parent.GetPosition();
383
384 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
385
387 }
388}
389
392{
394 {
395 m_AffectsPlayer = false;
396 }
397}
398