Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
playerstatbase.c
Go to the documentation of this file.
2 {
3  int m_Type;
4  void OnStoreSave( ParamsWriteContext ctx );
5  bool OnStoreLoad( ParamsReadContext ctx);
6  void OnRPC(ParamsReadContext ctx);
7  float Get();
8  string GetLabel();
9  void SetByFloat(float value);
10  void SetByFloatEx(float value, string system = "" );
11  bool IsSynced();
12  array<PlayerStatRecord> GetRecords();
13  void Init(int id/*, PlayerStats manager*/);
14  void SerializeValue(array<ref StatDebugObject> objects, int flags);
15  float GetNormalized();
16  float GetMax();
17  float GetMin();
18  int GetType()
19  {
20  return m_Type;
21  }
22 };
23 
24 class PlayerStat<Class T> extends PlayerStatBase
25 {
26  protected T m_MinValue;
27  protected T m_MaxValue;
28  protected T m_Value;
29  protected string m_ValueLabel;
30  protected int m_Flags;
31 
32  ref array<PlayerStatRecord> m_Records;
34 
35 
36  void PlayerStat(T min, T max,T init, string label, int flags)
37  {
38  m_MinValue = min;
39  m_MaxValue = max;
40  m_Value = init;
41  m_ValueLabel = label;
42  m_Flags = flags;
43 
44  m_Records = new array<PlayerStatRecord>;
45  }
46 
47  override void Init(int id/*, PlayerStats manager*/)
48  {
49  m_Type = id;
50  //m_Manager = manager;
51  }
52 
53  override void SerializeValue(array<ref StatDebugObject> objects, int flags)
54  {
55  objects.Insert( new StatDebugObject(GetLabel(), Get(), eRemoteStatType.PLAYER_STATS) );
56  }
57 
58  PlayerStats GetManager()
59  {
60  return m_Manager;
61  }
62 
63  void Set( T value, string system = "" )
64  {
65  /*
66  Print("setting stat: " + this.GetLabel() + "| value:" +value.ToString());
67 
68  if( this.GetLabel() == "Toxicity" )
69  {
70  DebugPrint.LogAndTrace("stack");
71  }
72  */
73  if ( value > m_MaxValue )
74  {
76  }
77  else if (value < m_MinValue)
78  {
80  }
81  else
82  {
83  m_Value = value;
84  }
85  //if( GetManager().GetAllowLogs() ) CreateRecord(value, system);
86  }
87 
88  void SetByFloat(float value, string system = "" )
89  {
90  T f = value;
91  Set(f,system);
92 
93  }
94  override void SetByFloatEx(float value, string system = "" )
95  {
96  SetByFloat(value, system);
97  }
98  /*
99  void SetByParam(Param param, string system = "" )
100  {
101  Class.CastTo(p1, param);
102  T v = p1.param1;
103  Set(v, system);
104  }
105  */
106  void Add( T value, string system = "" )
107  {
108  Set(m_Value+value, system);
109  }
110 
111  override float Get()
112  {
113  return m_Value;
114  }
115 
116  override string GetLabel()
117  {
118  return m_ValueLabel;
119  }
120 
121  override float GetMax()
122  {
123  return m_MaxValue;
124  }
125 
126  override float GetMin()
127  {
128  return m_MinValue;
129  }
130 
131  override float GetNormalized()
132  {
133  return Math.InverseLerp(GetMin(), GetMax(), Get());
134  }
135 
136  override array<PlayerStatRecord> GetRecords()
137  {
138  return m_Records;
139  }
140 
141  void CreateRecord(float value, string system)
142  {
143  m_Records.Insert( new PlayerStatRecord(value, GetGame().GetTime(), system ) );
144  }
145 
146  override void OnStoreSave( ParamsWriteContext ctx )
147  {
148  //ctx.Write(m_ValueLabel);
149  //PrintString("saving " + GetLabel()+" value:" +m_Value);
150  ctx.Write(m_Value);
151  }
152 
153  override bool OnStoreLoad( ParamsReadContext ctx)
154  {
155  //string name;
156 
157  //ctx.Read(name);
158  T value;
159  if(ctx.Read(value))
160  {
161  m_Value = value;
162  }
163  else
164  {
165  return false;
166  }
167  //PrintString("loading " + GetLabel()+" value:" +m_Value);
168  return true;
169  }
170 }
GetGame
proto native CGame GetGame()
Add
void Add(string name, string value)
Definition: universaltemperaturesource.c:224
PlayerStatRecord
Definition: playerstatrecord.c:1
m_Type
eBleedingSourceType m_Type
Definition: bleedingsource.c:25
m_Manager
ModifiersManager m_Manager
Definition: modifierbase.c:12
PlayerStatBase
Definition: playerstatbase.c:1
m_MinValue
float m_MinValue
Definition: staminahandler.c:139
GetMax
proto native float GetMax()
m_Value
string m_Value
Definition: enentity.c:5
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
GetMin
proto native float GetMin()
Get
array< ref PlayerStatBase > Get()
Definition: playerstatspco.c:103
array< PlayerStatRecord >
StatDebugObject
Definition: statdebugobject.c:1
PlayerStats
Definition: playerstats.c:6
init
enum MagnumStableStateID init
OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
Definition: modifierbase.c:229
m_MaxValue
float m_MaxValue
Definition: staminahandler.c:139
GetTime
float GetTime()
Definition: notificationsystem.c:35
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
eRemoteStatType
eRemoteStatType
Definition: remoteplayerstatdebug.c:1
OnStoreLoad
bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition: modifiersmanager.c:270