123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- enum eNotifiers
- {
- NTF_HEALTHY,
- NTF_BLEEDISH,
- NTF_HUNGRY,
- NTF_THIRSTY,
- NTF_STUFFED,
- NTF_SICK,
- NTF_WETNESS,
- NTF_WARMTH,
- NTF_FEVERISH,
- NTF_BLOOD,
- NTF_LIVES,
- NTF_STAMINA,
- //NTF_AGENT_INFECTION,
- NTF_PILLS,
- NTF_HEARTBEAT,
- NTF_FRACTURE,
- NTF_LEGS,
- //----------------------------
- NTF_COUNT,// !!! LAST ITEM !!!
- }
- class NotifiersManager
- {
- static const int MAX_COUNT = 64;
- ref array<ref NotifierBase> m_Notifiers;
- ref 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
- PlayerBase m_Player;
- ref VirtualHud m_VirtualHud;
- int m_MinTickTime;
- string m_System = "Notifiers";
-
- void NotifiersManager(PlayerBase player)
- {
- m_Player = player;
- m_Notifiers = new array<ref NotifierBase>;
- m_MinTickTime = MIN_TICK_NOTIFIERS;
- Init();
- }
- void Init()
- {
- m_Notifiers.Insert(new HungerNotfr(this));
- m_Notifiers.Insert(new ThirstNotfr(this));
- m_Notifiers.Insert(new WarmthNotfr(this));
- m_Notifiers.Insert(new WetnessNotfr(this));
- m_Notifiers.Insert(new HealthNotfr(this));
- m_Notifiers.Insert(new FeverNotfr(this));
- m_Notifiers.Insert(new SickNotfr(this));
- m_Notifiers.Insert(new StuffedNotfr(this));
- m_Notifiers.Insert(new BloodNotfr(this));
- m_Notifiers.Insert(new PillsNotfr(this));
- m_Notifiers.Insert(new HeartbeatNotfr(this));
- m_Notifiers.Insert(new FracturedLegNotfr(this));
- m_Notifiers.Insert(new InjuredLegNotfr(this));
-
- }
-
- void RegisterItself(int notifier_id, NotifierBase modifier)
- {
- if (notifier_id >= MAX_COUNT)
- Error("out of bounds for notifier id: " + notifier_id);
- else
- m_NotifiersStatic[notifier_id] = modifier;
- }
-
- PlayerBase GetPlayer()
- {
- return m_Player;
- }
- VirtualHud GetVirtualHud()
- {
- return m_VirtualHud;
- }
-
- NotifierBase FindNotifier(int type)
- {
- return m_NotifiersStatic[type];
- }
- void ActivateByType(int notifier, bool triggerEvent = true)
- {
- FindNotifier(notifier).SetActive(true);
- }
- void DeactivateByType(int notifier, bool triggerEvent = true)
- {
- FindNotifier(notifier).SetActive(false);
- }
- void OnScheduledTick()
- {
- if (!GetPlayer().IsPlayerSelected())
- return;
-
- TickNotifiers();
- }
- void TickNotifiers()
- {
- int currentTime = GetGame().GetTime();
- foreach (NotifierBase notifier: m_Notifiers)
- {
- if (notifier.IsActive() && notifier.IsTimeToTick(currentTime))
- notifier.OnTick(currentTime);
- }
- }
- }
|