DayZ 1.24
Loading...
Searching...
No Matches
PlayerStatBase.c
Go to the documentation of this file.
2{
3 int m_Type;
7 float Get();
8 string GetLabel();
9 void SetByFloat(float value);
10 void SetByFloatEx(float value, string system = "");
11 bool IsSynced();
13 void Init(int id/*, PlayerStats manager*/);
16 float GetMax();
17 float GetMin();
18 int GetType()
19 {
20 return m_Type;
21 }
22};
23
24class 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
34
35
36 void PlayerStat(T min, T max, T init, string label, int flags)
37 {
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
54 {
55 objects.Insert(new StatDebugObject(GetLabel(), Get(), eRemoteStatType.PLAYER_STATS));
56 }
57
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)
75 else if (value < m_MinValue)
77 else
78 m_Value = value;
79 //if( GetManager().GetAllowLogs() ) CreateRecord(value, system);
80 }
81
82 void SetByFloat(float value, string system = "")
83 {
84 T f = value;
85 Set(f, system);
86
87 }
88 override void SetByFloatEx(float value, string system = "")
89 {
91 }
92 /*
93 void SetByParam(Param param, string system = "" )
94 {
95 Class.CastTo(p1, param);
96 T v = p1.param1;
97 Set(v, system);
98 }
99 */
100 void Add(T value, string system = "")
101 {
103 }
104
105 override float Get()
106 {
107 return m_Value;
108 }
109
110 override string GetLabel()
111 {
112 return m_ValueLabel;
113 }
114
115 override float GetMax()
116 {
117 return m_MaxValue;
118 }
119
120 override float GetMin()
121 {
122 return m_MinValue;
123 }
124
125 override float GetNormalized()
126 {
127 return Math.InverseLerp(GetMin(), GetMax(), Get());
128 }
129
131 {
132 return m_Records;
133 }
134
135 void CreateRecord(float value, string system)
136 {
137 m_Records.Insert(new PlayerStatRecord(value, GetGame().GetTime(), system));
138 }
139
141 {
142 //ctx.Write(m_ValueLabel);
143 //PrintString("saving " + GetLabel()+" value:" +m_Value);
144 ctx.Write(m_Value);
145 }
146
148 {
149 //string name;
150
151 //ctx.Read(name);
152 T value;
153 if (ctx.Read(value))
154 m_Value = value;
155 else
156 return false;
157 //PrintString("loading " + GetLabel()+" value:" +m_Value);
158 return true;
159 }
160}
eBleedingSourceType m_Type
enum MagnumStableStateID init
float GetTime()
float m_MaxValue
float m_MinValue
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
float GetNormalized()
void SetByFloat(float value, string system="")
override float GetNormalized()
void Set(T value, string system="")
void Add(T value, string system="")
void SetByFloat(float value)
override string GetLabel()
override void Init(int id)
override float Get()
void OnStoreSave(ParamsWriteContext ctx)
bool OnStoreLoad(ParamsReadContext ctx)
override void SerializeValue(array< ref StatDebugObject > objects, int flags)
array< PlayerStatRecord > GetRecords()
override void OnStoreSave(ParamsWriteContext ctx)
void CreateRecord(float value, string system)
PlayerStats m_Manager
void SerializeValue(array< ref StatDebugObject > objects, int flags)
string GetLabel()
void SetByFloatEx(float value, string system="")
override bool OnStoreLoad(ParamsReadContext ctx)
PlayerStats GetManager()
void Init(int id)
override float GetMin()
override float GetMax()
void PlayerStat(T min, T max, T init, string label, int flags)
ref array< PlayerStatRecord > m_Records
override void SetByFloatEx(float value, string system="")
override array< PlayerStatRecord > GetRecords()
void OnRPC(ParamsReadContext ctx)
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto native CGame GetGame()
string m_Value
Definition EnEntity.c:805
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...