DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
NotifiersManager.c
См. документацию.
1//#define DIAG_NOTIFIER_LOGS
24
26{
27 static const int MAX_COUNT = 64;
29 NotifierBase m_NotifiersStatic[MAX_COUNT]; //introduced as a seperate array to allow for fast lookup, keeping the old one for quick looping through but also to keep modding compatibility
33 string m_System = "Notifiers";
34 private int m_LastPolledIndex = 0;
35 private ref array<int> m_NotifierIDs = new array<int>();
36
46
47 void Init()
48 {
49 m_Notifiers.Insert(new HealthNotfr(this));
50 m_Notifiers.Insert(new HungerNotfr(this));
51 m_Notifiers.Insert(new ThirstNotfr(this));
52 m_Notifiers.Insert(new StuffedNotfr(this));
53 m_Notifiers.Insert(new SickNotfr(this));
54 m_Notifiers.Insert(new WetnessNotfr(this));
55 m_Notifiers.Insert(new WarmthNotfr(this));
56 m_Notifiers.Insert(new FeverNotfr(this));
57 m_Notifiers.Insert(new BloodNotfr(this));
58 m_Notifiers.Insert(new PillsNotfr(this));
59 m_Notifiers.Insert(new HeartbeatNotfr(this));
60 m_Notifiers.Insert(new FracturedLegNotfr(this));
61 m_Notifiers.Insert(new InjuredLegNotfr(this));
62 }
63
64 void RegisterItself(int notifier_id, NotifierBase modifier)
65 {
66 if (notifier_id >= MAX_COUNT)
67 {
68 ErrorEx("Out of bounds for notifier id: " + notifier_id, ErrorExSeverity.ERROR);
69 }
70 else
71 {
72 m_NotifiersStatic[notifier_id] = modifier;
73 m_NotifierIDs.Insert(notifier_id);
74 #ifdef DIAG_NOTIFIER_LOGS
75 ErrorEx(string.Format("Added notifier %1 with id=%2", modifier, notifier_id), ErrorExSeverity.INFO);
76 #endif
77 }
78 }
79
81 {
82 return m_Player;
83 }
84
86 {
87 return m_VirtualHud;
88 }
89
91 {
92 return m_NotifiersStatic[type];
93 }
94
95 void ActivateByType(int notifier, bool triggerEvent = true)
96 {
97 FindNotifier(notifier).SetActive(true);
98 }
99
100 void DeactivateByType(int notifier, bool triggerEvent = true)
101 {
102 FindNotifier(notifier).SetActive(false);
103 }
104
106 {
107 if (!GetPlayer().IsPlayerSelected())
108 return;
109
111 }
112
114 {
115 int notifierCount = m_Notifiers.Count();
116 #ifdef DIAG_NOTIFIER_LOGS
117 if (notifierCount == 0)
118 {
119 ErrorEx("Notifier count is 0", ErrorExSeverity.ERROR);
120 return;
121 }
122 #endif
123
124 // Wrap around if we've reached the end
125 if (m_LastPolledIndex >= notifierCount)
126 {
127 #ifdef DIAG_NOTIFIER_LOGS
128 ErrorEx(string.Format("Last poll index is %1 and notifiers count is %2. Restet poll index!", m_LastPolledIndex, notifierCount), ErrorExSeverity.INFO);
129 #endif
131 }
132
133 int notifierID = m_NotifierIDs[m_LastPolledIndex];
134 #ifdef DIAG_NOTIFIER_LOGS
135 ErrorEx(string.Format("Got notifier ID %1 for poll index %2.", notifierID, m_LastPolledIndex), ErrorExSeverity.INFO);
136 #endif
137 // Get current notifier to process
138 NotifierBase currentNotifier = m_NotifiersStatic[notifierID];
139 if (currentNotifier && currentNotifier.IsActive())
140 {
141 #ifdef DIAG_NOTIFIER_LOGS
142 ErrorEx(string.Format("Got notifier %1 with ID %2.", currentNotifier, notifierID), ErrorExSeverity.INFO);
143 #endif
144 int currentTime = g_Game.GetTime();
145
146 // Only tick if it's time (using the notifier's own interval)
147 if (currentNotifier.IsTimeToTick(currentTime))
148 {
149 #ifdef DIAG_NOTIFIER_LOGS
150 ErrorEx(string.Format("Time to tick notifier %1.", currentNotifier), ErrorExSeverity.INFO);
151 #endif
152 currentNotifier.OnTick(currentTime);
153 }
154 #ifdef DIAG_NOTIFIER_LOGS
155 else
156 {
157 ErrorEx(string.Format("Skip tick of notifier %1 ..", currentNotifier), ErrorExSeverity.INFO);
158 }
159 #endif
160 }
161 #ifdef DIAG_NOTIFIER_LOGS
162 else
163 {
164 if (!currentNotifier)
165 ErrorEx(string.Format("Could not get any notifier with ID %1.", notifierID), ErrorExSeverity.ERROR);
166 else
167 ErrorEx(string.Format("Could get notifier %1 with ID %2 but notifier is inactive!", currentNotifier, notifierID), ErrorExSeverity.INFO);
168 }
169 #endif
170
171 // Move to next notifier for next tick
173 }
174}
map m_Player
DayZGame g_Game
Определения DayZGame.c:3942
override Widget Init()
Определения DayZGame.c:127
void VirtualHud(PlayerBase player)
Определения DisplayStatus.c:36
PlayerBase GetPlayer()
Определения ModifierBase.c:51
string m_System
the manager instance
Определения ModifierBase.c:12
void NotifiersManager(PlayerBase player)
Определения NotifiersManager.c:37
ref VirtualHud m_VirtualHud
Определения NotifiersManager.c:31
eNotifiers
Определения NotifiersManager.c:3
@ NTF_HEALTHY
Определения NotifiersManager.c:4
@ NTF_HEARTBEAT
Определения NotifiersManager.c:18
@ NTF_BLOOD
Определения NotifiersManager.c:13
@ NTF_THIRSTY
Определения NotifiersManager.c:7
@ NTF_STAMINA
Определения NotifiersManager.c:15
@ NTF_LEGS
Определения NotifiersManager.c:20
@ NTF_FRACTURE
Определения NotifiersManager.c:19
@ NTF_STUFFED
Определения NotifiersManager.c:8
@ NTF_WETNESS
Определения NotifiersManager.c:10
@ NTF_COUNT
Определения NotifiersManager.c:22
@ NTF_PILLS
Определения NotifiersManager.c:17
@ NTF_SICK
Определения NotifiersManager.c:9
@ NTF_WARMTH
Определения NotifiersManager.c:11
@ NTF_FEVERISH
Определения NotifiersManager.c:12
@ NTF_LIVES
Определения NotifiersManager.c:14
@ NTF_BLEEDISH
Определения NotifiersManager.c:5
@ NTF_HUNGRY
Определения NotifiersManager.c:6
void OnScheduledTick()
Определения NotifiersManager.c:105
ref array< int > m_NotifierIDs
Определения NotifiersManager.c:35
VirtualHud GetVirtualHud()
Определения NotifiersManager.c:85
void TickNotifiers()
Определения NotifiersManager.c:113
int m_MinTickTime
Определения NotifiersManager.c:32
NotifierBase FindNotifier(int type)
Определения NotifiersManager.c:90
enum eNotifiers MAX_COUNT
NotifierBase m_NotifiersStatic[MAX_COUNT]
Определения NotifiersManager.c:29
void DeactivateByType(int notifier, bool triggerEvent=true)
Определения NotifiersManager.c:100
ref array< ref NotifierBase > m_Notifiers
Определения NotifiersManager.c:28
void RegisterItself(int notifier_id, NotifierBase modifier)
Определения NotifiersManager.c:64
int m_LastPolledIndex
Определения NotifiersManager.c:34
void ActivateByType(int notifier, bool triggerEvent=true)
Определения NotifiersManager.c:95
Определения BloodNotfr.c:2
Определения FeverNotfr.c:2
Определения HealthNotfr.c:2
Определения HeartbeatNotfr.c:2
Определения HungerNotfr.c:2
Определения InjuredLegNotfr.c:2
void SetActive(bool state)
Определения NotifierBase.c:69
void OnTick(float current_Time)
Определения NotifierBase.c:147
bool IsActive()
Определения NotifierBase.c:64
bool IsTimeToTick(int current_time)
Определения NotifierBase.c:32
Определения NotifierBase.c:2
Определения PillsNotfr.c:2
Определения PlayerBaseClient.c:2
Определения SickNotfr.c:2
Определения StuffedNotfr.c:2
Определения ThirstNotfr.c:2
Определения WarmthNotfr.c:2
Определения WetnessNotfr.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
const int MIN_TICK_NOTIFIERS
Определения 3_Game/DayZ/constants.c:351