Fixed bug in ordering of systems.

This commit is contained in:
bakpakin
2015-04-03 19:59:02 +08:00
parent 77df6e20aa
commit f23941a903
+5 -2
View File
@@ -167,9 +167,13 @@ function tiny.add(world, ...)
local args = {...} local args = {...}
local entityStatus = world.entityStatus local entityStatus = world.entityStatus
local systemStatus = world.systemStatus local systemStatus = world.systemStatus
local systemIndices = world.systemIndices
local systemCount = world.systemCount
for _, obj in ipairs(args) do for _, obj in ipairs(args) do
if getmetatable(obj) == systemMetaTable then if getmetatable(obj) == systemMetaTable then
systemStatus[obj] = "add" systemStatus[obj] = "add"
systemCount = systemCount + 1
systemIndices[obj] = systemCount
else -- Assume obj is an Entity else -- Assume obj is an Entity
entityStatus[obj] = "add" entityStatus[obj] = "add"
end end
@@ -239,8 +243,7 @@ function tiny.manageSystems(world)
if status == "add" then if status == "add" then
local es = {} local es = {}
systemEntities[system] = es systemEntities[system] = es
tinsert(systems, system) systems[systemIndices[system]] = system
systemIndices[system] = #systems
activeSystems[system] = true activeSystems[system] = true
local filter = system.filter local filter = system.filter
if filter then if filter then