From 2895b74b6c6ecc9f8e3f3e67ffc2365b4dfd3e11 Mon Sep 17 00:00:00 2001 From: polygonboutique Date: Wed, 30 Nov 2016 10:46:25 +0100 Subject: [PATCH] addde remove component method to entity --- src/game-lib-entity.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/game-lib-entity.js b/src/game-lib-entity.js index a4219d7..ad08754 100644 --- a/src/game-lib-entity.js +++ b/src/game-lib-entity.js @@ -138,6 +138,13 @@ GameLib.D3.Entity.prototype.addComponent = function( }; +GameLib.D3.Entity.prototype.removeComponent = function(component) { + if(component && component.id && this.parentScene.idToComponent[component.id]) { + this.ids = this.ids.splice(this.ids.indexOf(component), 1); + delete this.parentScene.idToComponent[component.id]; + } +}; + GameLib.D3.Entity.prototype.getComponent = function( componentType ) {