forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginManager.js
More file actions
67 lines (49 loc) · 1.33 KB
/
Copy pathPluginManager.js
File metadata and controls
67 lines (49 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var Class = require('../utils/Class');
var plugins = {};
var PluginManager = new Class({
initialize:
// The PluginManager is global and belongs to the Game instance, not a Scene.
function PluginManager (game, config)
{
this.game = game;
},
boot: function ()
{
},
install: function (scene, globalPlugins, localPlugins)
{
var i;
var pluginKey;
var sys = scene.sys;
for (var i = 0; i < globalPlugins.length; i++)
{
pluginKey = globalPlugins[i];
sys.scene[pluginKey] = sys[pluginKey];
}
for (var i = 0; i < localPlugins.length; i++)
{
pluginKey = localPlugins[i];
if (plugins[pluginKey])
{
// console.log('installing', pluginKey);
// Install a local reference inside of Systems
sys[pluginKey] = new plugins[pluginKey](scene);
}
}
},
remove: function (key)
{
delete plugins[key];
},
destroy: function ()
{
plugins = {};
}
});
// Static method called directly by the Plugins
PluginManager.register = function (key, plugin)
{
plugins[key] = plugin;
// console.log('PluginManager.register', key);
};
module.exports = PluginManager;