summaryrefslogtreecommitdiff
path: root/honey
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-24 19:19:21 -0500
committersanine <sanine.not@pm.me>2023-03-24 19:19:21 -0500
commit627ca789065bfcbce53a51887be4e8f8fb20d26b (patch)
treeaf37f0075b88799a323e602ee215b0f95d02a2da /honey
parentd31a57c0afc8769cef8af82321c07cbc14c0474b (diff)
add pausing
Diffstat (limited to 'honey')
-rw-r--r--honey/ecs-systems.lua1
-rw-r--r--honey/ecs.lua29
2 files changed, 17 insertions, 13 deletions
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