var Class = require('../utils/Class'); var DataManager = require('./DataManager'); var PluginManager = require('../boot/PluginManager'); var DataManagerPlugin = new Class({ Extends: DataManager, initialize: function DataManagerPlugin(scene){ DataManager.call(this, this.scene, scene.sys.events); this.scene = scene; this.systems = scene.sys; scene.sys.events.on('start', this.start, this); } , start: function (){ this.events = this.scene.sys.events; var eventEmitter = this.systems.events; eventEmitter.once('shutdown', this.shutdown, this); eventEmitter.once('destroy', this.destroy, this); } , shutdown: function (){ var eventEmitter = this.systems.events; eventEmitter.off('shutdown', this.shutdown, this); } , destroy: function (){ DataManager.prototype.destroy.call(this); this.scene.sys.events.off('start', this.start, this); this.scene = null ; this.systems = null ; } } ); PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data'); module.exports = DataManagerPlugin;