Fix #22 - manage systems before setSystemIndex

This commit is contained in:
Calvin Rose 2020-08-12 08:28:57 -05:00
parent e095e10d44
commit afd7d326d7
3 changed files with 19 additions and 0 deletions

View File

@ -310,4 +310,14 @@ describe('tiny-ecs:', function()
assert.are.same(_G, GLOBALS) assert.are.same(_G, GLOBALS)
end) end)
it("Can set system indices", function()
local world = tiny.world()
local systemA = tiny.system()
local systemB = tiny.system()
world:addSystem(systemA)
world:addSystem(systemB)
world:setSystemIndex(systemA, 1)
assert(true)
end)
end) end)

8
test.lua Normal file
View File

@ -0,0 +1,8 @@
local tiny = require('tiny')
local world = tiny.world()
local systemA = tiny.system()
local systemB = tiny.system()
world:addSystem(systemA)
world:addSystem(systemB)
world:setSystemIndex(systemA, 1)

View File

@ -821,6 +821,7 @@ end
-- the order in which they Systems processed, because lower indexed Systems are -- the order in which they Systems processed, because lower indexed Systems are
-- processed first. Returns the old system.index. -- processed first. Returns the old system.index.
function tiny.setSystemIndex(world, system, index) function tiny.setSystemIndex(world, system, index)
tiny_manageSystems(world)
local oldIndex = system.index local oldIndex = system.index
local systems = world.systems local systems = world.systems