From c5c27c679c0bf9fd4ca7f3ce39e64603ff7f6252 Mon Sep 17 00:00:00 2001 From: bakpakin Date: Mon, 30 Mar 2015 15:22:23 +0800 Subject: [PATCH] Fix bug with deactivating Systems. Add test. --- spec/tiny_spec.lua | 14 ++++++++++++++ tiny.lua | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/tiny_spec.lua b/spec/tiny_spec.lua index efb324b..59f4ebe 100644 --- a/spec/tiny_spec.lua +++ b/spec/tiny_spec.lua @@ -138,6 +138,20 @@ describe('tiny-ecs:', function() assert.equals(timePassed, 0) assert.equals(entity1.xform.x, entityTemplate1.xform.x) 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) diff --git a/tiny.lua b/tiny.lua index 625d314..4e70cf1 100644 --- a/tiny.lua +++ b/tiny.lua @@ -389,7 +389,7 @@ end -- @param system A System in the World activate/deactivate -- @param active Boolean new state of the System function tiny.setSystemActive(world, system, active) - world.activeSystem[system] = active and true or nil + world.activeSystems[system] = active and true or nil end return tiny