From 16bcc6daab84373cac0f4125c1580d3cb1261baf Mon Sep 17 00:00:00 2001 From: sanine-a Date: Wed, 22 Mar 2023 12:12:31 -0500 Subject: move ecs systems into separate module --- honey/ecs.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'honey/ecs.lua') diff --git a/honey/ecs.lua b/honey/ecs.lua index 4eee343..23bb0ba 100644 --- a/honey/ecs.lua +++ b/honey/ecs.lua @@ -194,10 +194,22 @@ end function Level.update(self, dt) for _, system in ipairs(self.systems) do + if system.preUpdate then + for id in pairs(system.entities) do + local entity = self.entities[id] + system.preUpdate(entity) + end + end for id in pairs(system.entities) do local entity = self.entities[id] system.update(entity, dt) end + if system.postUpdate then + for id in pairs(system.entities) do + local entity = self.entities[id] + system.postUpdate(entity) + end + end end end -- cgit v1.2.1