Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
pluginmanager.c
Go to the documentation of this file.
1
class
PluginManager
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
//=================================
9
void
PluginManager
()
10
{
11
m_PluginRegister
=
new
array<typename>
;
12
m_PluginsPtrs
=
new
map<typename, ref PluginBase>
;
13
}
14
15
//=================================
16
// Destructor
17
//=================================
18
void
~PluginManager
()
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
33
g_Game
.GetUpdateQueue(
CALL_CATEGORY_GAMEPLAY
).Remove(this.
MainOnUpdate
);
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
#ifdef NO_GUI
61
RegisterPluginDiag
(
"PluginKeyBinding"
,
true
,
false
);
62
#else
63
RegisterPluginDiag
(
"PluginKeyBinding"
,
true
,
true
);
64
#endif
65
RegisterPluginDiag
(
"PluginDeveloper"
,
true
,
true
);
66
RegisterPluginDiag
(
"PluginDeveloperSync"
,
true
,
true
);
67
RegisterPluginDiag
(
"PluginDiagMenuClient"
,
true
,
false
);
68
RegisterPluginDiag
(
"PluginDiagMenuServer"
,
false
,
true
);
69
RegisterPluginDiag
(
"PluginPermanentCrossHair"
,
true
,
false
);
70
RegisterPluginDiag
(
"PluginRemotePlayerDebugClient"
,
true
,
false
);
71
RegisterPluginDiag
(
"PluginRemotePlayerDebugServer"
,
false
,
true
);
72
RegisterPluginDiag
(
"PluginUniversalTemperatureSourceClient"
,
true
,
false
);
73
RegisterPluginDiag
(
"PluginUniversalTemperatureSourceServer"
,
false
,
true
);
74
RegisterPluginDiag
(
"PluginTargetTemperature"
,
true
,
false
);
75
RegisterPluginDiag
(
"PluginDrawCheckerboard"
,
true
,
false
);
76
RegisterPluginDiag
(
"PluginItemDiagnostic"
,
true
,
true
);
77
RegisterPluginDiag
(
"PluginDayZCreatureAIDebug"
,
true
,
true
);
78
79
// Only In Debug / Internal
80
RegisterPluginDebug
(
"PluginConfigViewer"
,
true
,
true
);
81
RegisterPluginDebug
(
"PluginLocalEnscriptHistory"
,
true
,
true
);
82
RegisterPluginDebug
(
"PluginLocalEnscriptHistoryServer"
,
true
,
true
);
83
84
RegisterPluginDebug
(
"PluginSceneManager"
,
true
,
true
);
85
RegisterPluginDebug
(
"PluginConfigScene"
,
true
,
true
);
86
RegisterPluginDebug
(
"PluginMissionConfig"
,
true
,
true
);
87
RegisterPluginDebug
(
"PluginConfigEmotesProfile"
,
true
,
true
);
88
RegisterPluginDebug
(
"PluginConfigDebugProfile"
,
true
,
true
);
89
RegisterPluginDebug
(
"PluginConfigDebugProfileFixed"
,
true
,
true
);
90
91
RegisterPluginDebug
(
"PluginDayzPlayerDebug"
,
true
,
true
);
92
RegisterPluginDebug
(
"PluginDayZInfectedDebug"
,
true
,
true
);
93
RegisterPluginDebug
(
"PluginDoorRuler"
,
true
,
false
);
94
RegisterPluginDebug
(
"PluginCharPlacement"
,
true
,
false
);
95
//RegisterPluginDebug( "PluginSoundDebug", false, false );
96
RegisterPluginDebug
(
"PluginCameraTools"
,
true
,
true
);
97
RegisterPluginDebug
(
"PluginNutritionDumper"
,
true
,
false
);
98
#ifdef DIAG_DEVELOPER
99
RegisterPluginDebug
(
"PluginInventoryDebug"
,
true
,
true
);
100
#endif
101
RegisterPluginDebug
(
"PluginInventoryRepair"
,
true
,
false
);
102
103
g_Game
.GetUpdateQueue(
CALL_CATEGORY_GAMEPLAY
).Insert(
MainOnUpdate
);
104
}
105
106
//=================================
107
// PluginsInit
108
//=================================
109
void
PluginsInit
()
110
{
111
int
i = 0;
112
int
regCount =
m_PluginRegister
.Count();
113
114
array<PluginBase>
pluginPtrs = {};
115
pluginPtrs.Reserve(regCount);
116
117
foreach
(
typename
pluginType :
m_PluginRegister
)
118
{
119
PluginBase
moduleExist =
GetPluginByType
( pluginType );
120
if
( moduleExist )
121
{
122
m_PluginsPtrs
.Remove( pluginType );
123
}
124
125
PluginBase
moduleNew =
PluginBase
.Cast(pluginType.Spawn());
126
m_PluginsPtrs
.Set(pluginType, moduleNew);
127
pluginPtrs.Insert(moduleNew);
128
}
129
130
foreach
(
PluginBase
plugin : pluginPtrs)
131
{
132
if
( plugin )
133
{
134
plugin.OnInit();
135
}
136
}
137
}
138
139
//=================================
140
// MainOnUpdate
141
//=================================
142
void
MainOnUpdate
(
float
delta_time)
143
{
144
int
nPlugins =
m_PluginsPtrs
.Count();
145
for
(
int
i = 0; i < nPlugins; ++i)
146
{
147
PluginBase
plugin =
m_PluginsPtrs
.GetElement(i);
148
if
( plugin != NULL )
149
{
150
plugin.
OnUpdate
(delta_time);
151
}
152
}
153
}
154
163
//=================================
164
// GetPluginByType
165
//=================================
166
PluginBase
GetPluginByType
(
typename
plugin_type )
167
{
168
if
(
m_PluginsPtrs
.Contains( plugin_type ) )
169
{
170
return
m_PluginsPtrs
.Get( plugin_type );
171
}
172
173
return
null;
174
}
175
189
//=================================
190
// RegisterPlugin
191
//=================================
192
protected
void
RegisterPlugin
(
string
plugin_class_name,
bool
reg_on_client,
bool
reg_on_server,
bool
reg_on_release =
true
)
193
{
194
if
( !reg_on_client )
195
{
196
if
(
g_Game
.IsMultiplayer() &&
g_Game
.IsClient() )
197
{
198
return
;
199
}
200
}
201
202
if
( !reg_on_server )
203
{
204
if
(
g_Game
.IsMultiplayer() )
205
{
206
if
(
g_Game
.IsServer() )
207
{
208
return
;
209
}
210
}
211
}
212
213
if
( !reg_on_release )
214
{
215
if
( !
g_Game
.IsDebug() )
216
{
217
return
;
218
}
219
}
220
221
m_PluginRegister
.Insert( plugin_class_name.
ToType
() );
222
}
223
237
//=================================
238
// RegisterPlugin
239
//=================================
240
protected
void
RegisterPluginDebug
(
string
plugin_class_name,
bool
reg_on_client,
bool
reg_on_server )
241
{
242
RegisterPlugin
(plugin_class_name, reg_on_client, reg_on_server,
false
);
243
}
244
//=================================
245
// RegisterPlugin
246
//=================================
247
protected
void
RegisterPluginDiag
(
string
plugin_class_name,
bool
reg_on_client,
bool
reg_on_server )
248
{
249
#ifdef DIAG_DEVELOPER
250
RegisterPlugin
(plugin_class_name, reg_on_client, reg_on_server,
true
);
251
#else
252
return
;
253
#endif
254
}
255
256
//---------------------------------
257
// UnregisterPlugin
258
//---------------------------------
259
protected
bool
UnregisterPlugin
(
string
plugin_class_name )
260
{
261
typename
plugin_type = plugin_class_name.
ToType
();
262
263
if
(
m_PluginRegister
.Find( plugin_type ) != -1 )
264
{
265
m_PluginRegister
.RemoveItem( plugin_type );
266
return
true
;
267
}
268
269
return
false
;
270
}
271
}
272
273
ref
PluginManager
g_Plugins
;
274
283
PluginManager
GetPluginManager
()
284
{
285
/*
286
if ( g_Plugins == NULL )
287
{
288
PluginManagerInit();
289
}
290
*/
291
292
return
g_Plugins
;
293
}
294
295
296
void
PluginManagerInit
()
297
{
298
if
(
g_Plugins
== NULL)
299
{
300
g_Plugins
=
new
PluginManager
;
301
g_Plugins
.Init();
302
g_Plugins
.PluginsInit();
303
}
304
}
305
306
void
PluginManagerDelete
()
307
{
308
if
(
g_Plugins
)
309
{
310
delete
g_Plugins
;
311
g_Plugins
= NULL;
312
}
313
}
314
315
bool
IsPluginManagerExists
()
316
{
317
if
(
g_Plugins
!= null )
318
{
319
return
true
;
320
}
321
322
return
false
;
323
}
324
325
PluginBase
GetPlugin
(
typename
plugin_type)
326
{
327
PluginBase
plugin = null;
328
329
if
(
IsPluginManagerExists
() )
330
{
331
plugin =
GetPluginManager
().
GetPluginByType
(plugin_type);
332
333
if
( plugin == null )
334
{
335
#ifdef DIAG_DEVELOPER
336
if
(
IsPluginManagerExists
() )
337
{
338
PrintString
(
"Module "
+ plugin_type.ToString() +
" is not Registred in PluginManager.c!"
);
339
DumpStack
();
340
}
341
#endif
342
}
343
}
344
345
return
plugin;
346
}
347
348
// Inspired by BaseItem::SafeCast, no asserts version
349
PluginBase
GetPluginSafe
(
typename
plugin_type)
350
{
351
PluginBase
plugin = null;
352
353
if
(
IsPluginManagerExists
() )
354
{
355
plugin =
GetPluginManager
().
GetPluginByType
(plugin_type);
356
}
357
358
return
plugin;
359
}
360
361
bool
IsModuleExist
(
typename
plugin_type)
362
{
363
if
(
IsPluginManagerExists
() )
364
{
365
return
(
GetPlugin
(plugin_type) != NULL );
366
}
367
368
return
false
;
369
}
PluginBase
Class PluginMessageManager provides some basic Message Distribution mechanics, if you get instance of...
Definition
pluginbase.c:2
PluginBase::OnDestroy
void OnDestroy()
PluginBase::OnUpdate
void OnUpdate(float delta_time)
PluginManager
Definition
pluginmanager.c:2
PluginManager::RegisterPlugin
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.
Definition
pluginmanager.c:192
PluginManager::MainOnUpdate
void MainOnUpdate(float delta_time)
Definition
pluginmanager.c:142
PluginManager::Init
void Init()
Definition
pluginmanager.c:39
PluginManager::PluginsInit
void PluginsInit()
Definition
pluginmanager.c:109
PluginManager::m_PluginRegister
ref array< typename > m_PluginRegister
Definition
pluginmanager.c:3
PluginManager::GetPluginByType
PluginBase GetPluginByType(typename plugin_type)
Returns registred plugin by class type, better is to use global funtion GetPlugin(typename plugin_typ...
Definition
pluginmanager.c:166
PluginManager::m_PluginsPtrs
ref map< typename, ref PluginBase > m_PluginsPtrs
Definition
pluginmanager.c:4
PluginManager::UnregisterPlugin
bool UnregisterPlugin(string plugin_class_name)
Definition
pluginmanager.c:259
PluginManager::~PluginManager
void ~PluginManager()
Definition
pluginmanager.c:18
PluginManager::PluginManager
void PluginManager()
Definition
pluginmanager.c:9
PluginManager::RegisterPluginDiag
void RegisterPluginDiag(string plugin_class_name, bool reg_on_client, bool reg_on_server)
Definition
pluginmanager.c:247
PluginManager::RegisterPluginDebug
void RegisterPluginDebug(string plugin_class_name, bool reg_on_client, bool reg_on_server)
Register new PluginBase to PluginManager for storing and handling plugin.
Definition
pluginmanager.c:240
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
map
Definition
cachedequipmentstorage.c:4
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
DumpStack
proto void DumpStack()
Prints current call stack (stack trace).
PrintString
class array< Class T > PrintString
string::ToType
proto native ToType()
Returns internal type representation.
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition
tools.c:10
GetPluginManager
PluginManager GetPluginManager()
Returns registred plugin by class type, better is to use global funtion GetPlugin(typename plugin_typ...
Definition
pluginmanager.c:283
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition
pluginmanager.c:325
IsPluginManagerExists
bool IsPluginManagerExists()
Definition
pluginmanager.c:315
IsModuleExist
bool IsModuleExist(typename plugin_type)
Definition
pluginmanager.c:361
GetPluginSafe
PluginBase GetPluginSafe(typename plugin_type)
Definition
pluginmanager.c:349
g_Plugins
class PluginManager g_Plugins
PluginManagerInit
void PluginManagerInit()
Definition
pluginmanager.c:296
PluginManagerDelete
void PluginManagerDelete()
Definition
pluginmanager.c:306
Games
Dayz
scripts
4_world
plugins
pluginmanager.c
Generated by
1.17.0