no more parent entity manager, new renderer for entity
parent
e8ee24a12a
commit
58785caef3
|
@ -36,6 +36,11 @@ GameLib.EntityManager = function(apiEntityManager) {
|
|||
this.registerComponent.bind(this)
|
||||
);
|
||||
|
||||
GameLib.Event.Subscribe(
|
||||
GameLib.Event.INSTANCE_CREATED,
|
||||
this.instanceCreated.bind(this)
|
||||
);
|
||||
|
||||
GameLib.Event.Subscribe(
|
||||
GameLib.Event.REMOVE_COMPONENT,
|
||||
this.removeComponent.bind(this)
|
||||
|
@ -59,6 +64,12 @@ GameLib.EntityManager.prototype.createInstance = function() {
|
|||
GameLib.Component.prototype.createInstance.call(this);
|
||||
};
|
||||
|
||||
GameLib.EntityManager.prototype.instanceCreated = function(data) {
|
||||
if (data.component instanceof GameLib.Entity) {
|
||||
this.addEntity(data.component);
|
||||
}
|
||||
};
|
||||
|
||||
GameLib.EntityManager.prototype.registerComponent = function(data) {
|
||||
|
||||
var updated = false;
|
||||
|
@ -139,38 +150,6 @@ GameLib.EntityManager.prototype.removeComponent = function(data) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an GameLib.Entity and adds it to entities array
|
||||
* @returns {*}
|
||||
*/
|
||||
GameLib.EntityManager.prototype.createEntity = function(name) {
|
||||
|
||||
var apiEntity = new GameLib.API.Entity(
|
||||
null,
|
||||
name,
|
||||
null,
|
||||
null,
|
||||
this
|
||||
);
|
||||
|
||||
var entity = new GameLib.Entity(
|
||||
apiEntity
|
||||
);
|
||||
|
||||
this.entities.push(entity);
|
||||
|
||||
this.defaultEntity = entity;
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.NEW_ENTITY,
|
||||
{
|
||||
entity : entity
|
||||
}
|
||||
);
|
||||
|
||||
return entity;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an entity by ID or null
|
||||
* @param id
|
||||
|
@ -253,7 +232,6 @@ GameLib.EntityManager.prototype.findSceneByObject = function(object) {
|
|||
* @param entity GameLib.Entity
|
||||
*/
|
||||
GameLib.EntityManager.prototype.addEntity = function(entity) {
|
||||
entity.parentEntityManager = this;
|
||||
this.entities.push(entity);
|
||||
};
|
||||
|
||||
|
@ -289,8 +267,6 @@ GameLib.EntityManager.prototype.removeEntity = function(entity) {
|
|||
}
|
||||
this.entities.splice(index, 1);
|
||||
|
||||
entity.parentEntityManager = null;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue