Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
modifierbase.c
Go to the documentation of this file.
1 enum eModifiersTickType//bitmask
2 {
3  TICK = 1,
6 }
7 
8 
9 class ModifierBase
10 {
11  int m_ID = 0;
12  ModifiersManager m_Manager;//the manager instance
13  string m_System = "Modifiers";
14  float m_ActivatedTime;//overall time this modifier was active
15  bool m_TrackActivatedTime;//should this modifier track overall time it was active ?
16  bool m_IsPersistent;//is this modifier saved to the DB ?
20  bool m_IsActive;
25  int m_TickType = (eModifiersTickType.TICK | eModifiersTickType.ACTIVATE_CHECK | eModifiersTickType.DEACTIVATE_CHECK);//some modifiers do not need to check activate condition, as they get activated by request
27  bool m_IsLocked = false;
29  eModifierSyncIDs m_SyncID;//max 32 synced modifiers supported, 0 == no sync
30  PluginPlayerStatus m_ModulePlayerStatus;
31 
32  void ModifierBase()
33  {
34  Class.CastTo(m_ModulePlayerStatus, GetPlugin(PluginPlayerStatus));
35  }
36 
37  void InitBase(PlayerBase player, ModifiersManager manager)
38  {
39  m_Manager = manager;
40  m_Player = player;
41  Init();
42  }
43 
44  void Init(){}
45 
46 
48  {
49  return m_Player;
50  }
51 
52  bool IsPersistent()
53  {
54  return m_IsPersistent;
55  }
56 
58  {
59  m_Manager.m_ParamList.Insert(object);
60  }
61 
62 
64  {
66  }
67 
68  string GetDebugText()
69  {
70  return "";
71  }
72 
73  string GetDebugTextSimple()
74  {
75  return "";
76  }
77 
79  {
80  m_TickType = (m_TickType & ~eModifiersTickType.ACTIVATE_CHECK);
81  }
82 
84  {
85  m_TickType = (m_TickType & ~eModifiersTickType.DEACTIVATE_CHECK);
86  }
87 
88  void Tick(float delta_time)
89  {
90 
92  {
93  Activate();
94  }
95 
96  if( m_IsActive )
97  {
98  m_AccumulatedTimeActive += delta_time;
100  {
101  if( m_TickType & eModifiersTickType.DEACTIVATE_CHECK && DeactivateCondition(m_Player) && !IsLocked() )
102  {
103  Deactivate();
104  }
105  else//if(m_TickType & eModifiersTickType.TICK)
106  {
109  }
111  }
112  }
113  else if(m_TickType & eModifiersTickType.ACTIVATE_CHECK)
114  {
115  m_AccumulatedTimeInactive += delta_time;
117  {
118  if( ActivateCondition(m_Player) )
119  {
120  if( !IsLocked() )
121  {
122  ActivateRequest(EActivationType.TRIGGER_EVENT_ON_ACTIVATION);
123  }
124  }
126  }
127  }
128  }
129 
130  bool IsActive()
131  {
132  return m_IsActive;
133  }
134 
135  void SetLock(bool state)
136  {
137  m_IsLocked = state;
138  }
139 
140  bool IsLocked()
141  {
142  return m_IsLocked;
143  }
144 
146  {
147  return m_TrackActivatedTime;
148  }
149 
151  {
152  return m_ActivatedTime;
153  }
154 
155  void SetAttachedTime(float time)
156  {
157  m_ActivatedTime = time;
158  }
159 
161  {
162  return m_ID;
163  }
164 
165  string GetName()
166  {
167  string name = ClassName();
168  int index_start = name.Length() - 4;
169  int index_end = name.Length();
170  name = name.SubstringInverted(name, index_start, index_end);
171  return name;
172  }
173 
174  bool ActivateCondition(PlayerBase player)
175  {
176  return false;
177  }
178 
179  bool DeactivateCondition(PlayerBase player)
180  {
181  return false;
182  }
183 
185  void OnActivate(PlayerBase player)
186  {
187 
188  }
189 
191  void OnReconnect(PlayerBase player)
192  {
193 
194  }
195 
197  {
198 
199  }
200 
201  void Activate()
202  {
203  m_IsActive = true;
204  m_Player.m_SyncedModifiers = (m_Player.m_SyncedModifiers | m_SyncID);
205  if( m_ActivationType == EActivationType.TRIGGER_EVENT_ON_ACTIVATION ) OnActivate(m_Player);
206  else if(m_ActivationType == EActivationType.TRIGGER_EVENT_ON_CONNECT ) OnReconnect(m_Player);
207  m_Player.SetSynchDirty();
208  }
209 
211  {
212  m_ShouldBeActive = true;
213  m_ActivationType = trigger;
214  }
215 
216  void Deactivate(bool trigger = true)
217  {
218  if(!m_IsActive)
219  return;
220  m_Player.m_SyncedModifiers = (m_Player.m_SyncedModifiers & ~m_SyncID);
221  m_ShouldBeActive = false;
222  m_IsActive = false;
223  m_ActivatedTime = 0;
224  if(trigger)
226  }
227 
228 
230  {
231  }
232 
233 
234  private void OnTick(PlayerBase player, float deltaT)
235  {
236 
237  }
238 }
m_TickType
int m_TickType
Definition: modifierbase.c:25
eModifiersTickType
eModifiersTickType
Definition: modifierbase.c:1
m_LastTickedActive
float m_LastTickedActive
Definition: modifierbase.c:24
m_ShouldBeActive
bool m_ShouldBeActive
Definition: modifierbase.c:21
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
TICK
@ TICK
Definition: modifierbase.c:3
m_SyncID
eModifierSyncIDs m_SyncID
Definition: modifierbase.c:29
m_ID
enum eModifiersTickType m_ID
m_ActivationType
EActivationType m_ActivationType
Definition: modifierbase.c:28
Activate
void Activate()
Definition: modifierbase.c:201
m_Manager
ModifiersManager m_Manager
Definition: modifierbase.c:12
IsPersistent
bool IsPersistent()
Definition: modifierbase.c:52
GetName
string GetName()
Gets the name which is set for the ParticleManager, default is "ParticleSourceManager".
Definition: modifierbase.c:165
GetPlayer
PlayerBase GetPlayer()
Definition: modifierbase.c:47
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
Tick
void Tick(float delta_time)
Definition: modifierbase.c:88
m_IsLocked
bool m_IsLocked
Definition: modifierbase.c:27
m_System
string m_System
Definition: modifierbase.c:13
Deactivate
void Deactivate(bool trigger=true)
Definition: modifierbase.c:216
EActivationType
EActivationType
Definition: modifiersmanager.c:24
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
DisableDeactivateCheck
void DisableDeactivateCheck()
Definition: modifierbase.c:83
OnActivate
void OnActivate(PlayerBase player)
is called when an inactive modifier gets activated during gameplay, is NOT called on activation upon ...
Definition: modifierbase.c:185
ModifierBase
void ModifierBase()
Definition: modifierbase.c:32
PlayerBase
Definition: playerbaseclient.c:1
ModifiersManager
void ModifiersManager(PlayerBase player)
Definition: modifiersmanager.c:80
m_IsActive
bool m_IsActive
Definition: modifierbase.c:20
DEACTIVATE_CHECK
@ DEACTIVATE_CHECK
Definition: modifierbase.c:5
IsTrackAttachedTime
bool IsTrackAttachedTime()
Definition: modifierbase.c:145
m_TickIntervalInactive
float m_TickIntervalInactive
Definition: modifierbase.c:18
ModifierBase
Definition: breathvapourmdfr.c:3
m_IsPersistent
bool m_IsPersistent
Definition: modifierbase.c:16
m_LastTickedInactive
float m_LastTickedInactive
Definition: modifierbase.c:26
GetAttachedTime
float GetAttachedTime()
Definition: modifierbase.c:150
OnDeactivate
void OnDeactivate(PlayerBase player)
Definition: modifierbase.c:196
m_ActivatedTime
float m_ActivatedTime
Definition: modifierbase.c:14
IsLocked
bool IsLocked()
Definition: modifierbase.c:140
eModifierSyncIDs
eModifierSyncIDs
Definition: modifiersmanager.c:2
m_ModulePlayerStatus
PluginPlayerStatus m_ModulePlayerStatus
Definition: modifierbase.c:30
m_Player
PlayerBase m_Player
Definition: modifierbase.c:17
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
Definition: modifierbase.c:229
m_AccumulatedTimeActive
float m_AccumulatedTimeActive
Definition: modifierbase.c:22
DisableActivateCheck
void DisableActivateCheck()
Definition: modifierbase.c:78
IsActive
bool IsActive()
Definition: modifierbase.c:130
SetLock
void SetLock(bool state)
Definition: modifierbase.c:135
ACTIVATE_CHECK
@ ACTIVATE_CHECK
Definition: modifierbase.c:4
MakeParamObjectPersistent
void MakeParamObjectPersistent(Param object)
Definition: modifierbase.c:57
m_AccumulatedTimeInactive
float m_AccumulatedTimeInactive
Definition: modifierbase.c:23
SetAttachedTime
void SetAttachedTime(float time)
Definition: modifierbase.c:155
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
ResetLastTickTime
void ResetLastTickTime()
Definition: modifierbase.c:63
GetModifierID
int GetModifierID()
Definition: modifierbase.c:160
InitBase
void InitBase(PlayerBase player, ModifiersManager manager)
Definition: modifierbase.c:37
ActivateRequest
void ActivateRequest(EActivationType trigger)
Definition: modifierbase.c:210