From f3b16a40f66e625bec5f86c3b25a0926f2215942 Mon Sep 17 00:00:00 2001 From: bakpakin Date: Tue, 8 Sep 2015 13:22:07 -0400 Subject: [PATCH] Add some simple assertions to adding and removing systems. --- tiny.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tiny.lua b/tiny.lua index ca1fa62..972d7a0 100644 --- a/tiny.lua +++ b/tiny.lua @@ -398,8 +398,10 @@ tiny_addEntity = tiny.addEntity --- Adds a System to the world. Returns the System. function tiny.addSystem(world, system) + assert(system.world == nil, "System already belongs to a World.") local s2a = world.systemsToAdd s2a[#s2a + 1] = system + system.world = world return system end tiny_addSystem = tiny.addSystem @@ -431,6 +433,7 @@ tiny_removeEntity = tiny.removeEntity --- Removes a System from the world. Returns the System. function tiny.removeSystem(world, system) + assert(system.world == world, "System does not belong to this World.") local s2r = world.systemsToRemove s2r[#s2r + 1] = system return system