DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
UniversalTemperatureSourceLambdaBaseImpl.c
См. документацию.
2{
3 override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
4 {
5 float distanceToTemperatureSource;
6
7 foreach (Object nearestObject : nearestObjects)
8 {
9 ItemBase nearestItem = ItemBase.Cast(nearestObject);
10
12 if (nearestItem && nearestItem.HasWetness() && nearestItem != pSettings.m_Parent && !nearestItem.IsInherited(Man) && !nearestItem.IsUniversalTemperatureSource())
13 {
14 distanceToTemperatureSource = vector.Distance(nearestItem.GetPosition(), position);
15 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.3); //min distance cannot be 0 (division by zero)
16
17 float dryModifier = 0;
18
19 if (nearestItem.GetWet() >= GameConstants.STATE_DAMP)
20 {
21 dryModifier = (-1 * m_ExecuteInterval * nearestItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
22 Math.Clamp(dryModifier, nearestItem.GetWetMin(), nearestItem.GetWetMax());
23 nearestItem.AddWet(dryModifier);
24 }
25
26 array<EntityAI> cargoEntities = new array<EntityAI>();
27 nearestItem.GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, cargoEntities);
28 foreach (EntityAI cargoEntity : cargoEntities)
29 {
30 ItemBase cargoItem = ItemBase.Cast(cargoEntity);
31 if (cargoItem)
32 {
33 dryModifier = 0;
34 if (cargoItem.GetWet() >= GameConstants.STATE_DAMP)
35 {
36 dryModifier = (-1 * m_ExecuteInterval * cargoItem.GetDryingIncrement("groundHeatSource")) / distanceToTemperatureSource;
37 Math.Clamp(dryModifier, cargoItem.GetWetMin(), cargoItem.GetWetMax());
38 cargoItem.AddWet(dryModifier);
39 }
40 }
41 }
42 }
43 }
44 }
45
46 override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array<EntityAI> nearestObjects)
47 {
48 float distanceToTemperatureSource;
49 float tempTarget = pSettings.m_TemperatureItemCap;
50 EntityAI nearestEntity;
51
52 foreach (Object nearestObject : nearestObjects)
53 {
54 if (Class.CastTo(nearestEntity,nearestObject) && nearestEntity != pSettings.m_Parent && !nearestEntity.IsSelfAdjustingTemperature())
55 {
56 float temperatureDifference = tempTarget - nearestEntity.GetTemperature();
57
58 distanceToTemperatureSource = vector.Distance(nearestEntity.GetPosition(), position);
59 distanceToTemperatureSource = Math.Max(distanceToTemperatureSource, 0.1);
60
61 float time = m_ExecuteInterval;
62 if (m_ExecuteInterval == -1) //bogus time in the first execute
63 time = 1;
64
65 float distFactor = 1;
66 if (vector.Distance(nearestEntity.GetPosition(), position) > pSettings.m_RangeFull)
67 {
68 distFactor = Math.InverseLerp(pSettings.m_RangeMax,pSettings.m_RangeFull,distanceToTemperatureSource);
69 distFactor = Math.Max(distFactor, 0.0);
70 }
71
72 TemperatureDataInterpolated dta = new TemperatureDataInterpolated(tempTarget,ETemperatureAccessTypes.ACCESS_UTS,time,pSettings.m_TemperatureItemCoef * distFactor);
73
74 if (nearestEntity.GetInventory())
75 {
76 UpdateVicinityTemperatureRecursive(nearestEntity,dta);
77 }
78 else if (nearestEntity.CanHaveTemperature() && !nearestEntity.IsSelfAdjustingTemperature())
79 {
80 dta.m_HeatPermeabilityCoef = nearestEntity.GetHeatPermeabilityCoef();
81
82 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !nearestEntity.IsFreezeThawProgressFinished()) //ignoring insignificant increments
83 nearestEntity.SetTemperatureEx(dta);
84 else
85 nearestEntity.RefreshTemperatureAccess(dta);
86 }
87 }
88 }
89 }
90
91 protected void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef = 1.0)
92 {
93 float heatPermCoef = heatPermeabilityCoef;
94 heatPermCoef *= ent.GetHeatPermeabilityCoef();
95 dta.m_HeatPermeabilityCoef = heatPermCoef;
96
97 //handle temperature of this entity
98 if (ent.CanHaveTemperature() && !ent.IsSelfAdjustingTemperature())
99 {
100 float temperatureDifference = dta.m_AdjustedTarget - ent.GetTemperature();
101 if (Math.AbsFloat(temperatureDifference) >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD || !ent.IsFreezeThawProgressFinished()) //ignoring insignificant increments
102 ent.SetTemperatureEx(dta);
103 else
104 ent.RefreshTemperatureAccess(dta);
105 }
106
107 // go through any attachments and cargo, recursive
108 int inventoryAttCount = ent.GetInventory().AttachmentCount();
109 if (inventoryAttCount > 0)
110 {
111 EntityAI attachmentEnt;
112 for (int inAttIdx = 0; inAttIdx < inventoryAttCount; ++inAttIdx)
113 {
114 if (Class.CastTo(attachmentEnt,ent.GetInventory().GetAttachmentFromIndex(inAttIdx)))
115 {
116 UpdateVicinityTemperatureRecursive(attachmentEnt,dta,heatPermCoef);
117 }
118 }
119 }
120
121 if (ent.GetInventory().GetCargo())
122 {
123 int inventoryItemCount = ent.GetInventory().GetCargo().GetItemCount();
124 if (inventoryItemCount > 0)
125 {
126 EntityAI cargoEnt;
127 for (int j = 0; j < inventoryItemCount; ++j)
128 {
129 if (Class.CastTo(cargoEnt,ent.GetInventory().GetCargo().GetItem(j)))
130 {
131 UpdateVicinityTemperatureRecursive(cargoEnt,dta,heatPermCoef);
132 }
133 }
134 }
135 }
136 }
137
138 override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
139 {
140 resultValues.m_TemperatureItem = pSettings.m_TemperatureItemCap;
141 resultValues.m_TemperatureHeatcomfort = pSettings.m_TemperatureCap;
142
143 vector pos = pSettings.m_Position;
144 if (pSettings.m_Parent != null)
145 pos = pSettings.m_Parent.GetPosition();
146
147 // Define half-size (range)
148 float halfRange = pSettings.m_RangeMax;
149
150 // Calculate min and max positions of the box
151 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
152 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
153
154 array<EntityAI> nearestObjects = {};
155 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
156
157 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
158 {
159 EntityAI entity = nearestObjects[i];
160 if (entity)
161 {
162 vector objPos = entity.GetPosition();
163 float distance = vector.Distance(objPos, pos);
164 if (distance > pSettings.m_RangeMax)
165 nearestObjects.Remove(i);
166 }
167 }
168
169 if (nearestObjects.Count() > 0)
170 {
171 DryItemsInVicinity(pSettings, pos, nearestObjects);
172 WarmAndCoolItemsInVicinity(pSettings, pos, nearestObjects);
173 }
174 }
175
178 {
179 vector pos = pSettings.m_Position;
180 if (pSettings.m_Parent != null)
181 pos = pSettings.m_Parent.GetPosition();
182
183 // Define half-size (range)
184 float halfRange = pSettings.m_RangeMax;
185
186 // Calculate min and max positions of the box
187 vector minPos = pos - Vector(halfRange, halfRange / 2, halfRange);
188 vector maxPos = pos + Vector(halfRange, halfRange / 2, halfRange);
189
190 array<EntityAI> nearestObjects = {};
191 DayZPlayerUtils.SceneGetEntitiesInBox(minPos, maxPos, nearestObjects, QueryFlags.DYNAMIC);
192
193 for (int i = nearestObjects.Count() - 1; i >= 0; --i)
194 {
195 EntityAI entity = nearestObjects[i];
196 if (entity)
197 {
198 vector objPos = entity.GetPosition();
199 float distance = vector.Distance(objPos, pos);
200 if (distance > pSettings.m_RangeMax)
201 nearestObjects.Remove(i);
202 }
203 }
204
205 DryItemsInVicinity(pSettings, pos, nearestObjects);
206 }
207}
208
209class UniversalTemperatureSourceLambdaConstant : UniversalTemperatureSourceLambdaBaseImpl {}
211{
214 m_AffectsPlayer = false;
215 }
216}
217
void DayZPlayerUtils()
cannot be instantiated
Определения DayZPlayerUtils.c:465
QueryFlags
Определения DayZPlayerUtils.c:2
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine()
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
override void WarmAndCoolItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< EntityAI > nearestObjects)
override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings)
DEPRECATED.
override void DryItemsInVicinity(UniversalTemperatureSourceSettings pSettings, vector position, out notnull array< EntityAI > nearestObjects)
void UpdateVicinityTemperatureRecursive(EntityAI ent, TemperatureData dta, float heatPermeabilityCoef=1.0)
override void Execute(UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceResult resultValues)
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
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/constants.c:940
const float STATE_DAMP
Определения 3_Game/constants.c:875
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.