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

46 lines
1005 B
JavaScript
Raw Normal View History

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