diff options
Diffstat (limited to 'src/entities/entity.js')
-rw-r--r-- | src/entities/entity.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/entities/entity.js b/src/entities/entity.js index 33d1031..1eb5223 100644 --- a/src/entities/entity.js +++ b/src/entities/entity.js @@ -5,13 +5,14 @@ game.Entity = (id=game.nextId++) => { const addComponent = (component) => { components[component.name] = component; - } - const removeComponent = (component) => { - delete components[component.name]; - } - const hasComponent = (component) => { - components[component.name] !== undefined; - } + }; + const hasComponent = (componentName) => components[componentName] !== undefined; + const removeComponent = (componentName) => { + if (hasComponent(componentName)) { + delete components[componentName]; + } + }; + return { id, |