/** * Entity API Object (for storing / loading entities to and from API) * @param id * @param name * @param components R3.Component[] * @param parentEntity R3.Entity * @constructor */ R3.API.Entity = function( id, name, components, parentEntity ) { if (R3.Utils.UndefinedOrNull(id)) { id = R3.Utils.RandomId(); } this.id = id; if (R3.Utils.UndefinedOrNull(name)) { name = 'Entity (' + this.id + ')'; } this.name = name; if (R3.Utils.UndefinedOrNull(components)) { components = []; } this.components = components; R3.API.Component.call( this, R3.Component.ENTITY, parentEntity ); }; R3.API.Entity.prototype = Object.create(R3.API.Component.prototype); R3.API.Entity.prototype.constructor = R3.API.Entity; /** * Returns an API entity from an Object entity * @param objectEntity * @constructor */ R3.API.Entity.FromObject = function(objectEntity) { return new R3.API.Entity( objectEntity.id, objectEntity.name, objectEntity.components, objectEntity.parentEntity ) };