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

◆ UpdateVicinityTemperatureRecursive()

void UniversalTemperatureSourceLambdaEngine::UpdateVicinityTemperatureRecursive ( EntityAI ent,
TemperatureData dta,
float heatPermeabilityCoef = 1.0 )
protected

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

265{
266 override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<Object> nearestObjects)
267 {
268 float distanceToTemperatureSource;
269
270 foreach (Object nearestObject : nearestObjects)
271 {
272 ItemBase nearestItem = ItemBase.Cast(nearestObject);
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); //min distance cannot be 0 (division by zero)
279
280 float dryModifier = 0;
281
282 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
283 {
284 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
285 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
286 nearestItem.AddWet(dryModifier);
287 }
288
289 array<EntityAI> cargoEntities = new array<EntityAI>();
290 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
291 foreach (EntityAI cargoEntity : cargoEntities)
292 {
293 ItemBase cargoItem = ItemBase.Cast(cargoEntity);
294 if (cargoItem)
295 {
296 dryModifier = 0;
297 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
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
309 override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<Object> nearestObjects)
310 {
311 float distanceToTemperatureSource;
312 float tempTarget = pSettings.m_TemperatureItemCap;
313 EntityAI nearestEntity;
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) //bogus time in the first execute
326 time = 1;
327
328 float distFactor = 1;
329 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
330 {
331 distFactor = Math.InverseLerp(pSettings.m_RangeMax,pSettings.m_RangeFull,distanceToTemperatureSource);
332 distFactor = Math.Max(distFactor, 0.0);
333 }
334
335 TemperatureDataInterpolated dta = new TemperatureDataInterpolated(tempTarget,ETemperatureAccessTypes.ACCESS_UTS,time,pSettings.m_TemperatureItemCoef * distFactor);
336
337 if (nearestEntity.GetInventory())
338 {
339 UpdateVicinityTemperatureRecursive(nearestEntity,dta);
340 }
341 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
342 {
343 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
344
345 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !nearestEntity.IsFreezeThawProgressFinished()) //ignoring insignificant increments
346 nearestEntity.SetTemperatureEx(dta);
347 else
348 nearestEntity.RefreshTemperatureAccess(dta);
349 }
350 }
351 }
352 }
353
354 protected void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef = 1.0)
355 {
356 float heatPermCoef = heatPermeabilityCoef;
357 heatPermCoef *= ent.GetHeatPermeabilityCoef();
358 dta.m_HeatPermeabilityCoef = heatPermCoef;
359
360 //handle temperature of this entity
361 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
362 {
363 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
364 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !ent.IsFreezeThawProgressFinished()) //ignoring insignificant increments
365 ent.SetTemperatureEx(dta);
366 else
367 ent.RefreshTemperatureAccess(dta);
368 }
369
370 // go through any attachments and cargo, recursive
371 int inventoryAttCount = ent.GetInventory().AttachmentCount();
372 if (inventoryAttCount > 0)
373 {
374 EntityAI attachmentEnt;
375 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
376 {
377 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
378 {
379 UpdateVicinityTemperatureRecursive(attachmentEnt,dta,heatPermCoef);
380 }
381 }
382 }
383
384 if (ent.GetInventory().GetCargo())
385 {
386 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
387 if (inventoryItemCount > 0)
388 {
389 EntityAI cargoEnt;
390 for (int j = 0; j < inventoryItemCount; ++j)
391 {
392 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
393 {
394 UpdateVicinityTemperatureRecursive(cargoEnt,dta,heatPermCoef);
395 }
396 }
397 }
398 }
399 }
400
401 override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
402 {
403 resultValues.m_TemperatureItem = pSettings.m_TemperatureItemCap;
404 resultValues.m_TemperatureHeatcomfort = pSettings.m_TemperatureCap;
405
406 array<Object> nearestObjects = new array<Object>();
407
408 vector pos = pSettings.m_Position;
409 if (pSettings.m_Parent != null)
410 pos = pSettings.m_Parent.GetPosition();
411
412 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
413 if (nearestObjects.Count() > 0)
414 {
415 DryItemsInVicinity(pSettings, pos, nearestObjects);
416 WarmAndCoolItemsInVicinity(pSettings, pos, nearestObjects);
417 }
418 }
419
422 {
423 array<Object> nearestObjects = new array<Object>();
424
425 vector pos = pSettings.m_Position;
426 if (pSettings.m_Parent != null)
427 pos = pSettings.m_Parent.GetPosition();
428
429 GetGame().GetObjectsAtPosition(pos, pSettings.m_RangeMax, nearestObjects, null);
430
431 DryItemsInVicinity(pSettings, pos, nearestObjects);
432 }
433}
434
435class UniversalTemperatureSourceLambdaConstant : UniversalTemperatureSourceLambdaBaseImpl {}
437{
439 {
440 m_AffectsPlayer = false;
441 }
442}
443
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.