DayZ 1.30
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
21 {
22 m_Active = true;
23 m_Manager = manager;
24 m_Player = manager.GetPlayer();
25 m_TickInterval = 1000;
26 manager.RegisterItself(GetNotifierType(), this);
27 }
28
29 bool IsTimeToTick(int current_time)
30 {
31 int tickTime = (m_TickIntervalLastTick + m_TickInterval);
32 bool tick = (current_time >= tickTime);
33 #ifdef DIAG_NOTIFIER_LOGS
34 ErrorEx(string.Format("Tick time for notifier %1 is %2 | Current time= %3.", this, tickTime, current_time), ErrorExSeverity.INFO);
35 if (tick)
36 {
37 float timePassed = (current_time - m_TickIntervalLastTick) * 0.001;
38 float expectedInterval = m_TickInterval * 0.001;
39 float drift = (current_time - tickTime) * 0.001;
40 ErrorEx(string.Format("Notifier %1 updated after %2s (expected: %3s, drift: +%4s)", this, timePassed, expectedInterval, drift), ErrorExSeverity.INFO);
41 }
42 #endif
43 return tick;
44 }
45
47 {
48 return m_Player.GetVirtualHud();
49 }
50
52 {
53 return m_Type;
54 }
55
56 string GetName()
57 {
58 return this.ClassName() + " Notifier";
59 }
60
61 bool IsActive()
62 {
63 return m_Active;
64 }
65
66 void SetActive(bool state)
67 {
68 m_Active = state;
69 if (!state)
70 HideBadge();
71 }
72
73 void DisplayTendency(float delta);
74
85
86 float ReadFromCyclicBuffer(int index)
87 {
88 int indx = m_TendencyBufferWriteIterator + index;
89 if ( indx >= m_TendencyBufferSize)
90 {
91 indx = indx - m_TendencyBufferSize;
92 }
93
94 return m_TendencyBuffer[indx];
95 }
96
97 float GetDeltaAvaraged() //for tendency
98 {
99 array<float> values = new array<float>();
100 for (int i = 0; i < m_TendencyBufferSize; ++i)
101 {
102 values.Insert(ReadFromCyclicBuffer(i));
103 }
104
105 float valuesSum = 0;
106
107 int nValues = values.Count();
108 for (i = 0; i < nValues; ++i)
109 {
110 valuesSum += values.Get(i);
111 }
112
113 float sma = valuesSum / m_TendencyBufferSize;
114 if (m_FirstPass)
115 {
116 m_LastMA = sma;
117 m_FirstPass = false;
118 }
119
120 float tnd = sma - m_LastMA;
121 m_LastMA = sma;
122
123 return tnd;
124 }
125
127 {
128 float value1;
129 float value2;
130 int nValues = values.Count();
131 for (int i = 0; i < nValues - 1; ++i)
132 {
133 value1 = values.Get(i);
134 value2 = values.Get(i + 1);
135 float average = (value1 + value2) / 2;
136 values.Set(i, average);
137 values.Set(i + 1, average);
138 }
139
140 int index = nValues - 1;
141 values.Set(index, value2);
142 }
143
144 void OnTick(float current_time)
145 {
146 OnTick((int)current_time);
147 }
148
149 void OnTick(int currentTime)
150 {
151 #ifdef DIAG_NOTIFIER_LOGS
152 ErrorEx(string.Format("Set last tick interval time on notifier %1 | Time= %2.", m_TickIntervalLastTick, currentTime), ErrorExSeverity.INFO);
153 #endif
154 m_TickIntervalLastTick = currentTime;
155
156 DisplayBadge();
158
159 if (m_ShowTendency)
161 }
162
163 protected int CalculateTendency(float delta, float inctresholdlow, float inctresholdmed, float inctresholdhigh, float dectresholdlow, float dectresholdmed, float dectresholdhigh)
164 {
165 int tendency = TENDENCY_STABLE;
166 if (delta > inctresholdhigh)
167 tendency = TENDENCY_INC_HIGH;
168 else if (delta > inctresholdmed)
169 tendency = TENDENCY_INC_MED;
170 else if (delta > inctresholdlow)
171 tendency = TENDENCY_INC_LOW;
172 else if (delta < dectresholdhigh)
173 tendency = TENDENCY_DEC_HIGH;
174 else if (delta < dectresholdmed)
175 tendency = TENDENCY_DEC_MED;
176 else if (delta < dectresholdlow)
177 tendency = TENDENCY_DEC_LOW;
178
179 return tendency;
180 }
181
182
183 protected eBadgeLevel DetermineBadgeLevel(float value, float lvl_1, float lvl_2, float lvl_3)
184 {
185 eBadgeLevel level = eBadgeLevel.NONE;
186 if (value >= lvl_3)
187 level = eBadgeLevel.THIRD;
188 else if (value >= lvl_2)
189 level = eBadgeLevel.SECOND;
190 else if (value >= lvl_1)
191 level = eBadgeLevel.FIRST;
192
193 return level;
194 }
195
196
197 protected void DisplayBadge();
198 protected void HideBadge();
199
200 protected float GetObservedValue()
201 {
202 return 0.0;
203 }
204
206 PluginPlayerStatus m_ModulePlayerStatus;
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:49
void SmoothOutFloatValues(array< float > values)
Определения NotifierBase.c:126
void SetActive(bool state)
Определения NotifierBase.c:66
void OnTick(int currentTime)
Определения NotifierBase.c:149
void OnTick(float current_time)
Определения NotifierBase.c:144
void DisplayTendency(float delta)
int m_TendencyBufferWriteIterator
Определения NotifierBase.c:15
int m_Type
Определения NotifierBase.c:6
float m_DeltaT
Определения NotifierBase.c:3
bool IsActive()
Определения NotifierBase.c:61
PluginPlayerStatus m_ModulePlayerStatus
DEPRECTED BELOW.
Определения NotifierBase.c:206
PlayerBase m_Player
Определения NotifierBase.c:5
eBadgeLevel DetermineBadgeLevel(float value, float lvl_1, float lvl_2, float lvl_3)
Определения NotifierBase.c:183
const int TENDENCY_BUFFER_SIZE
Определения NotifierBase.c:9
float ReadFromCyclicBuffer(int index)
Определения NotifierBase.c:86
bool IsTimeToTick(int current_time)
Определения NotifierBase.c:29
bool m_FirstPass
Определения NotifierBase.c:18
void AddToCyclicBuffer(float value)
Определения NotifierBase.c:75
int m_TickInterval
Определения NotifierBase.c:12
float m_LastTendency
Определения NotifierBase.c:16
bool m_ShowTendency
Определения NotifierBase.c:10
VirtualHud GetVirtualHud()
Определения NotifierBase.c:46
void NotifierBase(NotifiersManager manager)
Определения NotifierBase.c:20
float GetDeltaAvaraged()
Определения NotifierBase.c:97
NotifiersManager m_Manager
Определения NotifierBase.c:7
float m_LastMA
Определения NotifierBase.c:17
string GetName()
Определения NotifierBase.c:56
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:163
float m_TendencyBuffer[TENDENCY_BUFFER_SIZE]
Определения NotifierBase.c:14
int m_TendencyBufferSize
Определения NotifierBase.c:8
void HideBadge()
void DisplayBadge()
float GetObservedValue()
Определения NotifierBase.c:200
int GetNotifierType()
Определения NotifierBase.c:51
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