summaryrefslogtreecommitdiff
path: root/honey/ecs.lua
diff options
context:
space:
mode:
Diffstat (limited to 'honey/ecs.lua')
-rw-r--r--honey/ecs.lua29
1 files changed, 16 insertions, 13 deletions
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