From 627ca789065bfcbce53a51887be4e8f8fb20d26b Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 24 Mar 2023 19:19:21 -0500 Subject: add pausing --- honey/ecs-systems.lua | 1 + honey/ecs.lua | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'honey') diff --git a/honey/ecs-systems.lua b/honey/ecs-systems.lua index 237aa78..5dec159 100644 --- a/honey/ecs-systems.lua +++ b/honey/ecs-systems.lua @@ -56,6 +56,7 @@ function renderCam(camera, priority) } entity.mesh:drawElements() end, + nopause=true, priority=priority, } end diff --git a/honey/ecs.lua b/honey/ecs.lua index d611b37..b7806f9 100644 --- a/honey/ecs.lua +++ b/honey/ecs.lua @@ -195,23 +195,26 @@ function Level.reconfigureAllEntities(self) end -function Level.update(self, dt) +function Level.update(self, dt, paused) + local paused = paused or false for _, system in ipairs(self.systems) do - if system.preUpdate then - system:preUpdate() - end - if system.prepareEntity then + if (not paused) or (paused and system.nopause) then + if system.preUpdate then + system:preUpdate() + end + if system.prepareEntity then + for id in pairs(system.entities) do + local entity = self.entities[id] + system:prepareEntity(entity) + end + end for id in pairs(system.entities) do local entity = self.entities[id] - system:prepareEntity(entity) + system:update(entity, dt) + end + if system.postUpdate then + system:postUpdate() end - end - for id in pairs(system.entities) do - local entity = self.entities[id] - system:update(entity, dt) - end - if system.postUpdate then - system:postUpdate() end end end -- cgit v1.2.1