3 const float RAIN_LIMIT_LOW = 0.05;
5 const float WATER_LEVEL_HIGH = 1.5;
6 const float WATER_LEVEL_MID = 1.2;
7 const float WATER_LEVEL_LOW = 0.5;
8 const float WATER_LEVEL_NONE = 0.15;
10 protected float m_WetDryTick;
11 protected float m_ItemsWetnessMax;
12 protected float m_RoofCheckTimer;
16 protected float m_PlayerHeightPos;
17 protected float m_PlayerSpeed;
18 protected float m_PlayerTemperature;
19 protected float m_PlayerHeat;
20 protected float m_HeatComfort;
23 protected float m_Rain = 0;
24 protected float m_Wind = 0;
25 protected float m_Fog = 0;
26 protected float m_DayOrNight = 0;
27 protected float m_Clouds = 0;
28 protected float m_EnvironmentTemperature = 0;
29 protected float m_Time = 0;
30 protected string m_SurfaceType;
33 protected float m_WaterLevel;
34 protected bool m_IsUnderRoof;
35 private bool m_IsUnderRoofBuilding;
36 protected bool m_IsInWater;
37 protected bool m_IsTempSet;
39 protected float m_HeatSourceTemp;
40 protected float m_HeatBufferTimer;
51 protected ref SimpleMovingAverage<float> m_WindAverageBuffer;
53 protected bool m_HasTemperatureSources;
54 protected float m_UTSAverageTemperature;
56 protected ref SimpleMovingAverage<float> m_UTSAverageTemperatureBuffer;
61 bool m_DebugLogDryWet =
false;
74 m_RoofCheckTimer = 0.0;
78 m_IsUnderRoof =
false;
80 m_SurfaceType =
"cp_dirt";
82 m_HeatBufferTimer = 0.0;
84 m_WindAverageBuffer =
new SimpleMovingAverage<float>(30, 0.5);
86 m_UTSAverageTemperature = 0.0;
88 m_UTSAverageTemperatureBuffer =
new SimpleMovingAverage<float>(10, 0);
156 void Update(
float pDelta)
160 m_RoofCheckTimer += pDelta;
162 if ( m_RoofCheckTimer >=
GameConstants.ENVIRO_TICK_ROOF_RC_CHECK )
164 if ( !IsInsideBuilding() )
167 m_RoofCheckTimer = 0;
177 CheckWaterContact(m_WaterLevel);
178 CollectAndSetPlayerData();
179 CollectAndSetEnvironmentData();
180 GatherTemperatureSources();
182 ProcessTemperatureSources();
188 if ( m_WetDryTick >=
GameConstants.ENVIRO_TICKS_TO_WETNESS_CALCULATION )
190 if ( IsWaterContact() )
192 ProcessWetnessByWaterLevel(m_WaterLevel);
194 else if ( IsRaining() && !IsInsideBuilding() && !IsUnderRoof() && !IsInsideVehicle() )
196 ProcessWetnessByRain();
200 ProcessItemsDryness();
214 m_ItemsWetnessMax = 0;
220 bool IsTemperatureSet()
226 void AddToEnvironmentTemperature(
float pTemperature);
229 protected float GetPlayerHeat()
237 return m_IsUnderRoof;
240 protected bool IsWaterContact()
245 bool IsInsideBuilding()
250 protected bool IsInsideVehicle()
255 private bool IsUnderRoofBuilding()
257 return m_IsUnderRoofBuilding;
260 protected bool IsRaining()
262 return m_Rain > RAIN_LIMIT_LOW;
266 protected void CheckUnderRoof()
269 if (IsInsideVehicle())
271 m_IsUnderRoof =
false;
272 m_IsUnderRoofBuilding =
false;
277 vector hitPosition, hitNormal;
279 vector to = from +
"0 25 0";
283 m_IsUnderRoof =
DayZPhysics.RayCastBullet(from, to, collisionLayerMask,
null, hitObject, hitPosition, hitNormal, hitFraction);
285 m_IsUnderRoofBuilding = hitObject && hitObject.IsInherited(
House);
288 protected void CheckWaterContact(out
float pWaterLevel)
296 pWaterLevel = WATER_LEVEL_MID;
298 pWaterLevel = WATER_LEVEL_HIGH;
304 if (IsUnderRoofBuilding())
315 switch ( liquidType )
320 pWaterLevel =
m_Player.GetCurrentWaterLevel();
329 m_SurfaceType = surfType;
334 float GetTemperatureHeightCorrection()
336 float temperature_reduction =
Math.Max(0, (m_PlayerHeightPos *
GameConstants.ENVIRO_TEMPERATURE_HEIGHT_REDUCTION));
337 return temperature_reduction;
340 float GetWindModifierPerSurface()
342 if (IsUnderRoofBuilding())
345 return g_Game.ConfigGetFloat(
"CfgSurfaces " + m_SurfaceType +
" windModifier");
348 float GetTemperature()
350 return m_EnvironmentTemperature;
354 protected float GetEnvironmentTemperature()
357 temperature =
g_Game.GetMission().GetWorldData().GetBaseEnvTemperature();
358 temperature +=
Math.AbsFloat(temperature * m_Clouds *
GameConstants.ENVIRO_CLOUDS_TEMP_EFFECT);
360 if (IsWaterContact())
362 temperature -=
Math.AbsFloat(temperature *
GameConstants.ENVIRO_WATER_TEMPERATURE_COEF);
365 if (IsInsideBuilding() || m_IsUnderRoofBuilding)
367 temperature +=
Math.AbsFloat(temperature *
GameConstants.ENVIRO_TEMPERATURE_INSIDE_COEF);
369 else if (IsInsideVehicle())
371 temperature +=
Math.AbsFloat(temperature *
GameConstants.ENVIRO_TEMPERATURE_INSIDE_VEHICLE_COEF);
373 else if (IsUnderRoof() && !m_IsUnderRoofBuilding)
375 temperature +=
Math.AbsFloat(temperature *
GameConstants.ENVIRO_TEMPERATURE_UNDERROOF_COEF);
376 temperature -=
GameConstants.ENVIRO_TEMPERATURE_WIND_COEF * GetWindModifierPerSurface() * m_Wind;
380 temperature -=
GameConstants.ENVIRO_TEMPERATURE_WIND_COEF * GetWindModifierPerSurface() * m_Wind;
381 temperature -=
Math.AbsFloat(temperature * m_Fog *
GameConstants.ENVIRO_FOG_TEMP_EFFECT);
382 temperature -= GetTemperatureHeightCorrection();
386 if (
Math.AbsFloat(m_UTSAverageTemperature) > 0.001)
388 temperature += m_UTSAverageTemperature;
398 if ( IsWaterContact() )
401 if (m_WaterLevel >= WATER_LEVEL_HIGH)
405 else if (m_WaterLevel >= WATER_LEVEL_MID && m_WaterLevel < WATER_LEVEL_HIGH)
409 else if (m_WaterLevel >= WATER_LEVEL_LOW && m_WaterLevel < WATER_LEVEL_MID)
413 else if (m_WaterLevel >= WATER_LEVEL_NONE && m_WaterLevel < WATER_LEVEL_LOW)
418 else if (IsRaining() && !IsInsideBuilding() && !IsUnderRoof() && !IsInsideVehicle())
426 float tempEffect =
Math.Max(m_PlayerHeat + GetEnvironmentTemperature(), 1.0);
428 float weatherEffect = ((1 - (m_Fog *
GameConstants.ENVIRO_FOG_DRY_EFFECT))) * (1 - (m_Clouds *
GameConstants.ENVIRO_CLOUD_DRY_EFFECT));
429 if (weatherEffect <= 0)
434 wetDelta = -(
GameConstants.ENVIRO_DRY_INCREMENT * weatherEffect * tempEffect);
435 if (!IsInsideBuilding())
446 protected void CollectAndSetPlayerData()
449 m_PlayerHeightPos = playerPos[1];
454 m_PlayerSpeed = hcm.GetCurrentMovementSpeed();
457 m_PlayerHeat = GetPlayerHeat();
461 protected void CollectAndSetEnvironmentData()
464 m_Rain = weather.GetRain().GetActual();
465 m_DayOrNight =
g_Game.GetWorld().GetSunOrMoon();
466 m_Fog = weather.GetFog().GetActual();
467 m_Clouds = weather.GetOvercast().GetActual();
468 m_Wind = m_WindAverageBuffer.Add(weather.GetWindSpeed() / weather.GetWindMaximumSpeed());
470 SetEnvironmentTemperature();
473 void SetEnvironmentTemperature()
476 m_EnvironmentTemperature = GetEnvironmentTemperature();
479 protected void ProcessWetnessByRain()
481 ProcessItemsWetness(m_SlotIdsComplete);
484 protected void ProcessWetnessByWaterLevel(
float pWaterLevel)
487 if (pWaterLevel >= WATER_LEVEL_HIGH)
490 ProcessItemsWetness(m_SlotIdsComplete);
492 else if (pWaterLevel >= WATER_LEVEL_MID && pWaterLevel < WATER_LEVEL_HIGH)
495 ProcessItemsWetness(m_SlotIdsUpper);
497 else if (pWaterLevel >= WATER_LEVEL_LOW && pWaterLevel < WATER_LEVEL_MID)
500 ProcessItemsWetness(m_SlotIdsBottom);
502 else if (pWaterLevel >= WATER_LEVEL_NONE && pWaterLevel < WATER_LEVEL_LOW)
505 ProcessItemsWetness(m_SlotIdsLower);
510 protected void ProcessItemsWetness(
array<int> pSlotIds)
514 int playerAttachmentCount =
m_Player.GetInventory().AttachmentCount();
516 LogDryWetProcess(
string.Format(
"Environment :: ProcessItemsWetness (update interval=%1s)",
GameConstants.ENVIRO_TICK_RATE));
517 for (
int attIdx = 0; attIdx < playerAttachmentCount; ++attIdx)
519 attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
520 if (attachment.IsItemBase())
522 int attachmentSlotsCount = attachment.GetInventory().GetSlotIdCount();
523 for (
int attachmentSlotId = 0; attachmentSlotId < attachmentSlotsCount; ++attachmentSlotId)
525 int attachmentSlot = attachment.GetInventory().GetSlotId(attachmentSlotId);
526 for (
int i = 0; i < pSlotIds.Count(); ++i)
528 if (attachmentSlot == pSlotIds.Get(i))
530 ApplyWetnessToItem(
ItemBase.Cast(attachment));
539 ApplyWetnessToItem(
m_Player.GetItemInHands());
541 LogDryWetProcess(
"==========");
545 protected void ProcessItemsDryness()
550 int attCount =
m_Player.GetInventory().AttachmentCount();
552 LogDryWetProcess(
string.Format(
"Environment :: ProcessItemsDryness (update interval=%1s)",
GameConstants.ENVIRO_TICK_RATE));
553 EnvironmentDrynessData drynessData =
new EnvironmentDrynessData();
554 drynessData.m_UseTemperatureSources = m_HasTemperatureSources;
556 if (m_HasTemperatureSources)
559 distance =
Math.Max(distance, 0.1);
560 drynessData.m_TemperatureSourceDistance = distance;
561 LogDryWetProcess(
string.Format(
"distance to heatsource: %1 m", distance));
564 for (
int attIdx = 0; attIdx < attCount; attIdx++)
566 attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
567 if (attachment && attachment.IsItemBase())
571 ApplyDrynessToItemEx(item, drynessData);
577 ApplyDrynessToItemEx(
m_Player.GetItemInHands(), drynessData);
580 LogDryWetProcess(
"==========");
583 protected void ApplyWetnessToItem(
ItemBase pItem)
588 bool isParentWet =
false;
589 bool parentContainsLiquid =
false;
592 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
603 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
604 parentContainsLiquid =
true;
609 if ((pItem.GetWet() > m_ItemsWetnessMax) && (parent ==
m_Player))
610 m_ItemsWetnessMax = pItem.GetWet();
614 if (isParentWet || parentContainsLiquid)
616 float soakingCoef = 0;
617 if (parentContainsLiquid)
619 soakingCoef = pItem.GetSoakingIncrement(
"parentWithLiquid");
620 LogDryWetProcess(
string.Format(
"%1 (soak coef=%2/s, current wetness=%3) [parent contains liquid]", pItem.GetDisplayName(), soakingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem !=
null);
622 else if (isParentWet && parentItem)
624 if (pItem.GetWet() < parentItem.GetWet())
626 soakingCoef = pItem.GetSoakingIncrement(
"wetParent");
627 LogDryWetProcess(
string.Format(
"%1 (soak coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), soakingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem !=
null);
632 soakingCoef = GetWetDelta();
633 LogDryWetProcess(
string.Format(
"%1 (soak coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), soakingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem !=
null);
636 pItem.AddWet(soakingCoef);
637 pItem.AddTemperature(
GameConstants.ENVIRO_TICK_RATE *
GameConstants.TEMPERATURE_RATE_COOLING_PLAYER * pItem.GetSoakingIncrement(
"wetParent"));
639 if (pItem.GetInventory().GetCargo())
641 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
642 for (
int i = 0; i < inItemCount; i++)
645 if (
Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
646 ApplyWetnessToItem(inItem);
650 int attCount = pItem.GetInventory().AttachmentCount();
653 for (
int attIdx = 0; attIdx < attCount; attIdx++)
655 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
658 ApplyWetnessToItem(itemAtt);
665 protected void ApplyDrynessToItem(
ItemBase pItem)
667 EnvironmentDrynessData drynessData =
new EnvironmentDrynessData();
668 ApplyDrynessToItemEx(pItem, drynessData);
671 protected void ApplyDrynessToItemEx(
ItemBase pItem, EnvironmentDrynessData pDrynessData)
675 float dryingIncrement = pItem.GetDryingIncrement(
"player");
676 if (pDrynessData.m_UseTemperatureSources)
677 dryingIncrement = pItem.GetDryingIncrement(
"playerHeatSource");
680 bool isParentWet =
false;
681 bool parentContainsLiquid =
false;
684 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
695 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
696 parentContainsLiquid =
true;
699 if ((pItem.GetWet() > m_ItemsWetnessMax) && (parent ==
m_Player))
701 m_ItemsWetnessMax = pItem.GetWet();
706 float dryingCoef = 0;
708 if (!isParentWet && !parentContainsLiquid)
711 dryingCoef = (-1 *
GameConstants.ENVIRO_TICK_RATE * dryingIncrement) / pDrynessData.m_TemperatureSourceDistance;
714 LogDryWetProcess(
string.Format(
"%1 (dry coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), dryingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem !=
null);
715 pItem.AddWet(dryingCoef);
718 if (pItem.GetInventory().GetCargo())
720 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
721 for (
int i = 0; i < inItemCount; i++)
724 if (
Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
725 ApplyDrynessToItemEx(inItem, pDrynessData);
729 int attCount = pItem.GetInventory().AttachmentCount();
732 for (
int attIdx = 0; attIdx < attCount; attIdx++)
734 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
736 if (
ItemBase.CastTo(itemAtt, attachment))
737 ApplyDrynessToItemEx(itemAtt, pDrynessData);
744 if (parentContainsLiquid)
747 dryingCoef = (
GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement(
"parentWithLiquid")) / pDrynessData.m_TemperatureSourceDistance;
748 LogDryWetProcess(
string.Format(
"%1 (dry coef=%2/s, current wetness=%3) [parent contains liquid]", pItem.GetDisplayName(), dryingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem !=
null);
749 pItem.AddWet(dryingCoef);
755 if (pItem.GetWet() < parentItem.GetWet())
758 dryingCoef = (
GameConstants.ENVIRO_TICK_RATE * pItem.GetSoakingIncrement(
"wetParent")) / pDrynessData.m_TemperatureSourceDistance;
759 LogDryWetProcess(
string.Format(
"%1 (dry coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), dryingCoef /
GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem !=
null);
760 pItem.AddWet(dryingCoef);
770 protected void ProcessItemsHeat()
772 float hcHead, hcBody, hcFeet;
773 float hHead, hBody, hFeet;
775 float heatComfortAvg;
778 BodyPartHeatProperties(m_HeadParts,
GameConstants.ENVIRO_HEATCOMFORT_HEADPARTS_WEIGHT, hcHead, hHead);
779 BodyPartHeatProperties(m_BodyParts,
GameConstants.ENVIRO_HEATCOMFORT_BODYPARTS_WEIGHT, hcBody, hBody);
780 BodyPartHeatProperties(m_FeetParts,
GameConstants.ENVIRO_HEATCOMFORT_FEETPARTS_WEIGHT, hcFeet, hFeet);
782 heatComfortAvg = (hcHead + hcBody + hcFeet) / 3;
783 heatAvg = (hHead + hBody + hFeet) / 3;
784 heatAvg = heatAvg *
GameConstants.ENVIRO_ITEM_HEAT_TRANSFER_COEF;
787 float applicableHB = 0.0;
788 if (m_UTSAverageTemperature < 0.001)
790 applicableHB =
m_Player.GetStatHeatBuffer().Get() / 30.0;
791 if (applicableHB > 0.0)
793 if (m_HeatBufferTimer > 1.0)
795 m_Player.GetStatHeatBuffer().Add(
Math.Min(EnvTempToCoef(m_EnvironmentTemperature), -0.1) *
GameConstants.ENVIRO_PLAYER_HEATBUFFER_DECREASE);
799 m_HeatBufferTimer +=
GameConstants.ENVIRO_PLAYER_HEATBUFFER_TICK;
804 m_HeatBufferTimer = 0.0;
809 applicableHB =
m_Player.GetStatHeatBuffer().Get() / 30.0;
810 if (m_HeatComfort >
PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING)
813 m_HeatBufferTimer = 0.0;
817 m_HeatBufferTimer = 0.0;
821 m_HeatComfort = (heatComfortAvg + heatAvg + (GetPlayerHeat() / 100)) + EnvTempToCoef(m_EnvironmentTemperature);
822 if ((m_HeatComfort + applicableHB) < (
PlayerConstants.THRESHOLD_HEAT_COMFORT_PLUS_WARNING - 0.01))
824 m_HeatComfort += applicableHB;
828 if (m_HeatComfort <= (
PlayerConstants.THRESHOLD_HEAT_COMFORT_PLUS_WARNING - 0.01))
830 m_HeatComfort =
PlayerConstants.THRESHOLD_HEAT_COMFORT_PLUS_WARNING - 0.01;
834 m_HeatComfort =
Math.Clamp(m_HeatComfort,
m_Player.GetStatHeatComfort().GetMin(),
m_Player.GetStatHeatComfort().GetMax());
836 m_Player.GetStatHeatComfort().Set(m_HeatComfort);
840 protected bool OverridenHeatComfort(out
float value);
842 protected float EnvTempToCoef(
float pTemp)
858 protected void BodyPartHeatProperties(
array<int> pBodyPartIds,
float pCoef, out
float pHeatComfort, out
float pHeat)
866 attCount =
m_Player.GetInventory().AttachmentCount();
868 for (
int attIdx = 0; attIdx < attCount; attIdx++)
870 attachment =
m_Player.GetInventory().GetAttachmentFromIndex(attIdx);
871 if (attachment.IsClothing())
874 int attachmentSlot = attachment.GetInventory().GetSlotId(0);
877 for (
int i = 0; i < pBodyPartIds.Count(); i++)
879 if (attachmentSlot == pBodyPartIds.Get(i))
881 float heatIsoMult = 1.0;
884 heatIsoMult =
GameConstants.ENVIRO_HEATISOLATION_VEST_WEIGHT;
889 heatIsoMult =
GameConstants.ENVIRO_HEATISOLATION_BACK_WEIGHT;
892 pHeatComfort += heatIsoMult * MiscGameplayFunctions.GetCurrentItemHeatIsolation(item);
895 int inAttCount = item.GetInventory().AttachmentCount();
898 for (
int inAttIdx = 0; inAttIdx < inAttCount; inAttIdx++)
900 EntityAI inAttachment = item.GetInventory().GetAttachmentFromIndex(inAttIdx);
904 pHeat += itemAtt.GetTemperature();
908 if (item.GetInventory().GetCargo())
910 int inItemCount = item.GetInventory().GetCargo().GetItemCount();
912 for (
int j = 0; j < inItemCount; j++)
915 if (
Class.CastTo(inItem, item.GetInventory().GetCargo().GetItem(j)))
917 pHeat += inItem.GetTemperature();
926 pHeatComfort = (pHeatComfort / pBodyPartIds.Count()) * pCoef;
927 pHeat = (pHeat / pBodyPartIds.Count()) * pCoef;
930 protected void GatherTemperatureSources()
932 m_UTemperatureSources.Clear();
937 foreach (
Object nearestObject : nearestObjects)
940 if (ent && ent.IsUniversalTemperatureSource() && ent !=
m_Player)
943 if (
vector.DistanceSq(
m_Player.GetPosition(), ent.GetPosition()) >
Math.SqrFloat(ent.GetUniversalTemperatureSource().GetMaxRange()))
946 m_UTemperatureSources.Insert(ent.GetUniversalTemperatureSource());
950 if (
m_Player.GetItemInHands() &&
m_Player.GetItemInHands().IsUniversalTemperatureSource())
951 m_UTemperatureSources.Insert(
m_Player.GetItemInHands().GetUniversalTemperatureSource());
954 protected void ProcessTemperatureSources()
956 if (m_UTemperatureSources.Count() == 0)
958 m_HasTemperatureSources =
false;
959 m_UTSAverageTemperature = m_UTSAverageTemperatureBuffer.Add(0);
966 foreach (UTemperatureSource tempSource : m_UTemperatureSources)
967 utsTemperatures.Insert(CalcTemperatureFromTemperatureSource(tempSource));
969 float min = MiscGameplayFunctions.GetMinValue(utsTemperatures);
970 float max = MiscGameplayFunctions.GetMaxValue(utsTemperatures);
972 if (max > 0 && min < 0)
975 m_UTSAverageTemperature = m_UTSAverageTemperatureBuffer.Add((max + min) * 0.5);
979 m_UTSAverageTemperature = m_UTSAverageTemperatureBuffer.Add(max);
982 m_HasTemperatureSources =
true;
985 float GetUniversalSourcesTemperageAverage()
987 return m_UTSAverageTemperature;
990 float CalcTemperatureFromTemperatureSource(notnull UTemperatureSource uts)
992 float distance =
vector.Distance(
m_Player.GetPosition(), uts.GetPosition());
993 distance =
Math.Max(distance, 0.1);
994 float temperature = 0;
999 if (distance > uts.GetFullRange())
1001 float distFactor = 1 - (distance / uts.GetMaxRange());
1002 distFactor =
Math.Max(distFactor, 0.0);
1003 temperature = uts.GetTemperature() * distFactor;
1010 temperature = uts.GetTemperature();
1019 #ifdef DIAG_DEVELOPER
1020 EnvDebugData GetEnvDebugData()
1022 EnvDebugData data =
new EnvDebugData();
1027 void ShowEnvDebugPlayerInfo(
bool enabled)
1029 EnvDebugData data = GetEnvDebugData();
1030 DisplayEnvDebugPlayerInfo(enabled, data);
1033 static void DisplayEnvDebugPlayerInfo(
bool enabled, EnvDebugData data)
1043 DbgUI.Text(
string.Format(
"Heat comfort: %1", data.m_PlayerData.m_HeatComfort));
1044 DbgUI.Text(
string.Format(
"Inside: %1 (%2)", data.m_PlayerData.m_Inside, data.m_PlayerData.m_Surface));
1045 DbgUI.Text(
string.Format(
"Under roof: %1 (%2)", data.m_PlayerData.m_UnderRoof, data.m_PlayerData.m_UnderRoofTimer));
1046 if ( data.m_PlayerData.m_WaterLevel > 0 )
1048 DbgUI.Text(
string.Format(
"Water Level: %1", data.m_PlayerData.m_WaterLevel));
1057 DbgUI.Text(
string.Format(
"Env temperature (base): %1", data.m_MiscData.m_TemperatureBase));
1058 DbgUI.Text(
string.Format(
"Env temperature (modfied): %1", data.m_MiscData.m_TemperatureModified));
1059 DbgUI.Text(
string.Format(
"Wind: %1 (x%2)", data.m_WeatherData.m_Wind, data.m_WeatherData.m_WindModifier));
1060 DbgUI.Text(
string.Format(
"Rain: %1", data.m_WeatherData.m_Rain));
1061 DbgUI.Text(
string.Format(
"Day/Night (1/0): %1", data.m_MiscData.m_DayOrNight));
1062 DbgUI.Text(
string.Format(
"Fog: %1", data.m_WeatherData.m_Fog));
1063 DbgUI.Text(
string.Format(
"Clouds: %1", data.m_WeatherData.m_Clouds));
1064 DbgUI.Text(
string.Format(
"Height: %1", data.m_MiscData.m_Height));
1065 DbgUI.Text(
string.Format(
"Wet delta: %1", data.m_MiscData.m_WetDelta));
1070 void FillDebugWeatherData(EnvDebugWeatherData data)
1072 data.m_Wind = m_Wind;
1073 data.m_WindModifier = GetWindModifierPerSurface();
1074 data.m_Rain = m_Rain;
1076 data.m_Clouds = m_Clouds;
1080 string GetDebugMessage()
1083 message +=
"Player stats";
1084 message +=
"\nHeat comfort: " + m_HeatComfort.ToString();
1085 message +=
"\nInside: " + IsInsideBuilding().ToString() +
" (" +
m_Player.GetSurfaceType() +
")";
1086 message +=
"\nUnder roof: " + m_IsUnderRoof.ToString() +
" (" + GetNextRoofCheck() +
")";
1087 if (IsWaterContact() && m_WaterLevel > WATER_LEVEL_NONE)
1089 message +=
"\nWater Level: " + m_WaterLevel;
1092 message +=
"\n\nWeather stats";
1093 message +=
"\nEnv temperature (base): " +
g_Game.GetMission().GetWorldData().GetBaseEnvTemperature().ToString();
1094 message +=
"\nEnv temperature (modified): " + m_EnvironmentTemperature.ToString();
1095 message +=
"\nWind: " + m_Wind.ToString() +
" (x" + GetWindModifierPerSurface() +
")";
1096 message +=
"\nRain: " + m_Rain.ToString();
1097 message +=
"\nDay/Night (1/0): " + m_DayOrNight.ToString();
1098 message +=
"\nFog: " + m_Fog.ToString();
1099 message +=
"\nClouds: " + m_Clouds.ToString();
1100 message +=
"\nHeight: " + GetTemperatureHeightCorrection().ToString();
1101 message +=
"\nWet delta: " + GetWetDelta().ToString();
1106 int GetNextRoofCheck()
1108 return (
GameConstants.ENVIRO_TICK_ROOF_RC_CHECK - m_RoofCheckTimer) + 1;
1111 float GetWaterLevel()
1113 if (IsWaterContact() && m_WaterLevel > WATER_LEVEL_NONE)
1115 return m_WaterLevel;
1123 float GetDayOrNight()
1125 return m_DayOrNight;
1128 private void LogDryWetProcess(
string message,
bool indented =
false)
1130 #ifdef DIAG_DEVELOPER
1131 if (m_DebugLogDryWet)
1133 string indentation =
"";
1135 indentation =
"|--";
1137 Debug.Log(
string.Format(
"%1 %2", indentation, message));
1143 class EnvironmentDrynessData
1149 #ifdef DIAG_DEVELOPER
1150 class EnvDebugPlayerData :
Param
1152 float m_HeatComfort;
1156 int m_UnderRoofTimer;
1161 m_HeatComfort = player.GetStatHeatComfort().Get();
1162 m_Inside = env.IsInsideBuilding();
1164 m_UnderRoof = env.IsUnderRoof();
1165 m_UnderRoofTimer = env.GetNextRoofCheck();
1166 m_WaterLevel = env.GetWaterLevel();
1172 ctx.Write(m_HeatComfort) && ctx.Write(m_Inside) && ctx.Write(
m_Surface) && ctx.Write(m_UnderRoof) && ctx.Write(m_UnderRoofTimer) && ctx.Write(m_WaterLevel));
1177 return ctx.Read(m_HeatComfort) && ctx.Read(m_Inside) && ctx.Read(
m_Surface) && ctx.Read(m_UnderRoof) && ctx.Read(m_UnderRoofTimer) && ctx.Read(m_WaterLevel);
1181 class EnvDebugMiscData :
Param
1183 float m_TemperatureBase;
1184 float m_TemperatureModified;
1191 m_TemperatureBase =
g_Game.GetMission().GetWorldData().GetBaseEnvTemperature();
1192 m_TemperatureModified = env.GetTemperature();
1193 m_DayOrNight = env.GetDayOrNight();
1194 m_Height = env.GetTemperatureHeightCorrection();
1195 m_WetDelta = env.GetWetDelta();
1200 return ctx.Write(m_TemperatureBase) && ctx.Write(m_TemperatureModified) && ctx.Write(m_DayOrNight) && ctx.Write(m_Height) && ctx.Write(m_WetDelta);
1205 return ctx.Read(m_TemperatureBase) && ctx.Read(m_TemperatureModified) && ctx.Read(m_DayOrNight) && ctx.Read(m_Height) && ctx.Read(m_WetDelta);
1209 class EnvDebugWeatherData :
Param
1212 float m_WindModifier;
1219 env.FillDebugWeatherData(
this);
1224 return ctx.Write(m_Wind) && ctx.Write(m_WindModifier) && ctx.Write(m_Rain) && ctx.Write(m_Fog) && ctx.Write(m_Clouds);
1229 return ctx.Read(m_Wind) && ctx.Read(m_WindModifier) && ctx.Read(m_Rain) && ctx.Read(m_Fog) && ctx.Read(m_Clouds);
1233 class EnvDebugData :
Param
1235 ref EnvDebugPlayerData m_PlayerData =
new EnvDebugPlayerData();
1236 ref EnvDebugMiscData m_MiscData =
new EnvDebugMiscData();
1237 ref EnvDebugWeatherData m_WeatherData =
new EnvDebugWeatherData();
1241 m_PlayerData.Synch(env, player);
1242 m_MiscData.Synch(env);
1243 m_WeatherData.Synch(env);
1248 return m_PlayerData.Serialize(ctx) && m_MiscData.Serialize(ctx) && m_WeatherData.Serialize(ctx);
1253 return m_PlayerData.Deserializer(ctx) && m_MiscData.Deserializer(ctx) && m_WeatherData.Deserializer(ctx);