DayZ 1.24
Loading...
Searching...
No Matches
NotifierBase.c
Go to the documentation of this file.
2{
3
4 float m_DeltaT; // time in seconds since the last tick
5 ref Timer m_Timer1; // timer which can be used for whatever
6 PlayerBase m_Player; //the player this Notifier belongs to
7 int m_Type;
9 int m_TendencyBufferSize = 3;//for best results, this should be somewhat aligned with modifier frequency
10 const int TENDENCY_BUFFER_SIZE = 30;//this needs to be bigger or same size as buffer size of any invidual buffer size
13 //private float m_SecsToSound; //internal counter
14 //protected float m_MinPauseBetweenSounds; //minimal amount of seconds that needs to pass till sound is played
15 //protected float m_MaxPauseBetweenSounds; //maximal amount of seconds that can pass till sound is played
16 //private float m_SecsSinceLastAnimation; //internal counter
17 //private float m_SecsToAnimation; //internal counter
18 //protected float m_MinPauseBetweenAnimations; //minimal amount of seconds that needs to pass till animation played
19 //protected float m_MaxPauseBetweenAnimations; //maximal amount of seconds that can pass till animation is splayed
25 float m_LastMA;
26 bool m_FirstPass = true;
27 //int m_TendencyID;
28
29 PluginPlayerStatus m_ModulePlayerStatus;
30
32 {
33
34 //m_Timer1 = new Timer();
35 m_ModulePlayerStatus = PluginPlayerStatus.Cast(GetPlugin(PluginPlayerStatus));
36 m_Active = true;
38 m_Player = manager.GetPlayer();
39 m_TickInterval = 1000;
40 manager.RegisterItself(GetNotifierType(), this);
41 }
42
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 {
72 if (!state) HideBadge();
73 }
74
76 {
77 }
78
89
97
98 float GetDeltaAvaraged()//for tendency
99 {
101 for (int i = 0; i < m_TendencyBufferSize; i++)
103 //SmoothOutFloatValues(values);
104
105 //--------------------------------------------------------------------------
106
107 float values_sum = 0;
108 //PrintString("----------------------------");
109 //PrintString("tendency:" + this.ClassName() );
110 for (i = 0; i < values.Count(); i++)
111 {
112 float value = values.Get(i);
113 values_sum += value;
114 //PrintString( value.ToString() );
115 }
116
118 if (m_FirstPass)
119 {
120 m_LastMA = sma;
121 m_FirstPass = false;
122 }
123
124 float tnd = sma - m_LastMA;
125 m_LastMA = sma;
126 /*
127 PrintString(GetName()+" tendency:" + tnd.ToString() );
128 PrintString("----------------------------");
129 */
130 return tnd;
131
132 //--------------------------------------------------------------------------
133
134 }
135
137 {
138 float value1;
139 float value2;
140 for (int i = 0; i < values.Count() - 1; i++)
141 {
142 value1 = values.Get(i);
143 value2 = values.Get(i + 1);
144 float average = (value1 + value2) / 2;
145 values.Set(i, average);
146 values.Set(i + 1, average);
147 }
148 int index = values.Count() - 1;
149 values.Set(index, value2);
150 }
151
153 {
154 //------------
155 /*
156 float time = GetGame().GetTime();
157 Print("ticking notifier "+ this.ClassName() +" for player " + m_Player.ToString() + " at time:" + time.ToString());
158 */
159 //------------
161 DisplayBadge();
164
165 }
166
168 {
176 //Print(" " + delta + " tendency: " + tendency +" " + this);
177 return tendency;
178 }
179
180
181 protected eBadgeLevel DetermineBadgeLevel(float value, float lvl_1, float lvl_2, float lvl_3)
182 {
184 if (value >= lvl_1) level = eBadgeLevel.FIRST;
185 if (value >= lvl_2) level = eBadgeLevel.SECOND;
186 if (value >= lvl_3) level = eBadgeLevel.THIRD;
187 return level;
188 }
189
190
191 protected void DisplayBadge()
192 {
193 }
194
195 protected void HideBadge()
196 {
197 }
198
199 protected float GetObservedValue()
200 {
201 return 0;
202 }
203}
const int TENDENCY_INC_LOW
Definition _constants.c:53
const int TENDENCY_DEC_HIGH
Definition _constants.c:58
const int TENDENCY_DEC_MED
Definition _constants.c:57
const int TENDENCY_INC_MED
Definition _constants.c:54
const int TENDENCY_DEC_LOW
Definition _constants.c:56
const int TENDENCY_INC_HIGH
Definition _constants.c:55
const int TENDENCY_STABLE
Definition _constants.c:52
eBadgeLevel
Definition _constants.c:2
void VirtualHud(PlayerBase player)
void NotifiersManager(PlayerBase player)
PluginBase GetPlugin(typename plugin_type)
void SmoothOutFloatValues(array< float > values)
void SetActive(bool state)
void OnTick(float current_time)
void DisplayTendency(float delta)
int m_TendencyBufferWriteIterator
bool IsActive()
PluginPlayerStatus m_ModulePlayerStatus
PlayerBase m_Player
Definition NotifierBase.c:6
eBadgeLevel DetermineBadgeLevel(float value, float lvl_1, float lvl_2, float lvl_3)
const int TENDENCY_BUFFER_SIZE
float ReadFromCyclicBuffer(int index)
bool IsTimeToTick(int current_time)
void AddToCyclicBuffer(float value)
float m_LastTendency
bool m_ShowTendency
VirtualHud GetVirtualHud()
void NotifierBase(NotifiersManager manager)
float GetDeltaAvaraged()
NotifiersManager m_Manager
Definition NotifierBase.c:8
string GetName()
int m_TickIntervalLastTick
int CalculateTendency(float delta, float inctresholdlow, float inctresholdmed, float inctresholdhigh, float dectresholdlow, float dectresholdmed, float dectresholdhigh)
float m_TendencyBuffer[TENDENCY_BUFFER_SIZE]
int m_TendencyBufferSize
Definition NotifierBase.c:9
void DisplayBadge()
float GetObservedValue()
int GetNotifierType()
ref Timer m_Timer1
Definition NotifierBase.c:5