Changed Implementation of Entity Storage.

Remove Use of Sets for Storing Entities in hopes to speed up Iteration.
Add some tests.
This commit is contained in:
bakpakin
2015-04-25 17:59:41 +08:00
parent debce6666e
commit a612a7b13d
2 changed files with 202 additions and 99 deletions
+21 -3
View File
@@ -110,8 +110,8 @@ describe('tiny-ecs:', function()
end)
it("Create World", function()
assert.equals(world.entityCount, 3)
assert.equals(world.systemCount, 2)
assert.equals(world:getEntityCount(), 3)
assert.equals(world:getSystemCount(), 2)
end)
it("Run simple simulation", function()
@@ -131,10 +131,11 @@ describe('tiny-ecs:', function()
end)
it("Remove Systems", function()
world:remove(oneTimeSystem, moveSystem)
world:remove(moveSystem, oneTimeSystem)
world:update(1)
assert.equals(timePassed, 0)
assert.equals(entity1.xform.x, entityTemplate1.xform.x)
assert.equals(0, world:getSystemCount())
end)
it("Disable and Enable Systems", function()
@@ -160,6 +161,23 @@ describe('tiny-ecs:', function()
assert.equals(0, world:getSystemCount())
end)
it("Add Entities Multiple Times", function()
world:update(1)
world:add(entity1, entity2, entity3)
world:update(2)
assert.equals(2, world:getSystemCount())
assert.equals(3, world:getEntityCount())
end)
it("Remove Entities Multiple Times", function()
world:update(1)
world:remove(entity1, entity2, entity3)
world:update(2)
world:remove(entity1, entity2, entity3)
world:update(2)
assert.equals(2, world:getSystemCount())
assert.equals(0, world:getEntityCount())
end)
end)