DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginManager.c
См. документацию.
2{
3 private ref array<typename> m_PluginRegister; // list of modules for creation
4 private ref map<typename, ref PluginBase> m_PluginsPtrs; // plugin, plugin pointer
5
6 //=================================
7 // Constructor
8 //=================================
14
15 //=================================
16 // Destructor
17 //=================================
19 {
20 int i;
21 PluginBase plugin;
22
23 for ( i = 0; i < m_PluginsPtrs.Count(); ++i)
24 {
25 plugin = m_PluginsPtrs.GetElement(i);
26 if ( plugin != NULL )
27 {
28 plugin.OnDestroy();
29 delete plugin;
30 }
31 }
32
34 }
35
36 //=================================
37 // Init
38 //=================================
39 void Init()
40 {
41 //----------------------------------------------------------------------
42 // Register modules
43 //----------------------------------------------------------------------
44 // Module Class Name Client Server
45 //----------------------------------------------------------------------
46 RegisterPlugin( "PluginHorticulture", true, true );
47 RegisterPlugin( "PluginRepairing", true, true );
48 RegisterPlugin( "PluginPlayerStatus", true, true );
49 RegisterPlugin( "PluginMessageManager", true, true );
50 RegisterPlugin( "PluginLifespan", true, true );
51 RegisterPlugin( "PluginVariables", true, true );
52 RegisterPlugin( "PluginObjectsInteractionManager", false, true );
53 RegisterPlugin( "PluginRecipesManager", true, true );
54 RegisterPlugin( "PluginTransmissionAgents", true, true );
55 RegisterPlugin( "PluginConfigEmotesProfile", true, true );
56 RegisterPlugin( "PluginPresenceNotifier", true, false );
57 RegisterPlugin( "PluginAdminLog", false, true );
58
59 // Developer + Diag
60 RegisterPluginDiag( "PluginKeyBinding", true, false );
61 RegisterPluginDiag( "PluginDeveloper", true, true );
62 RegisterPluginDiag( "PluginDeveloperSync", true, true );
63 RegisterPluginDiag( "PluginDiagMenuClient", true, false );
64 RegisterPluginDiag( "PluginDiagMenuServer", false, true );
65 RegisterPluginDiag( "PluginPermanentCrossHair", true, false );
66 RegisterPluginDiag( "PluginRemotePlayerDebugClient", true, false );
67 RegisterPluginDiag( "PluginRemotePlayerDebugServer", false, true );
68 RegisterPluginDiag( "PluginUniversalTemperatureSourceClient", true, false );
69 RegisterPluginDiag( "PluginUniversalTemperatureSourceServer", false, true );
70 RegisterPluginDiag( "PluginTargetTemperature", true, false );
71 RegisterPluginDiag( "PluginDrawCheckerboard", true, false );
72 RegisterPluginDiag( "PluginItemDiagnostic", true, true );
73 RegisterPluginDiag( "PluginDayZCreatureAIDebug", true, true );
74
75 // Only In Debug / Internal
76 RegisterPluginDebug( "PluginConfigViewer", true, true );
77 RegisterPluginDebug( "PluginLocalEnscriptHistory", true, true );
78 RegisterPluginDebug( "PluginLocalEnscriptHistoryServer", true, true );
79
80 RegisterPluginDebug( "PluginSceneManager", true, true );
81 RegisterPluginDebug( "PluginConfigScene", true, true );
82 RegisterPluginDebug( "PluginMissionConfig", true, true );
83 RegisterPluginDebug( "PluginConfigEmotesProfile", true, true );
84 RegisterPluginDebug( "PluginConfigDebugProfile", true, true );
85 RegisterPluginDebug( "PluginConfigDebugProfileFixed", true, true );
86
87 RegisterPluginDebug( "PluginDayzPlayerDebug", true, true );
88 RegisterPluginDebug( "PluginDayZInfectedDebug", true, true );
89 RegisterPluginDebug( "PluginDoorRuler", true, false );
90 RegisterPluginDebug( "PluginCharPlacement", true, false );
91 //RegisterPluginDebug( "PluginSoundDebug", false, false );
92 RegisterPluginDebug( "PluginCameraTools", true, true );
93 RegisterPluginDebug( "PluginNutritionDumper", true, false );
94
96 }
97
98 //=================================
99 // PluginsInit
100 //=================================
102 {
103 int i = 0;
104 int regCount = m_PluginRegister.Count();
105
106 array<PluginBase> pluginPtrs = {};
107 pluginPtrs.Reserve(regCount);
108
109 foreach (typename pluginType : m_PluginRegister)
110 {
111 PluginBase moduleExist = GetPluginByType( pluginType );
112 if ( moduleExist )
113 {
114 m_PluginsPtrs.Remove( pluginType );
115 }
116
117 PluginBase moduleNew = PluginBase.Cast(pluginType.Spawn());
118 m_PluginsPtrs.Set(pluginType, moduleNew);
119 pluginPtrs.Insert(moduleNew);
120 }
121
122 foreach (PluginBase plugin : pluginPtrs)
123 {
124 if ( plugin )
125 {
126 plugin.OnInit();
127 }
128 }
129 }
130
131 //=================================
132 // MainOnUpdate
133 //=================================
134 void MainOnUpdate(float delta_time)
135 {
136 for ( int i = 0; i < m_PluginsPtrs.Count(); ++i)
137 {
138 PluginBase plugin = m_PluginsPtrs.GetElement(i);
139 if ( plugin != NULL )
140 {
141 plugin.OnUpdate(delta_time);
142 }
143 }
144 }
145
154 //=================================
155 // GetPluginByType
156 //=================================
157 PluginBase GetPluginByType( typename plugin_type )
158 {
159 if ( m_PluginsPtrs.Contains( plugin_type ) )
160 {
161 return m_PluginsPtrs.Get( plugin_type );
162 }
163
164 return null;
165 }
166
180 //=================================
181 // RegisterPlugin
182 //=================================
183 protected void RegisterPlugin( string plugin_class_name, bool reg_on_client, bool reg_on_server, bool reg_on_release = true )
184 {
185 if ( !reg_on_client )
186 {
187 if ( GetGame().IsMultiplayer() && GetGame().IsClient() )
188 {
189 return;
190 }
191 }
192
193 if ( !reg_on_server )
194 {
195 if ( GetGame().IsMultiplayer() )
196 {
197 if ( GetGame().IsServer() )
198 {
199 return;
200 }
201 }
202 }
203
204 if ( !reg_on_release )
205 {
206 if ( !GetGame().IsDebug() )
207 {
208 return;
209 }
210 }
211
212 m_PluginRegister.Insert( plugin_class_name.ToType() );
213 }
214
228 //=================================
229 // RegisterPlugin
230 //=================================
231 protected void RegisterPluginDebug( string plugin_class_name, bool reg_on_client, bool reg_on_server )
232 {
233 RegisterPlugin(plugin_class_name, reg_on_client, reg_on_server, false);
234 }
235 //=================================
236 // RegisterPlugin
237 //=================================
238 protected void RegisterPluginDiag( string plugin_class_name, bool reg_on_client, bool reg_on_server )
239 {
240 #ifdef DIAG_DEVELOPER
241 RegisterPlugin(plugin_class_name, reg_on_client, reg_on_server, true);
242 #else
243 return;
244 #endif
245 }
246
247 //---------------------------------
248 // UnregisterPlugin
249 //---------------------------------
250 protected bool UnregisterPlugin( string plugin_class_name )
251 {
252 typename plugin_type = plugin_class_name.ToType();
253
254 if ( m_PluginRegister.Find( plugin_type ) != -1 )
255 {
256 m_PluginRegister.RemoveItem( plugin_type );
257 return true;
258 }
259
260 return false;
261 }
262}
263
265
275{
276 /*
277 if ( g_Plugins == NULL )
278 {
279 PluginManagerInit();
280 }
281 */
282
283 return g_Plugins;
284}
285
286
288{
289 if (g_Plugins == NULL)
290 {
292 g_Plugins.Init();
293 g_Plugins.PluginsInit();
294 }
295}
296
298{
299 if ( g_Plugins )
300 {
301 delete g_Plugins;
302 g_Plugins = NULL;
303 }
304}
305
307{
308 if ( g_Plugins != null )
309 {
310 return true;
311 }
312
313 return false;
314}
315
316PluginBase GetPlugin(typename plugin_type)
317{
318 PluginBase plugin = null;
319
320 if ( IsPluginManagerExists() )
321 {
322 plugin = GetPluginManager().GetPluginByType(plugin_type);
323
324 if ( plugin == null )
325 {
326 #ifdef DIAG_DEVELOPER
327 if ( IsPluginManagerExists() )
328 {
329 PrintString("Module " + plugin_type.ToString() + " is not Registred in PluginManager.c!");
330 DumpStack();
331 }
332 #endif
333 }
334 }
335
336 return plugin;
337}
338
339bool IsModuleExist(typename plugin_type)
340{
341 if ( IsPluginManagerExists() )
342 {
343 return ( GetPlugin(plugin_type) != NULL );
344 }
345
346 return false;
347}
map
Определения ControlsXboxNew.c:4
PluginManager GetPluginManager()
Returns registred plugin by class type, better is to use global funtion GetPlugin(typename plugin_typ...
Определения PluginManager.c:274
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
bool IsPluginManagerExists()
Определения PluginManager.c:306
bool IsModuleExist(typename plugin_type)
Определения PluginManager.c:339
class PluginManager g_Plugins
void PluginManagerInit()
Определения PluginManager.c:287
void PluginManagerDelete()
Определения PluginManager.c:297
override ScriptInvoker GetUpdateQueue(int call_category)
Определения DayZGame.c:1192
void OnDestroy()
void OnUpdate(float delta_time)
Определения PluginBase.c:2
PluginBase GetPluginByType(typename plugin_type)
Returns registred plugin by class type, better is to use global funtion GetPlugin(typename plugin_typ...
Определения PluginManager.c:157
void RegisterPluginDebug(string plugin_class_name, bool reg_on_client, bool reg_on_server)
Register new PluginBase to PluginManager for storing and handling plugin.
Определения PluginManager.c:231
void ~PluginManager()
Определения PluginManager.c:18
void PluginsInit()
Определения PluginManager.c:101
bool UnregisterPlugin(string plugin_class_name)
Определения PluginManager.c:250
ref map< typename, ref PluginBase > m_PluginsPtrs
Определения PluginManager.c:4
void RegisterPluginDiag(string plugin_class_name, bool reg_on_client, bool reg_on_server)
Определения PluginManager.c:238
void MainOnUpdate(float delta_time)
Определения PluginManager.c:134
ref array< typename > m_PluginRegister
Определения PluginManager.c:3
void Init()
Определения PluginManager.c:39
void PluginManager()
Определения PluginManager.c:9
void RegisterPlugin(string plugin_class_name, bool reg_on_client, bool reg_on_server, bool reg_on_release=true)
Register new PluginBase to PluginManager for storing and handling plugin.
Определения PluginManager.c:183
Определения PluginManager.c:2
proto bool Remove(func fn, int flags=EScriptInvokerRemoveFlags.ALL)
remove specific call from list
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto void DumpStack()
Prints current call stack (stack trace)
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Определения EnScript.c:345
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...
const int CALL_CATEGORY_GAMEPLAY
Определения tools.c:10