Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
14  vector m_Position = vector.Zero;
15  EntityAI m_Parent = null;
16 }
17 
18 class UniversalTemperatureSourceResult
19 {
20  float m_Temperature = 0;
21  // ?? what else
22 }
23 
25 class UniversalTemperatureSourceTimer : Timer
26 {
27  override void OnTimer()
28  {
29  if (m_params)
30  {
31  GetGame().GameScript.CallFunctionParams(m_target, m_function, null, m_params);
32  }
33  else
34  {
35  GetGame().GameScript.CallFunction(m_target, m_function, null, 0);
36  }
37  }
38 
39  override void Stop()
40  {
41  SetRunning(false);
42  m_time = 0;
43  }
44 
45  void SetParams(Param params)
46  {
47  m_params = params;
48  }
49 }
50 
51 typedef UniversalTemperatureSource UTemperatureSource;
52 
54 {
55  protected bool m_Active
56  protected ref UniversalTemperatureSourceTimer m_Timer;
57  protected UniversalTemperatureSourceSettings m_Settings;
58  protected ref UniversalTemperatureSourceResult m_ResultValues;
59  protected ref UniversalTemperatureSourceLambdaBase m_Lambda;
60 
62  {
63  m_Active = false;
64  m_Settings = pSettings;
65  m_Lambda = pLambda;
66  m_ResultValues = new UniversalTemperatureSourceResult();
67  m_Timer = new UniversalTemperatureSourceTimer();
68 
69  Init(pParent);
70  }
71 
72  void ~UniversalTemperatureSource() {};
73 
74  void Init(EntityAI pParent)
75  {
76  if (pParent)
77  {
78  pParent.SetUniversalTemperatureSource(this);
79 
80  m_Settings.m_Parent = pParent;
81  m_Settings.m_Position = pParent.GetPosition();
82  }
83 
84  if (!m_Settings.m_ManualUpdate)
85  {
87 
88  m_Timer.Run(m_Settings.m_UpdateInterval, this, "Update", params, m_Settings.m_Updateable);
89  SetActive(false);
90  }
91  }
92 
94  {
95  return m_Settings.m_Position;
96  }
97 
98  float GetFullRange()
99  {
100  return m_Settings.m_RangeFull;
101  }
102 
103  float GetMaxRange()
104  {
105  return m_Settings.m_RangeMax;
106  }
107 
108  float GetTemperature()
109  {
110  if (m_Settings.m_TemperatureCap != float.MAX)
111  {
112  return Math.Min(m_Settings.m_TemperatureCap, GetTemperatureRaw());
113  }
114 
115  return GetTemperatureRaw();
116  }
117 
118  float GetTemperatureRaw()
119  {
120  if (m_ResultValues)
121  {
122  return m_ResultValues.m_Temperature;
123  }
124 
125  return 0;
126  }
127 
128  float GetTemperatureMin()
129  {
130  return m_Settings.m_TemperatureMin;
131  }
132 
133  float GetTemperatureMax()
134  {
135  return m_Settings.m_TemperatureMax;
136  }
137 
139  {
140  return m_Settings.m_Parent;
141  }
142 
143  bool IsActive()
144  {
145  if (m_Settings.m_ManualUpdate)
146  {
147  return m_Active;
148  }
149 
150  return m_Timer && m_Timer.IsRunning();
151  }
152 
153  void SetActive(bool pActive)
154  {
155  if (m_Settings.m_ManualUpdate)
156  {
157  m_Active = pActive;
158  return;
159  }
160 
161  if (pActive && !m_Timer.IsRunning())
162  {
163  m_Timer.Continue();
164  }
165  else
166  {
167  m_Timer.Stop();
168  }
169  }
170 
171  void SetDefferedActive(bool pActive, float pSeconds)
172  {
173  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLaterByName(this, "SetActive", pSeconds * 1000, false, new Param1<bool>(pActive));
174  }
175 
176  void ChangeSettings(UniversalTemperatureSourceSettings pSettings)
177  {
179  }
180 
182  {
183  if (!IsActive())
184  {
185  return;
186  }
187 
188  if (lambda)
189  {
190  settings.m_Position = settings.m_Parent.GetUniversalTemperatureSourcePosition();
191  lambda.Execute(settings, m_ResultValues);
192  }
193 
194  }
195 }
196 
197 typedef UniversalTemperatureSourceDebug UTemperatureSourceDebug
198 
200 {
201  const string DELIMITER_DATA = "|";
202  const string DELIMITER_KEYPAIR = ":";
203 
204  string m_Header;
205  string m_Data;
209 
211  {
212  m_Header = "";
213  m_Data = "";
214  m_Pairs = new array<string>();
215  m_Names = new array<string>();
216  m_Values = new array<string>();
217  }
218 
219  void AddHeader(string header)
220  {
221  m_Header = header;
222  }
223 
224  void Add(string name, string value)
225  {
226  m_Data = string.Format("%1%2:%3%4", m_Data, name, value, DELIMITER_DATA);
227  }
228 
229  void Commit()
230  {
231  m_Pairs = ParseData();
232  ParseKeyPairs();
233  }
234 
236  {
237  return m_Pairs.Count();
238  }
239 
240  string GetHeader()
241  {
242  return m_Header;
243  }
244 
245  string GetName(int pIndex)
246  {
247  if (m_Names.Count() - 1 < pIndex)
248  {
249  Debug.Log(string.Format("GetName index: %1 from data of length: %2", pIndex, m_Names.Count()), "UniversalTemperatureSourceDebug");
250  return "";
251  }
252 
253  return m_Names.Get(pIndex);
254  }
255 
256  string GetValue(int pIndex)
257  {
258  if (m_Values.Count() - 1 < pIndex)
259  {
260  Debug.Log(string.Format("GetValue index: %1 from data of length: %2", pIndex, m_Values.Count()), "UniversalTemperatureSourceDebug");
261  return "";
262  }
263 
264  return m_Values.Get(pIndex);
265  }
266 
268  {
269 
270  array<string> parsed = new array<string>();
271  if (m_Data)
272  {
273  m_Data.Split(DELIMITER_DATA, parsed);
274  }
275 
276  return parsed;
277  }
278 
279  protected void ParseKeyPairs()
280  {
281  m_Names.Clear();
282  m_Values.Clear();
283 
284  if (m_Pairs)
285  {
286  for (int i = 0; i < m_Pairs.Count(); i++)
287  {
288  array<string> keypair = new array<string>();
289 
290  m_Pairs.Get(i).Split(DELIMITER_KEYPAIR, keypair);
291  m_Names.Insert(keypair[0]);
292  m_Values.Insert(keypair[1]);
293  }
294  }
295  }
296 
297  void Debug()
298  {
299  for (int i = 0; i < m_Names.Count(); i++)
300  {
301  Debug.Log(string.Format("%1: %2", m_Names.Get(i), m_Values.Get(i)), "UniversalTemperatureSourceDebug");
302  }
303  }
304 }
Param2
Definition: ppeconstants.c:66
GetGame
proto native CGame GetGame()
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
AddHeader
void AddHeader(string header)
Definition: universaltemperaturesource.c:219
Add
void Add(string name, string value)
Definition: universaltemperaturesource.c:224
m_Temperature
class UniversalTemperatureSourceSettings m_Temperature
UniversalTemperatureSourceLambdaBase
Definition: universaltemperaturesourcelambdabase.c:1
ParseData
protected array< string > ParseData()
Definition: universaltemperaturesource.c:267
PairsCount
int PairsCount()
Definition: universaltemperaturesource.c:235
m_Data
string m_Data
Definition: universaltemperaturesource.c:205
GetHeader
string GetHeader()
Definition: universaltemperaturesource.c:240
OnTimer
void OnTimer()
DEPRECATED.
Definition: tools.c:350
m_time
protected float m_time
Definition: tools.c:224
m_Timer
ref Timer m_Timer
Definition: dayzgame.c:690
SetActive
void SetActive()
Definition: trapbase.c:437
ParseKeyPairs
protected void ParseKeyPairs()
Definition: universaltemperaturesource.c:279
UniversalTemperatureSource
original Timer deletes m_params which is unwanted
Definition: universaltemperaturesource.c:25
UniversalTemperatureSourceDebug
Definition: universaltemperaturesource.c:53
m_Pairs
ref array< string > m_Pairs
values parsed from m_Pairs
Definition: universaltemperaturesource.c:208
SetRunning
protected void SetRunning(bool running)
Definition: tools.c:351
GetTemperature
override float GetTemperature()
Definition: itembase.c:3525
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
DELIMITER_KEYPAIR
const string DELIMITER_KEYPAIR
Definition: universaltemperaturesource.c:202
vector
Definition: enconvert.c:105
UniversalTemperatureSourceSettings
Definition: universaltemperaturesource.c:1
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
UniversalTemperatureSourceDebug
void UniversalTemperatureSourceDebug()
keeps first iteration of parsed data from the m_Data
Definition: universaltemperaturesource.c:210
GetTemperatureMin
override float GetTemperatureMin()
Definition: itembase.c:3535
GetTemperatureMax
override float GetTemperatureMax()
Definition: itembase.c:3540
GetName
string GetName(int pIndex)
Definition: universaltemperaturesource.c:245
array< string >
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
GetValue
string GetValue(int pIndex)
Definition: universaltemperaturesource.c:256
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Debug
Definition: debug.c:13
m_Values
ref array< string > m_Values
names parsed from m_Pairs
Definition: universaltemperaturesource.c:207
IsActive
bool IsActive()
Definition: modifierbase.c:130
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition: effect.c:405
Timer
Definition: dayzplayerimplement.c:62
Debug
void Debug()
Definition: universaltemperaturesource.c:297
Math
Definition: enmath.c:6
m_Names
ref array< string > m_Names
Definition: universaltemperaturesource.c:206
Commit
void Commit()
Definition: universaltemperaturesource.c:229
EntityAI
Definition: building.c:5
Stop
void Stop()
Stops all elements this effect consists of.
Definition: effect.c:179
m_Header
string m_Header
Definition: universaltemperaturesource.c:204