2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 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
|
|
|
*/
|
|
|
|
|
2018-01-18 05:20:57 +00:00
|
|
|
var GetFastValue = require('../utils/object/GetFastValue');
|
2018-01-18 05:33:54 +00:00
|
|
|
var UppercaseFirst = require('../utils/string/UppercaseFirst');
|
2018-01-18 05:20:57 +00:00
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
|
|
|
* Builds an array of which physics plugins should be activated for the given Scene.
|
|
|
|
*
|
|
|
|
* @function Phaser.Scenes.GetPhysicsPlugins
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-22 06:50:09 +00:00
|
|
|
* @param {Phaser.Scenes.Systems} sys - The scene system to get the physics systems of.
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
2018-04-22 06:50:09 +00:00
|
|
|
* @return {array} An array of Physics systems to start for this Scene.
|
2018-02-12 15:18:31 +00:00
|
|
|
*/
|
2018-01-18 05:20:57 +00:00
|
|
|
var GetPhysicsPlugins = function (sys)
|
|
|
|
{
|
|
|
|
var defaultSystem = sys.game.config.defaultPhysicsSystem;
|
|
|
|
var sceneSystems = GetFastValue(sys.settings, 'physics', false);
|
|
|
|
|
|
|
|
if (!defaultSystem && !sceneSystems)
|
|
|
|
{
|
|
|
|
// No default physics system or systems in this scene
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Let's build the systems array
|
|
|
|
var output = [];
|
|
|
|
|
|
|
|
if (defaultSystem)
|
|
|
|
{
|
2018-01-18 05:33:54 +00:00
|
|
|
output.push(UppercaseFirst(defaultSystem + 'Physics'));
|
2018-01-18 05:20:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sceneSystems)
|
|
|
|
{
|
|
|
|
for (var key in sceneSystems)
|
|
|
|
{
|
2018-01-18 05:33:54 +00:00
|
|
|
key = UppercaseFirst(key.concat('Physics'));
|
2018-01-18 05:20:57 +00:00
|
|
|
|
|
|
|
if (output.indexOf(key) === -1)
|
|
|
|
{
|
|
|
|
output.push(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// An array of Physics systems to start for this Scene
|
|
|
|
return output;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetPhysicsPlugins;
|