phaser/src/scene/GetScenePlugins.js

42 lines
1 KiB
JavaScript
Raw Normal View History

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}
*/
var GetFastValue = require('../utils/object/GetFastValue');
2018-02-12 15:18:31 +00:00
/**
* Builds an array of which plugins (not including physics plugins) should be activated for the given Scene.
*
* @function Phaser.Scenes.GetScenePlugins
* @since 3.0.0
*
* @param {Phaser.Scenes.Systems} sys - [description]
*
* @return {array} [description]
*/
var GetScenePlugins = function (sys)
{
var defaultPlugins = sys.plugins.getDefaultScenePlugins();
var scenePlugins = GetFastValue(sys.settings, 'plugins', false);
// Scene Plugins always override Default Plugins
if (Array.isArray(scenePlugins))
{
return scenePlugins;
}
else if (defaultPlugins)
{
return defaultPlugins;
}
else
{
// No default plugins or plugins in this scene
return [];
}
};
module.exports = GetScenePlugins;