summaryrefslogtreecommitdiff
path: root/honey/ecs.lua
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-04-13 23:40:31 -0500
committersanine <sanine.not@pm.me>2023-04-13 23:40:31 -0500
commit371e3a188e190a9c8b53dc6eef02d4eea72db826 (patch)
tree9d82a01b790682cc1c9889bb13494cfd8db9b545 /honey/ecs.lua
parent64be3e5d5788e5e866d7f5fb7b1c6f754735f2f4 (diff)
move message dispatching into ecs-systems.lua
Diffstat (limited to 'honey/ecs.lua')
-rw-r--r--honey/ecs.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/honey/ecs.lua b/honey/ecs.lua
index 69feb12..39f1c77 100644
--- a/honey/ecs.lua
+++ b/honey/ecs.lua
@@ -69,9 +69,22 @@ function EntityDb.addComponent(self, id, name, value)
end
+-- add multiple components at once, for convenience
+function EntityDb.addComponents(self, id, components)
+ for name, value in pairs(components) do
+ self:addComponent(id, name, value)
+ end
+end
+
+
-- get all entities with a given component
function EntityDb.queryComponent(self, name)
- return self.components[name].data
+ local component = self.components[name]
+ if component then
+ return component.data
+ else
+ return {}
+ end
end