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

◆ WarmAndCoolItemsInVicinity()

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

dist factor minimum should be at 0

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

258{
259 override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
260 {
261 float distanceToTemperatureSource;
262
263 foreach (Object nearestObject : nearestObjects)
264 {
265 ItemBase nearestItem = ItemBase.Cast(nearestObject);
266 ItemBase temperatureSource = ItemBase.Cast(pSettings.m_Parent);
267
269 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
270 {
271 distanceToTemperatureSource = vector.Distance(nearestItem.GetPosition(), position);
272 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.001);
273 distanceToTemperatureSource = 1 / distanceToTemperatureSource;
274 distanceToTemperatureSource = Math.Clamp(distanceToTemperatureSource, 0.0, 1.0);
275
276 float dryValue = 0;
277
278 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
279 {
280 dryValue = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) * pSettings.m_ItemDryModifier * distanceToTemperatureSource;
281 Math.Clamp(dryValue, nearestItem.GetWetMin(), nearestItem.GetWetMax());
282 nearestItem.AddWet(dryValue);
283 }
284
285 array<EntityAI> cargoEntities = new array<EntityAI>();
286 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
287 foreach (EntityAI cargoEntity : cargoEntities)
288 {
289 ItemBase cargoItem = ItemBase.Cast(cargoEntity);
290 if (cargoItem)
291 {
292 dryValue = 0;
293 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
294 {
295 dryValue = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) * pSettings.m_ItemDryModifier * distanceToTemperatureSource;
296 Math.Clamp(dryValue, cargoItem.GetWetMin(), cargoItem.GetWetMax());
297 cargoItem.AddWet(dryValue);
298 }
299 }
300 }
301 }
302 }
303 }
304
305 override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
306 {
307 float distanceToTemperatureSource;
308 float tempTarget = pSettings.m_TemperatureItemCap;
309 EntityAI nearestEntity;
310
311 foreach (Object nearestObject : nearestObjects)
312 {
313 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
314 {
315 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
316
317 distanceToTemperatureSource = vector.Distance(nearestEntity.GetPosition(), position);
318 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1);
319
320 float time = m_ExecuteInterval;
321 if (m_ExecuteInterval == -1) //bogus time in the first execute
322 time = 1;
323
324 float distFactor = 1;
325 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
326 {
327 distFactor = Math.InverseLerp(pSettings.m_RangeMax,pSettings.m_RangeFull,distanceToTemperatureSource);
328 distFactor = Math.Max(distFactor, 0.0);
329 }
330
331 TemperatureDataInterpolated dta = new TemperatureDataInterpolated(tempTarget,ETemperatureAccessTypes.ACCESS_UTS,time,pSettings.m_TemperatureItemCoef * distFactor);
332
333 if (nearestEntity.GetInventory())
334 {
335 UpdateVicinityTemperatureRecursive(nearestEntity,dta);
336 }
337 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
338 {
339 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
340
341 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !nearestEntity.IsFreezeThawProgressFinished()) //ignoring insignificant increments
342 nearestEntity.SetTemperatureEx(dta);
343 else
344 nearestEntity.RefreshTemperatureAccess(dta);
345 }
346 }
347 }
348 }
349
350 protected void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef = 1.0)
351 {
352 float heatPermCoef = heatPermeabilityCoef;
353 heatPermCoef *= ent.GetHeatPermeabilityCoef();
354 dta.m_HeatPermeabilityCoef = heatPermCoef;
355
356 //handle temperature of this entity
357 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
358 {
359 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
360 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !ent.IsFreezeThawProgressFinished()) //ignoring insignificant increments
361 ent.SetTemperatureEx(dta);
362 else
363 ent.RefreshTemperatureAccess(dta);
364 }
365
366 // go through any attachments and cargo, recursive
367 int inventoryAttCount = ent.GetInventory().AttachmentCount();
368 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
369 {
370 EntityAI attachmentEnt;
371 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
372 {
373 UpdateVicinityTemperatureRecursive(attachmentEnt,dta,heatPermCoef);
374 }
375 }
376
377 CargoBase cargo = ent.GetInventory().GetCargo();
378 if (cargo)
379 {
380 int inventoryItemCount = cargo.GetItemCount();
381 for (int j = 0; j < inventoryItemCount; ++j)
382 {
383 EntityAI cargoEnt;
384 if (Class.CastTo(cargoEnt, cargo.GetItem(j)))
385 {
386 UpdateVicinityTemperatureRecursive(cargoEnt, dta, heatPermCoef);
387 }
388 }
389 }
390 }
391
392 override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
393 {
394 resultValues.m_TemperatureItem = pSettings.m_TemperatureItemCap;
395 resultValues.m_TemperatureHeatcomfort = pSettings.m_TemperatureCap;
396
397 vector pos = pSettings.m_Position;
398 if (pSettings.m_Parent != null)
399 pos = pSettings.m_Parent.GetPosition();
400
401 // Define half-size (range)
402 float halfRange = pSettings.m_RangeMax;
403
404 // Calculate min and max positions of the box
405 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
406 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
407
408 array<EntityAI> nearestObjects = {};
409 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
410
411 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
412 {
413 EntityAI entity = nearestObjects[i];
414 if (entity)
415 {
416 vector objPos = entity.GetPosition();
417 float distance = vector.Distance(objPos, pos);
418 if (distance > pSettings.m_RangeMax)
419 nearestObjects.Remove(i);
420 }
421 }
422
423 if (nearestObjects.Count() > 0)
424 {
425 DryItemsInVicinity(pSettings, pos, nearestObjects);
426 WarmAndCoolItemsInVicinity(pSettings, pos, nearestObjects);
427 }
428 }
429
432 {
433 vector pos = pSettings.m_Position;
434 if (pSettings.m_Parent != null)
435 pos = pSettings.m_Parent.GetPosition();
436
437 // Define half-size (range)
438 float halfRange = pSettings.m_RangeMax;
439
440 // Calculate min and max positions of the box
441 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
442 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
443
444 array<EntityAI> nearestObjects = {};
445 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
446
447 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
448 {
449 EntityAI entity = nearestObjects[i];
450 if (entity)
451 {
452 vector objPos = entity.GetPosition();
453 float distance = vector.Distance(objPos, pos);
454 if (distance > pSettings.m_RangeMax)
455 nearestObjects.Remove(i);
456 }
457 }
458
459 DryItemsInVicinity(pSettings, pos, nearestObjects);
460 }
461}
462
463class UniversalTemperatureSourceLambdaConstant : UniversalTemperatureSourceLambdaBaseImpl {}
465{
467 {
468 m_AffectsPlayer = false;
469 }
470}
471
void DayZPlayerUtils()
cannot be instantiated
Определения DayZPlayerUtils.c:465
QueryFlags
Определения DayZPlayerUtils.c:2
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< EntityAI > nearestObjects)
override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< EntityAI > nearestObjects)
void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef=1.0)
UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine()
override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
represents base for cargo storage for entities
Определения Cargo.c:7
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения 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:19
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_ItemDryModifier
maximum range where the receiver can get some temperature
Определения UniversalTemperatureSource.c:9
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:119
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
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
Определения 3_Game/DayZ/constants.c:943
const float STATE_DAMP
Определения 3_Game/DayZ/constants.c:878
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
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.