2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2018-02-12 16:01:20 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-01-09 01:30:10 +00:00
|
|
|
var Class = require('../utils/Class');
|
2019-01-18 13:41:43 +00:00
|
|
|
var GameEvents = require('../core/events');
|
2018-05-11 00:50:37 +00:00
|
|
|
var EventEmitter = require('eventemitter3');
|
2018-05-15 11:52:18 +00:00
|
|
|
var FileTypesManager = require('../loader/FileTypesManager');
|
|
|
|
var GameObjectCreator = require('../gameobjects/GameObjectCreator');
|
|
|
|
var GameObjectFactory = require('../gameobjects/GameObjectFactory');
|
2018-05-11 00:50:37 +00:00
|
|
|
var GetFastValue = require('../utils/object/GetFastValue');
|
2018-05-15 11:52:18 +00:00
|
|
|
var PluginCache = require('./PluginCache');
|
2018-05-15 13:19:56 +00:00
|
|
|
var Remove = require('../utils/array/Remove');
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
2018-05-15 13:19:56 +00:00
|
|
|
* The PluginManager is responsible for installing and adding plugins to Phaser.
|
|
|
|
*
|
|
|
|
* It is a global system and therefore belongs to the Game instance, not a specific Scene.
|
|
|
|
*
|
|
|
|
* It works in conjunction with the PluginCache. Core internal plugins automatically register themselves
|
|
|
|
* with the Cache, but it's the Plugin Manager that is responsible for injecting them into the Scenes.
|
|
|
|
*
|
|
|
|
* There are two types of plugin:
|
|
|
|
*
|
2019-01-18 15:20:56 +00:00
|
|
|
* 1. A Global Plugin
|
|
|
|
* 2. A Scene Plugin
|
2018-05-15 13:19:56 +00:00
|
|
|
*
|
|
|
|
* A Global Plugin is a plugin that lives within the Plugin Manager rather than a Scene. You can get
|
|
|
|
* access to it by calling `PluginManager.get` and providing a key. Any Scene that requests a plugin in
|
|
|
|
* this way will all get access to the same plugin instance, allowing you to use a single plugin across
|
|
|
|
* multiple Scenes.
|
|
|
|
*
|
|
|
|
* A Scene Plugin is a plugin dedicated to running within a Scene. These are different to Global Plugins
|
|
|
|
* in that their instances do not live within the Plugin Manager, but within the Scene Systems class instead.
|
|
|
|
* And that every Scene created is given its own unique instance of a Scene Plugin. Examples of core Scene
|
|
|
|
* Plugins include the Input Plugin, the Tween Plugin and the physics Plugins.
|
|
|
|
*
|
|
|
|
* You can add a plugin to Phaser in three different ways:
|
|
|
|
*
|
2019-01-18 15:20:56 +00:00
|
|
|
* 1. Preload it
|
|
|
|
* 2. Include it in your source code and install it via the Game Config
|
|
|
|
* 3. Include it in your source code and install it within a Scene
|
2018-05-15 13:19:56 +00:00
|
|
|
*
|
|
|
|
* For examples of all of these approaches please see the Phaser 3 Examples Repo `plugins` folder.
|
|
|
|
*
|
|
|
|
* For information on creating your own plugin please see the Phaser 3 Plugin Template.
|
2018-02-12 23:13:16 +00:00
|
|
|
*
|
|
|
|
* @class PluginManager
|
2018-10-10 09:49:13 +00:00
|
|
|
* @memberof Phaser.Plugins
|
2018-02-12 23:13:16 +00:00
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* @param {Phaser.Game} game - The game instance that owns this Plugin Manager.
|
2018-02-12 23:13:16 +00:00
|
|
|
*/
|
2018-01-09 01:30:10 +00:00
|
|
|
var PluginManager = new Class({
|
|
|
|
|
2018-05-11 00:50:37 +00:00
|
|
|
Extends: EventEmitter,
|
|
|
|
|
2018-01-09 01:30:10 +00:00
|
|
|
initialize:
|
|
|
|
|
2018-01-18 13:59:32 +00:00
|
|
|
function PluginManager (game)
|
2018-01-09 01:30:10 +00:00
|
|
|
{
|
2018-05-11 00:50:37 +00:00
|
|
|
EventEmitter.call(this);
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
2018-05-15 13:19:56 +00:00
|
|
|
* The game instance that owns this Plugin Manager.
|
2018-02-12 23:13:16 +00:00
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @name Phaser.Plugins.PluginManager#game
|
2018-02-12 23:13:16 +00:00
|
|
|
* @type {Phaser.Game}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-16 02:08:04 +00:00
|
|
|
this.game = game;
|
2018-01-18 05:21:14 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* The global plugins currently running and managed by this Plugin Manager.
|
|
|
|
* A plugin must have been started at least once in order to appear in this list.
|
|
|
|
*
|
|
|
|
* @name Phaser.Plugins.PluginManager#plugins
|
2019-02-13 15:22:29 +00:00
|
|
|
* @type {Phaser.Plugins.Types.GlobalPlugin[]}
|
2018-05-15 13:19:56 +00:00
|
|
|
* @since 3.8.0
|
|
|
|
*/
|
2018-05-11 15:01:37 +00:00
|
|
|
this.plugins = [];
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* A list of plugin keys that should be installed into Scenes as well as the Core Plugins.
|
|
|
|
*
|
|
|
|
* @name Phaser.Plugins.PluginManager#scenePlugins
|
|
|
|
* @type {string[]}
|
|
|
|
* @since 3.8.0
|
|
|
|
*/
|
2018-05-11 00:50:37 +00:00
|
|
|
this.scenePlugins = [];
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* A temporary list of plugins to install when the game has booted.
|
|
|
|
*
|
|
|
|
* @name Phaser.Plugins.PluginManager#_pendingGlobal
|
|
|
|
* @private
|
|
|
|
* @type {array}
|
|
|
|
* @since 3.8.0
|
|
|
|
*/
|
2018-05-11 15:01:37 +00:00
|
|
|
this._pendingGlobal = [];
|
2018-05-15 13:19:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A temporary list of scene plugins to install when the game has booted.
|
|
|
|
*
|
|
|
|
* @name Phaser.Plugins.PluginManager#_pendingScene
|
|
|
|
* @private
|
|
|
|
* @type {array}
|
|
|
|
* @since 3.8.0
|
|
|
|
*/
|
2018-05-11 15:01:37 +00:00
|
|
|
this._pendingScene = [];
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-10 16:14:33 +00:00
|
|
|
if (game.isBooted)
|
|
|
|
{
|
|
|
|
this.boot();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-18 13:41:43 +00:00
|
|
|
game.events.once(GameEvents.BOOT, this.boot, this);
|
2018-05-10 16:14:33 +00:00
|
|
|
}
|
2018-01-16 02:08:04 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
2018-05-15 13:19:56 +00:00
|
|
|
* Run once the game has booted and installs all of the plugins configured in the Game Config.
|
2018-02-12 23:13:16 +00:00
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#boot
|
2018-05-15 13:19:56 +00:00
|
|
|
* @protected
|
2018-02-12 23:13:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-16 02:08:04 +00:00
|
|
|
boot: function ()
|
|
|
|
{
|
2018-05-11 15:01:37 +00:00
|
|
|
var i;
|
2018-05-11 17:55:44 +00:00
|
|
|
var entry;
|
|
|
|
var key;
|
|
|
|
var plugin;
|
|
|
|
var start;
|
|
|
|
var mapping;
|
2018-07-19 00:21:17 +00:00
|
|
|
var data;
|
2018-05-11 15:01:37 +00:00
|
|
|
var config = this.game.config;
|
2018-05-10 16:14:33 +00:00
|
|
|
|
|
|
|
// Any plugins to install?
|
2018-05-11 15:01:37 +00:00
|
|
|
var list = config.installGlobalPlugins;
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
// Any plugins added outside of the game config, but before the game booted?
|
2018-05-11 15:01:37 +00:00
|
|
|
list = list.concat(this._pendingGlobal);
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
for (i = 0; i < list.length; i++)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 17:55:44 +00:00
|
|
|
entry = list[i];
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-07-19 00:21:17 +00:00
|
|
|
// { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test', data: { msg: 'The plugin is alive' } }
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 17:55:44 +00:00
|
|
|
key = GetFastValue(entry, 'key', null);
|
|
|
|
plugin = GetFastValue(entry, 'plugin', null);
|
|
|
|
start = GetFastValue(entry, 'start', false);
|
2018-05-18 17:43:27 +00:00
|
|
|
mapping = GetFastValue(entry, 'mapping', null);
|
2018-07-19 00:21:17 +00:00
|
|
|
data = GetFastValue(entry, 'data', null);
|
2018-05-11 13:06:51 +00:00
|
|
|
|
|
|
|
if (key && plugin)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-07-19 00:21:17 +00:00
|
|
|
this.install(key, plugin, start, mapping, data);
|
2018-05-10 16:14:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
// Any scene plugins to install?
|
|
|
|
list = config.installScenePlugins;
|
|
|
|
|
|
|
|
// Any plugins added outside of the game config, but before the game booted?
|
|
|
|
list = list.concat(this._pendingScene);
|
|
|
|
|
|
|
|
for (i = 0; i < list.length; i++)
|
|
|
|
{
|
2018-05-11 17:55:44 +00:00
|
|
|
entry = list[i];
|
2018-05-11 15:01:37 +00:00
|
|
|
|
|
|
|
// { key: 'moveSpritePlugin', plugin: MoveSpritePlugin, , mapping: 'move' }
|
|
|
|
|
2018-05-11 17:55:44 +00:00
|
|
|
key = GetFastValue(entry, 'key', null);
|
|
|
|
plugin = GetFastValue(entry, 'plugin', null);
|
|
|
|
mapping = GetFastValue(entry, 'mapping', null);
|
2018-05-11 15:01:37 +00:00
|
|
|
|
|
|
|
if (key && plugin)
|
|
|
|
{
|
|
|
|
this.installScenePlugin(key, plugin, mapping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this._pendingGlobal = [];
|
|
|
|
this._pendingScene = [];
|
|
|
|
|
2019-01-18 13:41:43 +00:00
|
|
|
this.game.events.once(GameEvents.DESTROY, this.destroy, this);
|
2018-01-16 02:08:04 +00:00
|
|
|
},
|
2018-01-09 01:30:10 +00:00
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
2018-05-15 13:19:56 +00:00
|
|
|
* Called by the Scene Systems class. Tells the plugin manager to install all Scene plugins into it.
|
2018-02-12 23:13:16 +00:00
|
|
|
*
|
2018-05-18 17:43:27 +00:00
|
|
|
* First it will install global references, i.e. references from the Game systems into the Scene Systems (and Scene if mapped.)
|
|
|
|
* Then it will install Core Scene Plugins followed by Scene Plugins registered with the PluginManager.
|
|
|
|
* Finally it will install any references to Global Plugins that have a Scene mapping property into the Scene itself.
|
|
|
|
*
|
2018-05-15 11:52:18 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#addToScene
|
2018-05-15 13:19:56 +00:00
|
|
|
* @protected
|
2018-05-15 11:52:18 +00:00
|
|
|
* @since 3.8.0
|
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* @param {Phaser.Scenes.Systems} sys - The Scene Systems class to install all the plugins in to.
|
|
|
|
* @param {array} globalPlugins - An array of global plugins to install.
|
|
|
|
* @param {array} scenePlugins - An array of scene plugins to install.
|
2018-05-15 11:52:18 +00:00
|
|
|
*/
|
|
|
|
addToScene: function (sys, globalPlugins, scenePlugins)
|
|
|
|
{
|
2018-05-15 13:19:56 +00:00
|
|
|
var i;
|
|
|
|
var pluginKey;
|
2018-05-18 17:43:27 +00:00
|
|
|
var pluginList;
|
2018-05-11 00:50:37 +00:00
|
|
|
var game = this.game;
|
2018-01-18 05:21:14 +00:00
|
|
|
var scene = sys.scene;
|
|
|
|
var map = sys.settings.map;
|
2018-05-15 13:19:56 +00:00
|
|
|
var isBooted = sys.settings.isBooted;
|
2018-01-16 02:08:04 +00:00
|
|
|
|
2018-01-18 05:21:14 +00:00
|
|
|
// Reference the GlobalPlugins from Game into Scene.Systems
|
2018-05-15 13:19:56 +00:00
|
|
|
for (i = 0; i < globalPlugins.length; i++)
|
2018-01-16 02:08:04 +00:00
|
|
|
{
|
2018-05-15 13:19:56 +00:00
|
|
|
pluginKey = globalPlugins[i];
|
2019-02-13 15:22:29 +00:00
|
|
|
|
2018-01-30 13:15:50 +00:00
|
|
|
if (game[pluginKey])
|
2018-01-18 05:21:14 +00:00
|
|
|
{
|
2018-01-30 13:15:50 +00:00
|
|
|
sys[pluginKey] = game[pluginKey];
|
|
|
|
|
|
|
|
// Scene level injection
|
|
|
|
if (map.hasOwnProperty(pluginKey))
|
|
|
|
{
|
|
|
|
scene[map[pluginKey]] = sys[pluginKey];
|
|
|
|
}
|
2018-01-18 05:21:14 +00:00
|
|
|
}
|
2018-08-07 10:19:20 +00:00
|
|
|
else if (pluginKey === 'game' && map.hasOwnProperty(pluginKey))
|
|
|
|
{
|
|
|
|
scene[map[pluginKey]] = game;
|
|
|
|
}
|
2018-01-16 22:28:29 +00:00
|
|
|
}
|
2018-01-18 05:21:14 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
for (var s = 0; s < scenePlugins.length; s++)
|
2018-01-16 22:28:29 +00:00
|
|
|
{
|
2018-05-18 17:43:27 +00:00
|
|
|
pluginList = scenePlugins[s];
|
2018-01-18 05:21:14 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
for (i = 0; i < pluginList.length; i++)
|
2018-01-30 13:15:50 +00:00
|
|
|
{
|
2018-05-15 13:19:56 +00:00
|
|
|
pluginKey = pluginList[i];
|
2018-01-30 13:15:50 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
if (!PluginCache.hasCore(pluginKey))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2018-01-18 05:21:14 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
var source = PluginCache.getCore(pluginKey);
|
2018-01-17 03:41:58 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
var plugin = new source.plugin(scene, this);
|
|
|
|
|
|
|
|
sys[source.mapping] = plugin;
|
2018-01-18 13:59:32 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
// Scene level injection
|
|
|
|
if (source.custom)
|
|
|
|
{
|
|
|
|
scene[source.mapping] = plugin;
|
|
|
|
}
|
|
|
|
else if (map.hasOwnProperty(source.mapping))
|
|
|
|
{
|
|
|
|
scene[map[source.mapping]] = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scene is already booted, usually because this method is being called at run-time, so boot the plugin
|
|
|
|
if (isBooted)
|
|
|
|
{
|
|
|
|
plugin.boot();
|
|
|
|
}
|
2018-01-16 02:08:04 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-18 17:43:27 +00:00
|
|
|
|
|
|
|
// And finally, inject any 'global scene plugins'
|
|
|
|
pluginList = this.plugins;
|
|
|
|
|
|
|
|
for (i = 0; i < pluginList.length; i++)
|
|
|
|
{
|
|
|
|
var entry = pluginList[i];
|
2019-02-13 15:22:29 +00:00
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
if (entry.mapping)
|
|
|
|
{
|
|
|
|
scene[entry.mapping] = entry.plugin;
|
|
|
|
}
|
|
|
|
}
|
2018-01-09 01:30:10 +00:00
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Called by the Scene Systems class. Returns a list of plugins to be installed.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#getDefaultScenePlugins
|
|
|
|
* @protected
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @return {string[]} A list keys of all the Scene Plugins to install.
|
|
|
|
*/
|
2018-05-11 15:01:37 +00:00
|
|
|
getDefaultScenePlugins: function ()
|
|
|
|
{
|
|
|
|
var list = this.game.config.defaultPlugins;
|
|
|
|
|
|
|
|
// Merge in custom Scene plugins
|
|
|
|
list = list.concat(this.scenePlugins);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Installs a new Scene Plugin into the Plugin Manager and optionally adds it
|
|
|
|
* to the given Scene as well. A Scene Plugin added to the manager in this way
|
|
|
|
* will be automatically installed into all new Scenes using the key and mapping given.
|
|
|
|
*
|
|
|
|
* The `key` property is what the plugin is injected into Scene.Systems as.
|
|
|
|
* The `mapping` property is optional, and if specified is what the plugin is installed into
|
|
|
|
* the Scene as. For example:
|
|
|
|
*
|
|
|
|
* ```javascript
|
|
|
|
* this.plugins.installScenePlugin('powerupsPlugin', pluginCode, 'powerups');
|
|
|
|
*
|
|
|
|
* // and from within the scene:
|
|
|
|
* this.sys.powerupsPlugin; // key value
|
|
|
|
* this.powerups; // mapping value
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* This method is called automatically by Phaser if you install your plugins using either the
|
|
|
|
* Game Configuration object, or by preloading them via the Loader.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#installScenePlugin
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The property key that will be used to add this plugin to Scene.Systems.
|
|
|
|
* @param {function} plugin - The plugin code. This should be the non-instantiated version.
|
|
|
|
* @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use.
|
|
|
|
* @param {Phaser.Scene} [addToScene] - Optionally automatically add this plugin to the given Scene.
|
|
|
|
*/
|
2018-05-11 17:22:28 +00:00
|
|
|
installScenePlugin: function (key, plugin, mapping, addToScene)
|
2018-05-11 15:01:37 +00:00
|
|
|
{
|
|
|
|
if (typeof plugin !== 'function')
|
|
|
|
{
|
|
|
|
console.warn('Invalid Scene Plugin: ' + key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-15 11:52:18 +00:00
|
|
|
if (PluginCache.hasCore(key))
|
2018-05-11 15:01:37 +00:00
|
|
|
{
|
|
|
|
console.warn('Scene Plugin key in use: ' + key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-15 11:52:18 +00:00
|
|
|
PluginCache.register(key, plugin, mapping, true);
|
2018-05-11 15:01:37 +00:00
|
|
|
|
|
|
|
this.scenePlugins.push(key);
|
2018-05-11 17:22:28 +00:00
|
|
|
|
|
|
|
if (addToScene)
|
|
|
|
{
|
|
|
|
var instance = new plugin(addToScene, this);
|
|
|
|
|
|
|
|
addToScene.sys[key] = instance;
|
|
|
|
|
|
|
|
if (mapping && mapping !== '')
|
|
|
|
{
|
|
|
|
addToScene[mapping] = instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance.boot();
|
|
|
|
}
|
2018-05-11 15:01:37 +00:00
|
|
|
},
|
|
|
|
|
2018-05-10 16:14:33 +00:00
|
|
|
/**
|
2018-05-15 13:19:56 +00:00
|
|
|
* Installs a new Global Plugin into the Plugin Manager and optionally starts it running.
|
|
|
|
* A global plugin belongs to the Plugin Manager, rather than a specific Scene, and can be accessed
|
|
|
|
* and used by all Scenes in your game.
|
|
|
|
*
|
|
|
|
* The `key` property is what you use to access this plugin from the Plugin Manager.
|
|
|
|
*
|
|
|
|
* ```javascript
|
|
|
|
* this.plugins.install('powerupsPlugin', pluginCode);
|
2018-05-10 16:14:33 +00:00
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* // and from within the scene:
|
|
|
|
* this.plugins.get('powerupsPlugin');
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* This method is called automatically by Phaser if you install your plugins using either the
|
|
|
|
* Game Configuration object, or by preloading them via the Loader.
|
|
|
|
*
|
|
|
|
* The same plugin can be installed multiple times into the Plugin Manager by simply giving each
|
|
|
|
* instance its own unique key.
|
2018-05-10 16:14:33 +00:00
|
|
|
*
|
2018-05-11 13:06:51 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#install
|
2018-05-10 16:14:33 +00:00
|
|
|
* @since 3.8.0
|
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* @param {string} key - The unique handle given to this plugin within the Plugin Manager.
|
|
|
|
* @param {function} plugin - The plugin code. This should be the non-instantiated version.
|
2018-05-18 17:43:27 +00:00
|
|
|
* @param {boolean} [start=false] - Automatically start the plugin running? This is always `true` if you provide a mapping value.
|
|
|
|
* @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use.
|
2018-07-19 00:21:17 +00:00
|
|
|
* @param {any} [data] - A value passed to the plugin's `init` method.
|
2018-10-23 12:28:56 +00:00
|
|
|
*
|
|
|
|
* @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if `start` was false, or game isn't yet booted.
|
2018-05-10 16:14:33 +00:00
|
|
|
*/
|
2018-07-19 00:21:17 +00:00
|
|
|
install: function (key, plugin, start, mapping, data)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 00:50:37 +00:00
|
|
|
if (start === undefined) { start = false; }
|
2018-05-18 17:43:27 +00:00
|
|
|
if (mapping === undefined) { mapping = null; }
|
2018-07-19 00:21:17 +00:00
|
|
|
if (data === undefined) { data = null; }
|
2018-05-11 00:50:37 +00:00
|
|
|
|
|
|
|
if (typeof plugin !== 'function')
|
|
|
|
{
|
|
|
|
console.warn('Invalid Plugin: ' + key);
|
2018-10-23 12:28:56 +00:00
|
|
|
return null;
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 11:52:18 +00:00
|
|
|
if (PluginCache.hasCustom(key))
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
|
|
|
console.warn('Plugin key in use: ' + key);
|
2018-10-23 12:28:56 +00:00
|
|
|
return null;
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
if (mapping !== null)
|
|
|
|
{
|
|
|
|
start = true;
|
|
|
|
}
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
if (!this.game.isBooted)
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
2018-07-19 00:21:17 +00:00
|
|
|
this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping, data: data });
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
2018-05-11 13:06:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Add it to the plugin store
|
2018-07-19 00:21:17 +00:00
|
|
|
PluginCache.registerCustom(key, plugin, mapping, data);
|
2018-05-11 00:50:37 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
if (start)
|
|
|
|
{
|
|
|
|
return this.start(key);
|
|
|
|
}
|
|
|
|
}
|
2018-10-23 12:28:56 +00:00
|
|
|
|
|
|
|
return null;
|
2018-05-11 13:06:51 +00:00
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Gets an index of a global plugin based on the given key.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#getIndex
|
|
|
|
* @protected
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The unique plugin key.
|
|
|
|
*
|
|
|
|
* @return {integer} The index of the plugin within the plugins array.
|
|
|
|
*/
|
2018-05-11 13:06:51 +00:00
|
|
|
getIndex: function (key)
|
|
|
|
{
|
|
|
|
var list = this.plugins;
|
|
|
|
|
|
|
|
for (var i = 0; i < list.length; i++)
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
2018-05-11 13:06:51 +00:00
|
|
|
var entry = list[i];
|
2018-05-11 00:50:37 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
if (entry.key === key)
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Gets a global plugin based on the given key.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#getEntry
|
|
|
|
* @protected
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The unique plugin key.
|
|
|
|
*
|
2019-02-13 15:22:29 +00:00
|
|
|
* @return {Phaser.Plugins.Types.GlobalPlugin} The plugin entry.
|
2018-05-15 13:19:56 +00:00
|
|
|
*/
|
2018-05-11 13:06:51 +00:00
|
|
|
getEntry: function (key)
|
|
|
|
{
|
|
|
|
var idx = this.getIndex(key);
|
|
|
|
|
|
|
|
if (idx !== -1)
|
|
|
|
{
|
|
|
|
return this.plugins[idx];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Checks if the given global plugin, based on its key, is active or not.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#isActive
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The unique plugin key.
|
|
|
|
*
|
|
|
|
* @return {boolean} `true` if the plugin is active, otherwise `false`.
|
|
|
|
*/
|
2018-05-11 13:06:51 +00:00
|
|
|
isActive: function (key)
|
|
|
|
{
|
|
|
|
var entry = this.getEntry(key);
|
|
|
|
|
|
|
|
return (entry && entry.active);
|
2018-05-10 16:14:33 +00:00
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Starts a global plugin running.
|
|
|
|
*
|
|
|
|
* If the plugin was previously active then calling `start` will reset it to an active state and then
|
|
|
|
* call its `start` method.
|
|
|
|
*
|
|
|
|
* If the plugin has never been run before a new instance of it will be created within the Plugin Manager,
|
|
|
|
* its active state set and then both of its `init` and `start` methods called, in that order.
|
|
|
|
*
|
|
|
|
* If the plugin is already running under the given key then nothing happens.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#start
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the plugin to start.
|
|
|
|
* @param {string} [runAs] - Run the plugin under a new key. This allows you to run one plugin multiple times.
|
|
|
|
*
|
|
|
|
* @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if invalid key given or plugin is already stopped.
|
|
|
|
*/
|
2018-05-11 13:06:51 +00:00
|
|
|
start: function (key, runAs)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 13:06:51 +00:00
|
|
|
if (runAs === undefined) { runAs = key; }
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
var entry = this.getEntry(runAs);
|
|
|
|
|
|
|
|
// Plugin already running under this key?
|
|
|
|
if (entry && !entry.active)
|
|
|
|
{
|
|
|
|
// It exists, we just need to start it up again
|
|
|
|
entry.active = true;
|
|
|
|
entry.plugin.start();
|
|
|
|
}
|
|
|
|
else if (!entry)
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
2018-05-18 17:43:27 +00:00
|
|
|
entry = this.createEntry(key, runAs);
|
|
|
|
}
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
return (entry) ? entry.plugin : null;
|
|
|
|
},
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
/**
|
|
|
|
* Creates a new instance of a global plugin, adds an entry into the plugins array and returns it.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#createEntry
|
|
|
|
* @private
|
|
|
|
* @since 3.9.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the plugin to create an instance of.
|
|
|
|
* @param {string} [runAs] - Run the plugin under a new key. This allows you to run one plugin multiple times.
|
|
|
|
*
|
|
|
|
* @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if invalid key given.
|
|
|
|
*/
|
|
|
|
createEntry: function (key, runAs)
|
|
|
|
{
|
|
|
|
var entry = PluginCache.getCustom(key);
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
var instance = new entry.plugin(this);
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
entry = {
|
|
|
|
key: runAs,
|
|
|
|
plugin: instance,
|
|
|
|
active: true,
|
2018-07-19 00:21:17 +00:00
|
|
|
mapping: entry.mapping,
|
|
|
|
data: entry.data
|
2018-05-18 17:43:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
this.plugins.push(entry);
|
|
|
|
|
2018-07-19 00:21:17 +00:00
|
|
|
instance.init(entry.data);
|
2018-05-18 17:43:27 +00:00
|
|
|
instance.start();
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
return entry;
|
2018-05-11 13:06:51 +00:00
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Stops a global plugin from running.
|
|
|
|
*
|
|
|
|
* If the plugin is active then its active state will be set to false and the plugins `stop` method
|
|
|
|
* will be called.
|
|
|
|
*
|
|
|
|
* If the plugin is not already running, nothing will happen.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#stop
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the plugin to stop.
|
|
|
|
*
|
|
|
|
* @return {Phaser.Plugins.PluginManager} The Plugin Manager.
|
|
|
|
*/
|
2018-05-11 13:06:51 +00:00
|
|
|
stop: function (key)
|
|
|
|
{
|
|
|
|
var entry = this.getEntry(key);
|
|
|
|
|
|
|
|
if (entry && entry.active)
|
|
|
|
{
|
|
|
|
entry.active = false;
|
|
|
|
entry.plugin.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Gets a global plugin from the Plugin Manager based on the given key and returns it.
|
|
|
|
*
|
|
|
|
* If it cannot find an active plugin based on the key, but there is one in the Plugin Cache with the same key,
|
|
|
|
* then it will create a new instance of the cached plugin and return that.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#get
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the plugin to get.
|
2018-05-16 13:35:45 +00:00
|
|
|
* @param {boolean} [autoStart=true] - Automatically start a new instance of the plugin if found in the cache, but not actively running.
|
2018-05-15 13:19:56 +00:00
|
|
|
*
|
2018-05-16 13:35:45 +00:00
|
|
|
* @return {?(Phaser.Plugins.BasePlugin|function)} The plugin, or `null` if no plugin was found matching the key.
|
2018-05-15 13:19:56 +00:00
|
|
|
*/
|
2018-05-16 13:35:45 +00:00
|
|
|
get: function (key, autoStart)
|
2018-05-11 13:06:51 +00:00
|
|
|
{
|
2018-05-16 13:35:45 +00:00
|
|
|
if (autoStart === undefined) { autoStart = true; }
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
var entry = this.getEntry(key);
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
return entry.plugin;
|
|
|
|
}
|
2018-05-15 13:19:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
var plugin = this.getClass(key);
|
|
|
|
|
2018-05-16 13:35:45 +00:00
|
|
|
if (plugin && autoStart)
|
2018-05-15 13:19:56 +00:00
|
|
|
{
|
2018-05-18 17:43:27 +00:00
|
|
|
entry = this.createEntry(key, key);
|
2018-05-15 13:19:56 +00:00
|
|
|
|
2018-05-18 17:43:27 +00:00
|
|
|
return (entry) ? entry.plugin : null;
|
2018-05-15 13:19:56 +00:00
|
|
|
}
|
2018-05-16 13:35:45 +00:00
|
|
|
else if (plugin)
|
|
|
|
{
|
|
|
|
return plugin;
|
|
|
|
}
|
2018-05-15 13:19:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2018-05-10 16:14:33 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2018-05-15 13:19:56 +00:00
|
|
|
* Returns the plugin class from the cache.
|
|
|
|
* Used internally by the Plugin Manager.
|
2018-05-10 16:14:33 +00:00
|
|
|
*
|
2018-05-11 13:06:51 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#getClass
|
2018-05-10 16:14:33 +00:00
|
|
|
* @since 3.8.0
|
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* @param {string} key - The key of the plugin to get.
|
2018-05-10 16:14:33 +00:00
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* @return {Phaser.Plugins.BasePlugin} A Plugin object
|
2018-05-10 16:14:33 +00:00
|
|
|
*/
|
2018-05-11 13:06:51 +00:00
|
|
|
getClass: function (key)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-15 11:52:18 +00:00
|
|
|
return PluginCache.getCustomClass(key);
|
2018-05-10 16:14:33 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
2018-05-15 13:19:56 +00:00
|
|
|
* Removes a global plugin from the Plugin Manager and Plugin Cache.
|
2018-02-12 23:13:16 +00:00
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* It is up to you to remove all references to this plugin that you may hold within your game code.
|
2018-02-12 23:13:16 +00:00
|
|
|
*
|
2018-05-15 13:19:56 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#removeGlobalPlugin
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the plugin to remove.
|
2018-02-12 23:13:16 +00:00
|
|
|
*/
|
2018-05-15 13:19:56 +00:00
|
|
|
removeGlobalPlugin: function (key)
|
2018-01-16 02:08:04 +00:00
|
|
|
{
|
2018-05-15 13:19:56 +00:00
|
|
|
var entry = this.getEntry(key);
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
Remove(this.plugins, entry);
|
|
|
|
}
|
|
|
|
|
2018-05-15 11:52:18 +00:00
|
|
|
PluginCache.removeCustom(key);
|
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Removes a scene plugin from the Plugin Manager and Plugin Cache.
|
|
|
|
*
|
|
|
|
* This will not remove the plugin from any active Scenes that are already using it.
|
|
|
|
*
|
|
|
|
* It is up to you to remove all references to this plugin that you may hold within your game code.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#removeScenePlugin
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the plugin to remove.
|
|
|
|
*/
|
|
|
|
removeScenePlugin: function (key)
|
|
|
|
{
|
|
|
|
Remove(this.scenePlugins, key);
|
2018-05-15 11:52:18 +00:00
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
PluginCache.remove(key);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a new type of Game Object with the global Game Object Factory and / or Creator.
|
|
|
|
* This is usually called from within your Plugin code and is a helpful short-cut for creating
|
|
|
|
* new Game Objects.
|
|
|
|
*
|
|
|
|
* The key is the property that will be injected into the factories and used to create the
|
|
|
|
* Game Object. For example:
|
|
|
|
*
|
|
|
|
* ```javascript
|
|
|
|
* this.plugins.registerGameObject('clown', clownFactoryCallback, clownCreatorCallback);
|
|
|
|
* // later in your game code:
|
|
|
|
* this.add.clown();
|
|
|
|
* this.make.clown();
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* The callbacks are what are called when the factories try to create a Game Object
|
|
|
|
* matching the given key. It's important to understand that the callbacks are invoked within
|
|
|
|
* the context of the GameObjectFactory. In this context there are several properties available
|
|
|
|
* to use:
|
|
|
|
*
|
|
|
|
* this.scene - A reference to the Scene that owns the GameObjectFactory.
|
|
|
|
* this.displayList - A reference to the Display List the Scene owns.
|
|
|
|
* this.updateList - A reference to the Update List the Scene owns.
|
|
|
|
*
|
|
|
|
* See the GameObjectFactory and GameObjectCreator classes for more details.
|
|
|
|
* Any public property or method listed is available from your callbacks under `this`.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#registerGameObject
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`.
|
|
|
|
* @param {function} [factoryCallback] - The callback to invoke when the Game Object Factory is called.
|
|
|
|
* @param {function} [creatorCallback] - The callback to invoke when the Game Object Creator is called.
|
|
|
|
*/
|
2018-05-15 11:52:18 +00:00
|
|
|
registerGameObject: function (key, factoryCallback, creatorCallback)
|
|
|
|
{
|
|
|
|
if (factoryCallback)
|
|
|
|
{
|
|
|
|
GameObjectFactory.register(key, factoryCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (creatorCallback)
|
|
|
|
{
|
|
|
|
GameObjectCreator.register(key, creatorCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-05-15 13:19:56 +00:00
|
|
|
/**
|
|
|
|
* Registers a new file type with the global File Types Manager, making it available to all Loader
|
|
|
|
* Plugins created after this.
|
|
|
|
*
|
|
|
|
* This is usually called from within your Plugin code and is a helpful short-cut for creating
|
|
|
|
* new loader file types.
|
|
|
|
*
|
|
|
|
* The key is the property that will be injected into the Loader Plugin and used to load the
|
|
|
|
* files. For example:
|
|
|
|
*
|
|
|
|
* ```javascript
|
|
|
|
* this.plugins.registerFileType('wad', doomWadLoaderCallback);
|
|
|
|
* // later in your preload code:
|
|
|
|
* this.load.wad();
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* The callback is what is called when the loader tries to load a file matching the given key.
|
|
|
|
* It's important to understand that the callback is invoked within
|
|
|
|
* the context of the LoaderPlugin. In this context there are several properties / methods available
|
|
|
|
* to use:
|
|
|
|
*
|
|
|
|
* this.addFile - A method to add the new file to the load queue.
|
|
|
|
* this.scene - The Scene that owns the Loader Plugin instance.
|
|
|
|
*
|
|
|
|
* See the LoaderPlugin class for more details. Any public property or method listed is available from
|
|
|
|
* your callback under `this`.
|
|
|
|
*
|
|
|
|
* @method Phaser.Plugins.PluginManager#registerFileType
|
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`.
|
|
|
|
* @param {function} callback - The callback to invoke when the Game Object Factory is called.
|
2018-05-18 17:43:27 +00:00
|
|
|
* @param {Phaser.Scene} [addToScene] - Optionally add this file type into the Loader Plugin owned by the given Scene.
|
2018-05-15 13:19:56 +00:00
|
|
|
*/
|
2018-05-18 17:43:27 +00:00
|
|
|
registerFileType: function (key, callback, addToScene)
|
2018-05-15 11:52:18 +00:00
|
|
|
{
|
|
|
|
FileTypesManager.register(key, callback);
|
2018-05-18 17:43:27 +00:00
|
|
|
|
|
|
|
if (addToScene && addToScene.sys.load)
|
|
|
|
{
|
|
|
|
addToScene.sys.load[key] = callback;
|
|
|
|
}
|
2018-01-16 02:08:04 +00:00
|
|
|
},
|
2018-01-09 01:30:10 +00:00
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
2018-05-15 13:19:56 +00:00
|
|
|
* Destroys this Plugin Manager and all associated plugins.
|
|
|
|
* It will iterate all plugins found and call their `destroy` methods.
|
2018-07-31 09:28:36 +00:00
|
|
|
*
|
|
|
|
* The PluginCache will remove all custom plugins.
|
2018-02-12 23:13:16 +00:00
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#destroy
|
2018-05-15 13:19:56 +00:00
|
|
|
* @since 3.8.0
|
2018-02-12 23:13:16 +00:00
|
|
|
*/
|
2018-01-16 02:08:04 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
2018-05-15 13:19:56 +00:00
|
|
|
for (var i = 0; i < this.plugins.length; i++)
|
|
|
|
{
|
2018-05-17 11:16:14 +00:00
|
|
|
this.plugins[i].plugin.destroy();
|
2018-05-15 13:19:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-31 09:28:36 +00:00
|
|
|
PluginCache.destroyCustomPlugins();
|
|
|
|
|
|
|
|
if (this.game.noReturn)
|
|
|
|
{
|
|
|
|
PluginCache.destroyCorePlugins();
|
|
|
|
}
|
|
|
|
|
2018-01-31 03:38:10 +00:00
|
|
|
this.game = null;
|
2018-05-15 13:19:56 +00:00
|
|
|
this.plugins = [];
|
|
|
|
this.scenePlugins = [];
|
2018-01-16 02:08:04 +00:00
|
|
|
}
|
2018-01-09 01:30:10 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
/*
|
|
|
|
* "Sometimes, the elegant implementation is just a function.
|
|
|
|
* Not a method. Not a class. Not a framework. Just a function."
|
|
|
|
* -- John Carmack
|
|
|
|
*/
|
|
|
|
|
2018-01-09 01:30:10 +00:00
|
|
|
module.exports = PluginManager;
|