DayZ 1.24
Loading...
Searching...
No Matches
UniversalTemperatureSource.c
Go to the documentation of this file.
2{
3 float m_UpdateInterval = 1.0;
4 float m_TemperatureMin = 0;
5 float m_TemperatureMax = 100;
6 float m_TemperatureCap = float.MAX;
7 float m_RangeFull = 1;
8 float m_RangeMax = 2;
9
10 bool m_Updateable = false;
11 bool m_ManualUpdate = false;
12 bool m_AffectStat = false;
13
16}
17
19{
20 float m_Temperature = 0;
21 // ?? what else
22}
23
26{
27 override void OnTimer()
28 {
29 if (m_params)
30 GetGame().GameScript.CallFunctionParams(m_target, m_function, null, m_params);
31 else
32 GetGame().GameScript.CallFunction(m_target, m_function, null, 0);
33 }
34
35 override void Stop()
36 {
37 SetRunning(false);
38 m_time = 0;
39 }
40
42 {
43 m_params = params;
44 }
45}
46
48
50{
51 protected bool m_Active
56
67
69
71 {
72 if (pParent)
73 {
74 pParent.SetUniversalTemperatureSource(this);
75
76 m_Settings.m_Parent = pParent;
77 m_Settings.m_Position = pParent.GetPosition();
78 }
79
80 if (!m_Settings.m_ManualUpdate)
81 {
83
84 m_Timer.Run(m_Settings.m_UpdateInterval, this, "Update", params, m_Settings.m_Updateable);
85 SetActive(false);
86 }
87 }
88
90 {
91 return m_Settings.m_Position;
92 }
93
95 {
96 return m_Settings.m_RangeFull;
97 }
98
100 {
101 return m_Settings.m_RangeMax;
102 }
103
105 {
106 if (m_Settings.m_TemperatureCap != float.MAX)
107 return Math.Min(m_Settings.m_TemperatureCap, GetTemperatureRaw());
108
109 return GetTemperatureRaw();
110 }
111
113 {
114 if (m_ResultValues)
115 return m_ResultValues.m_Temperature;
116
117 return 0;
118 }
119
121 {
122 return m_Settings.m_TemperatureMin;
123 }
124
126 {
127 return m_Settings.m_TemperatureMax;
128 }
129
131 {
132 return m_Settings.m_Parent;
133 }
134
135 bool IsActive()
136 {
137 if (m_Settings.m_ManualUpdate)
138 return m_Active;
139
140 return m_Timer && m_Timer.IsRunning();
141 }
142
144 {
145 if (m_Settings.m_ManualUpdate)
146 {
147 m_Active = pActive;
148 return;
149 }
150
151 if (pActive && !m_Timer.IsRunning())
152 m_Timer.Continue();
153 else
154 m_Timer.Stop();
155 }
156
158 {
159 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLaterByName(this, "SetActive", pSeconds * 1000, false, new Param1<bool>(pActive));
160 }
161
166
168 {
169 if (!IsActive())
170 return;
171
172 if (lambda)
173 {
174 settings.m_Position = settings.m_Parent.GetUniversalTemperatureSourcePosition();
175 lambda.Execute(settings, m_ResultValues);
176 }
177
178 }
179}
180
182
184{
185 const string DELIMITER_DATA = "|";
186 const string DELIMITER_KEYPAIR = ":";
187
188 string m_Header;
189 string m_Data;
193
195 {
196 m_Header = "";
197 m_Data = "";
198 m_Pairs = new array<string>();
199 m_Names = new array<string>();
200 m_Values = new array<string>();
201 }
202
203 void AddHeader(string header)
204 {
206 }
207
208 void Add(string name, string value)
209 {
210 m_Data = string.Format("%1%2:%3%4", m_Data, name, value, DELIMITER_DATA);
211 }
212
213 void Commit()
214 {
215 m_Pairs = ParseData();
217 }
218
220 {
221 return m_Pairs.Count();
222 }
223
224 string GetHeader()
225 {
226 return m_Header;
227 }
228
229 string GetName(int pIndex)
230 {
231 if (m_Names.Count() - 1 < pIndex)
232 {
233 Debug.Log(string.Format("GetName index: %1 from data of length: %2", pIndex, m_Names.Count()), "UniversalTemperatureSourceDebug");
234 return "";
235 }
236
237 return m_Names.Get(pIndex);
238 }
239
240 string GetValue(int pIndex)
241 {
242 if (m_Values.Count() - 1 < pIndex)
243 {
244 Debug.Log(string.Format("GetValue index: %1 from data of length: %2", pIndex, m_Values.Count()), "UniversalTemperatureSourceDebug");
245 return "";
246 }
247
248 return m_Values.Get(pIndex);
249 }
250
252 {
253
255 if (m_Data)
257
258 return parsed;
259 }
260
261 protected void ParseKeyPairs()
262 {
263 m_Names.Clear();
264 m_Values.Clear();
265
266 if (m_Pairs)
267 {
268 for (int i = 0; i < m_Pairs.Count(); i++)
269 {
271
272 m_Pairs.Get(i).Split(DELIMITER_KEYPAIR, keypair);
273 m_Names.Insert(keypair[0]);
274 m_Values.Insert(keypair[1]);
275 }
276 }
277 }
278
279 void Debug()
280 {
281 for (int i = 0; i < m_Names.Count(); i++)
282 Debug.Log(string.Format("%1: %2", m_Names.Get(i), m_Values.Get(i)), "UniversalTemperatureSourceDebug");
283 }
284}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
override Widget Init()
Definition DayZGame.c:120
ref Timer m_Timer
Definition DayZGame.c:675
bool IsActive()
float GetValue()
Definition SyncedValue.c:55
void SetActive()
Definition TrapBase.c:409
string GetHeader()
class UniversalTemperatureSourceSettings m_Temperature
ref array< string > m_Pairs
values parsed from m_Pairs
ref array< string > m_Names
array< string > ParseData()
void AddHeader(string header)
void Add(string name, string value)
const string DELIMITER_KEYPAIR
ref array< string > m_Values
names parsed from m_Pairs
void ParseKeyPairs()
void UniversalTemperatureSourceDebug()
keeps first iteration of parsed data from the m_Data
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
Definition EnMath.c:7
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
void UniversalTemperatureSource(EntityAI pParent, UniversalTemperatureSourceSettings pSettings, UniversalTemperatureSourceLambdaBase pLambda)
void SetDefferedActive(bool pActive, float pSeconds)
ref UniversalTemperatureSourceTimer m_Timer
UniversalTemperatureSourceSettings m_Settings
void ChangeSettings(UniversalTemperatureSourceSettings pSettings)
ref UniversalTemperatureSourceLambdaBase m_Lambda
void Update(UniversalTemperatureSourceSettings settings, UniversalTemperatureSourceLambdaBase lambda)
ref UniversalTemperatureSourceResult m_ResultValues
original Timer deletes m_params which is unwanted
vector m_Position
if the temperature generated is also set as Temperature Stat on Item itself
bool m_Updateable
maximum range where the receiver can get some temperature
float m_RangeFull
temperature cap that will limit the return value from GetTemperature method
float m_TemperatureCap
max temperature you can get from the TemperatureSource
float m_RangeMax
range where the full temperature is given to receiver
bool m_ManualUpdate
if the Update is running periodically
float m_TemperatureMin
how often the Update is ticking
float m_TemperatureMax
min temperature you can get from the TemperatureSource
bool m_AffectStat
update is called manually (ex. own tick of parent entity)
const float MAX
Definition EnConvert.c:99
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
static proto float Min(float x, float y)
Returns smaller of two given values.
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Definition EnString.c:396
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
float m_time
Definition tools.c:212
void SetRunning(bool running)
Definition tools.c:335
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
proto native owned string GetName()