phaser/src/scene/GetScenePlugins.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2020-01-15 12:07:09 +00:00
* @copyright 2020 Photon Storm Ltd.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2018-02-12 16:01:20 +00:00
*/
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
*
2018-10-19 11:32:43 +00:00
* @param {Phaser.Scenes.Systems} sys - The Scene Systems object to check for plugins.
2018-02-12 15:18:31 +00:00
*
2018-10-19 11:32:43 +00:00
* @return {array} An array of all plugins which should be activated, either the default ones or the ones configured in the Scene Systems object.
2018-02-12 15:18:31 +00:00
*/
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;