11var Class = require ( '../utils/Class' ) ;
2+ var CoreScenePlugins = require ( '../CoreScenePlugins' ) ;
23var EventEmitter = require ( 'eventemitter3' ) ;
34var GetFastValue = require ( '../utils/object/GetFastValue' ) ;
4- var ScenePlugin = require ( './ScenePlugin' ) ;
5+ var GetPhysicsPlugins = require ( './GetPhysicsPlugins' ) ;
6+ var GetScenePlugins = require ( './GetScenePlugins' ) ;
7+ var GlobalPlugins = require ( '../GlobalPlugins' ) ;
58var Settings = require ( './Settings' ) ;
69
710var Systems = new Class ( {
@@ -23,23 +26,22 @@ var Systems = new Class({
2326 this . canvas ;
2427 this . context ;
2528
26- // Global Systems - these are global managers (belonging to Game)
29+ // Global Systems - these are single-instance global managers that belong to Game
2730
2831 this . anims ;
2932 this . cache ;
3033 this . registry ;
3134 this . sound ;
3235 this . textures ;
3336
34- // These are core Scene plugins, needed by lots of the global systems (and each other)
37+ // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems
3538
3639 this . add ;
3740 this . cameras ;
3841 this . displayList ;
3942 this . events ;
4043 this . make ;
41- this . sceneManager ;
42- this . time ;
44+ this . scenePlugin ;
4345 this . updateList ;
4446 } ,
4547
@@ -49,79 +51,17 @@ var Systems = new Class({
4951
5052 this . game = game ;
5153
52- // Global Systems - these are global managers (belonging to Game)
54+ game . plugins . installGlobal ( this , GlobalPlugins ) ;
5355
54- this . anims = game . anims ;
55- this . cache = game . cache ;
56- this . registry = game . registry ;
57- this . sound = game . sound ;
58- this . textures = game . textures ;
56+ game . plugins . installLocal ( this , CoreScenePlugins ) ;
5957
60- // These are core Scene plugins, needed by lots of the global systems (and each other)
58+ game . plugins . installLocal ( this , GetScenePlugins ( this ) ) ;
6159
62- this . events = new EventEmitter ( ) ;
63-
64- game . plugins . install ( scene ,
65- [ 'anims' , 'cache' , 'registry' , 'sound' , 'textures' ] ,
66- [ 'displayList' , 'updateList' , 'sceneManager' , 'time' , 'cameras' , 'add' , 'make' , 'load' , 'tweens' , 'input' ]
67- ) ;
68-
69- var physics = this . getPhysicsSystem ( ) ;
70-
71- if ( physics )
72- {
73- game . plugins . install ( scene , [ ] , physics ) ;
74- }
60+ game . plugins . installLocal ( this , GetPhysicsPlugins ( this ) ) ;
7561
7662 this . events . emit ( 'boot' , this ) ;
7763 } ,
7864
79- getPhysicsSystem : function ( )
80- {
81- var defaultSystem = this . game . config . defaultPhysicsSystem ;
82- var sceneSystems = GetFastValue ( this . settings , 'physics' , false ) ;
83-
84- if ( ! defaultSystem && ! sceneSystems )
85- {
86- // No default physics system or systems in this scene
87- return ;
88- }
89-
90- // Let's build the systems array
91- var output = [ ] ;
92-
93- if ( defaultSystem )
94- {
95- output . push ( defaultSystem + 'Physics' ) ;
96- }
97-
98- if ( sceneSystems )
99- {
100- for ( var key in sceneSystems )
101- {
102- key = key . concat ( 'Physics' ) ;
103-
104- if ( output . indexOf ( key ) === - 1 )
105- {
106- output . push ( key ) ;
107- }
108- }
109- }
110-
111- // An array of Physics systems to start for this Scene
112- return output ;
113- } ,
114-
115- inject : function ( plugin )
116- {
117- var map = this . settings . map ;
118-
119- if ( plugin . mapping && map . hasOwnProperty ( plugin . mapping ) )
120- {
121- this . scene [ plugin . mapping ] = plugin ;
122- }
123- } ,
124-
12565 step : function ( time , delta )
12666 {
12767 this . events . emit ( 'preupdate' , time , delta ) ;
0 commit comments