2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-01-30 00:55:27 +00:00
|
|
|
var Class = require('../utils/Class');
|
|
|
|
var DataManager = require('./DataManager');
|
2018-02-12 23:03:48 +00:00
|
|
|
var PluginManager = require('../boot/PluginManager');
|
2018-01-30 00:55:27 +00:00
|
|
|
|
2018-02-12 22:16:18 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin.
|
|
|
|
* You can then search, query it, and retrieve the data. The parent must either extend EventEmitter,
|
|
|
|
* or have a property called `events` that is an instance of it.
|
|
|
|
*
|
|
|
|
* @class DataManagerPlugin
|
|
|
|
* @extends Phaser.Data.DataManager
|
|
|
|
* @memberOf Phaser.Data
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Scene} scene - [description]
|
|
|
|
*/
|
2018-01-30 00:55:27 +00:00
|
|
|
var DataManagerPlugin = new Class({
|
|
|
|
|
|
|
|
Extends: DataManager,
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
|
|
|
function DataManagerPlugin (scene)
|
|
|
|
{
|
2018-02-12 22:16:18 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Data.DataManagerPlugin#scene
|
|
|
|
* @type {Phaser.Scene}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-30 00:55:27 +00:00
|
|
|
this.scene = scene;
|
|
|
|
|
2018-02-12 22:16:18 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Data.DataManagerPlugin#systems
|
|
|
|
* @type {Phaser.Scenes.Systems}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-30 00:55:27 +00:00
|
|
|
this.systems = scene.sys;
|
|
|
|
|
|
|
|
if (!scene.sys.settings.isBooted)
|
|
|
|
{
|
|
|
|
scene.sys.events.once('boot', this.boot, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
DataManager.call(this, this.scene, scene.sys.events);
|
|
|
|
},
|
|
|
|
|
2018-02-12 22:16:18 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Data.DataManagerPlugin#boot
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-30 00:55:27 +00:00
|
|
|
boot: function ()
|
|
|
|
{
|
|
|
|
var eventEmitter = this.systems.events;
|
|
|
|
|
|
|
|
eventEmitter.on('shutdown', this.shutdownPlugin, this);
|
|
|
|
eventEmitter.on('destroy', this.destroyPlugin, this);
|
|
|
|
},
|
|
|
|
|
2018-02-12 22:16:18 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Data.DataManagerPlugin#shutdownPlugin
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-30 00:55:27 +00:00
|
|
|
shutdownPlugin: function ()
|
|
|
|
{
|
|
|
|
// Should we reset the events?
|
|
|
|
},
|
|
|
|
|
2018-02-12 22:16:18 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Data.DataManagerPlugin#destroyPlugin
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-30 00:55:27 +00:00
|
|
|
destroyPlugin: function ()
|
|
|
|
{
|
|
|
|
this.destroy();
|
|
|
|
|
|
|
|
this.scene = undefined;
|
|
|
|
this.systems = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data');
|
|
|
|
|
|
|
|
module.exports = DataManagerPlugin;
|