forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataManagerPlugin.js
More file actions
102 lines (86 loc) · 2.39 KB
/
DataManagerPlugin.js
File metadata and controls
102 lines (86 loc) · 2.39 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../utils/Class');
var DataManager = require('./DataManager');
var PluginManager = require('../boot/PluginManager');
/**
* @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]
*/
var DataManagerPlugin = new Class({
Extends: DataManager,
initialize:
function DataManagerPlugin (scene)
{
/**
* [description]
*
* @name Phaser.Data.DataManagerPlugin#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Data.DataManagerPlugin#systems
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
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);
},
/**
* [description]
*
* @method Phaser.Data.DataManagerPlugin#boot
* @since 3.0.0
*/
boot: function ()
{
var eventEmitter = this.systems.events;
eventEmitter.on('shutdown', this.shutdownPlugin, this);
eventEmitter.on('destroy', this.destroyPlugin, this);
},
/**
* [description]
*
* @method Phaser.Data.DataManagerPlugin#shutdownPlugin
* @since 3.0.0
*/
shutdownPlugin: function ()
{
// Should we reset the events?
},
/**
* [description]
*
* @method Phaser.Data.DataManagerPlugin#destroyPlugin
* @since 3.0.0
*/
destroyPlugin: function ()
{
this.destroy();
this.scene = undefined;
this.systems = undefined;
}
});
PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data');
module.exports = DataManagerPlugin;