DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
NotifierBase.c
См. документацию.
2{
3 float m_DeltaT; // time in seconds since the last tick
4 ref Timer m_Timer1; // timer which can be used for whatever
5 PlayerBase m_Player; //the player this Notifier belongs to
6 int m_Type;
8 int m_TendencyBufferSize = 3;//for best results, this should be somewhat aligned with modifier frequency
9 const int TENDENCY_BUFFER_SIZE = 30;//this needs to be bigger or same size as buffer size of any invidual buffer size
17 float m_LastMA;
18 bool m_FirstPass = true;
19
20 PluginPlayerStatus m_ModulePlayerStatus;
21
23 {
24 m_ModulePlayerStatus = PluginPlayerStatus.Cast(GetPlugin(PluginPlayerStatus));
25 m_Active = true;
26 m_Manager = manager;
27 m_Player = manager.GetPlayer();
28 m_TickInterval = 1000;
29 manager.RegisterItself(GetNotifierType(), this);
30 }
31
32 bool IsTimeToTick(int current_time)
33 {
34 int tickTime = (m_TickIntervalLastTick + m_TickInterval);
35 bool tick = (current_time >= tickTime);
36 #ifdef DIAG_NOTIFIER_LOGS
37 ErrorEx(string.Format("Tick time for notifier %1 is %2 | Current time= %3.", this, tickTime, current_time), ErrorExSeverity.INFO);
38 if (tick)
39 {
40 float timePassed = (current_time - m_TickIntervalLastTick) / 1000.0;
41 float expectedInterval = m_TickInterval / 1000.0;
42 float drift = (current_time - tickTime) / 1000.0;
43 ErrorEx(string.Format("Notifier %1 updated after %2s (expected: %3s, drift: +%4s)", this, timePassed, expectedInterval, drift), ErrorExSeverity.INFO);
44 }
45 #endif
46 return tick;
47 }
48
50 {
51 return m_Player.GetVirtualHud();
52 }
53
55 {
56 return m_Type;
57 }
58
59 string GetName()
60 {
61 return this.ClassName() + " Notifier";
62 }
63
64 bool IsActive()
65 {
66 return m_Active;
67 }
68
69 void SetActive(bool state)
70 {
71 m_Active = state;
72 if (!state)
73 HideBadge();
74 }
75
76 void DisplayTendency(float delta);
77
88
89 float ReadFromCyclicBuffer(int index)
90 {
91 int indx = m_TendencyBufferWriteIterator + index;
92 if ( indx >= m_TendencyBufferSize)
93 {
94 indx = indx - m_TendencyBufferSize;
95 }
96
97 return m_TendencyBuffer[indx];
98 }
99
100 float GetDeltaAvaraged() //for tendency
101 {
102 array<float> values = new array<float>();
103 for (int i = 0; i < m_TendencyBufferSize; ++i)
104 {
105 values.Insert(ReadFromCyclicBuffer(i));
106 }
107
108 float valuesSum = 0;
109
110 int nValues = values.Count();
111 for (i = 0; i < nValues; ++i)
112 {
113 valuesSum += values.Get(i);
114 }
115
116 float sma = valuesSum / m_TendencyBufferSize;
117 if (m_FirstPass)
118 {
119 m_LastMA = sma;
120 m_FirstPass = false;
121 }
122
123 float tnd = sma - m_LastMA;
124 m_LastMA = sma;
125
126 return tnd;
127 }
128
130 {
131 float value1;
132 float value2;
133 int nValues = values.Count();
134 for (int i = 0; i < nValues - 1; i++)
135 {
136 value1 = values.Get(i);
137 value2 = values.Get(i + 1);
138 float average = (value1 + value2) / 2;
139 values.Set(i, average);
140 values.Set(i + 1, average);
141 }
142
143 int index = nValues - 1;
144 values.Set(index, value2);
145 }
146
147 void OnTick(float current_Time)
148 {
149 OnTick((int)current_Time);
150 }
151
152 void OnTick(int currentTime)
153 {
154 #ifdef DIAG_NOTIFIER_LOGS
155 ErrorEx(string.Format("Set last tick interval time on notifier %1 | Time= %2.", m_TickIntervalLastTick, currentTime), ErrorExSeverity.INFO);
156 #endif
157 m_TickIntervalLastTick = currentTime;
158
159 DisplayBadge();
161
162 if (m_ShowTendency)
164 }
165
166 protected int CalculateTendency(float delta, float inctresholdlow, float inctresholdmed, float inctresholdhigh, float dectresholdlow, float dectresholdmed, float dectresholdhigh)
167 {
168 int tendency = TENDENCY_STABLE;
169 if (delta > inctresholdhigh)
170 tendency = TENDENCY_INC_HIGH;
171 else if (delta > inctresholdmed)
172 tendency = TENDENCY_INC_MED;
173 else if (delta > inctresholdlow)
174 tendency = TENDENCY_INC_LOW;
175 else if (delta < dectresholdhigh)
176 tendency = TENDENCY_DEC_HIGH;
177 else if (delta < dectresholdmed)
178 tendency = TENDENCY_DEC_MED;
179 else if (delta < dectresholdlow)
180 tendency = TENDENCY_DEC_LOW;
181
182 return tendency;
183 }
184
185
186 protected eBadgeLevel DetermineBadgeLevel(float value, float lvl_1, float lvl_2, float lvl_3)
187 {
188 eBadgeLevel level = eBadgeLevel.NONE;
189 if (value >= lvl_3)
190 level = eBadgeLevel.THIRD;
191 else if (value >= lvl_2)
192 level = eBadgeLevel.SECOND;
193 else if (value >= lvl_1)
194 level = eBadgeLevel.FIRST;
195
196 return level;
197 }
198
199
200 protected void DisplayBadge();
201 protected void HideBadge();
202
203 protected float GetObservedValue()
204 {
205 return 0.0;
206 }
207}
const int TENDENCY_INC_LOW
const int TENDENCY_DEC_HIGH
const int TENDENCY_DEC_MED
const int TENDENCY_INC_MED
const int TENDENCY_DEC_LOW
const int TENDENCY_INC_HIGH
const int TENDENCY_STABLE
void VirtualHud(PlayerBase player)
Определения DisplayStatus.c:36
void NotifiersManager(PlayerBase player)
Определения NotifiersManager.c:37
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
void SmoothOutFloatValues(array< float > values)
Определения NotifierBase.c:129
void SetActive(bool state)
Определения NotifierBase.c:69
void OnTick(int currentTime)
Определения NotifierBase.c:152
void DisplayTendency(float delta)
int m_TendencyBufferWriteIterator
Определения NotifierBase.c:15
int m_Type
Определения NotifierBase.c:6
void OnTick(float current_Time)
Определения NotifierBase.c:147
float m_DeltaT
Определения NotifierBase.c:3
bool IsActive()
Определения NotifierBase.c:64
PluginPlayerStatus m_ModulePlayerStatus
Определения NotifierBase.c:20
PlayerBase m_Player
Определения NotifierBase.c:5
eBadgeLevel DetermineBadgeLevel(float value, float lvl_1, float lvl_2, float lvl_3)
Определения NotifierBase.c:186
const int TENDENCY_BUFFER_SIZE
Определения NotifierBase.c:9
float ReadFromCyclicBuffer(int index)
Определения NotifierBase.c:89
bool IsTimeToTick(int current_time)
Определения NotifierBase.c:32
bool m_FirstPass
Определения NotifierBase.c:18
void AddToCyclicBuffer(float value)
Определения NotifierBase.c:78
int m_TickInterval
Определения NotifierBase.c:12
float m_LastTendency
Определения NotifierBase.c:16
bool m_ShowTendency
Определения NotifierBase.c:10
VirtualHud GetVirtualHud()
Определения NotifierBase.c:49
void NotifierBase(NotifiersManager manager)
Определения NotifierBase.c:22
float GetDeltaAvaraged()
Определения NotifierBase.c:100
NotifiersManager m_Manager
Определения NotifierBase.c:7
float m_LastMA
Определения NotifierBase.c:17
string GetName()
Определения NotifierBase.c:59
bool m_Active
Определения NotifierBase.c:11
int m_TickIntervalLastTick
Определения NotifierBase.c:13
int CalculateTendency(float delta, float inctresholdlow, float inctresholdmed, float inctresholdhigh, float dectresholdlow, float dectresholdmed, float dectresholdhigh)
Определения NotifierBase.c:166
float m_TendencyBuffer[TENDENCY_BUFFER_SIZE]
Определения NotifierBase.c:14
int m_TendencyBufferSize
Определения NotifierBase.c:8
void HideBadge()
void DisplayBadge()
float GetObservedValue()
Определения NotifierBase.c:203
int GetNotifierType()
Определения NotifierBase.c:54
ref Timer m_Timer1
Определения NotifierBase.c:4
Определения PlayerBaseClient.c:2
Определения DayZPlayerImplement.c:39
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx