mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2024-10-12 19:44:17 +00:00
Fix reordering of Systems.
This commit is contained in:
parent
dc3deab725
commit
dc69636f72
@ -197,6 +197,14 @@ describe('tiny-ecs:', function()
|
||||
assert.equals(3, world:getEntityCount())
|
||||
end)
|
||||
|
||||
it("Reorder Systems", function()
|
||||
world:update(1)
|
||||
world:setSystemIndex(moveSystem, 2)
|
||||
world:update(1)
|
||||
assert.equals(2, world:getSystemIndex(moveSystem))
|
||||
assert.equals(1, world:getSystemIndex(oneTimeSystem))
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
9
tiny.lua
9
tiny.lua
@ -540,11 +540,16 @@ end
|
||||
-- @param system
|
||||
-- @param index
|
||||
function tiny.setSystemIndex(world, system, index)
|
||||
local oldIndex = world.systemIndices[system]
|
||||
local systemIndices = world.systemIndices
|
||||
local oldIndex = systemIndices[system]
|
||||
local systems = world.systems
|
||||
|
||||
tremove(systems, oldIndex)
|
||||
tinsert(systems, index, system)
|
||||
world.systemIndices[system] = index
|
||||
|
||||
for i = oldIndex, index, index >= oldIndex and 1 or -1 do
|
||||
systemIndices[systems[i]] = i
|
||||
end
|
||||
end
|
||||
|
||||
--- Activates Systems in the World.
|
||||
|
Loading…
Reference in New Issue
Block a user