Fix bug with deactivating Systems. Add test.

This commit is contained in:
bakpakin
2015-03-30 15:22:23 +08:00
parent 22daad2b26
commit c5c27c679c
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -138,6 +138,20 @@ describe('tiny-ecs:', function()
assert.equals(timePassed, 0) assert.equals(timePassed, 0)
assert.equals(entity1.xform.x, entityTemplate1.xform.x) assert.equals(entity1.xform.x, entityTemplate1.xform.x)
end) end)
it("Disable and Enable Systems", function()
world:setSystemActive(moveSystem, false)
world:setSystemActive(oneTimeSystem, false)
world:update(1)
assert.equals(timePassed, 0)
assert.equals(entity1.xform.x, entityTemplate1.xform.x)
world:setSystemActive(moveSystem, true)
world:setSystemActive(oneTimeSystem, true)
world:update(1)
assert.equals(timePassed, 1)
assert.are_not.equal(entity1.xform.x, entityTemplate1.xform.x)
end)
end) end)
end) end)
+1 -1
View File
@@ -389,7 +389,7 @@ end
-- @param system A System in the World activate/deactivate -- @param system A System in the World activate/deactivate
-- @param active Boolean new state of the System -- @param active Boolean new state of the System
function tiny.setSystemActive(world, system, active) function tiny.setSystemActive(world, system, active)
world.activeSystem[system] = active and true or nil world.activeSystems[system] = active and true or nil
end end
return tiny return tiny