r3-legacy/src/game-lib-d3-api-broadphase.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-06-23 16:04:42 +02:00
/**
* Raw Broadphase API object - should always correspond with the Broadphase Schema
* @param id
* @param name
* @param broadphaseType
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Broadphase = function(
id,
name,
broadphaseType,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Broadphase (' + this.id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(broadphaseType)) {
broadphaseType = GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE;
}
this.broadphaseType = broadphaseType;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
GameLib.D3.API.Broadphase.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Broadphase.prototype.constructor = GameLib.D3.API.Broadphase;
/**
* Creates an API Broadphase from an Object Broadphase
* @param objectBroadphase
* @constructor
*/
GameLib.D3.API.Broadphase.FromObject = function(objectBroadphase) {
return new GameLib.D3.API.Broadphase(
objectBroadphase.id,
objectBroadphase.name,
objectBroadphase.broadphaseType,
objectBroadphase.parentEntity
);
};