mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2024-11-17 04:44:23 +00:00
Add some simple assertions to adding and removing systems.
This commit is contained in:
parent
5035d2c8a7
commit
f3b16a40f6
3
tiny.lua
3
tiny.lua
@ -398,8 +398,10 @@ tiny_addEntity = tiny.addEntity
|
|||||||
|
|
||||||
--- Adds a System to the world. Returns the System.
|
--- Adds a System to the world. Returns the System.
|
||||||
function tiny.addSystem(world, system)
|
function tiny.addSystem(world, system)
|
||||||
|
assert(system.world == nil, "System already belongs to a World.")
|
||||||
local s2a = world.systemsToAdd
|
local s2a = world.systemsToAdd
|
||||||
s2a[#s2a + 1] = system
|
s2a[#s2a + 1] = system
|
||||||
|
system.world = world
|
||||||
return system
|
return system
|
||||||
end
|
end
|
||||||
tiny_addSystem = tiny.addSystem
|
tiny_addSystem = tiny.addSystem
|
||||||
@ -431,6 +433,7 @@ tiny_removeEntity = tiny.removeEntity
|
|||||||
|
|
||||||
--- Removes a System from the world. Returns the System.
|
--- Removes a System from the world. Returns the System.
|
||||||
function tiny.removeSystem(world, system)
|
function tiny.removeSystem(world, system)
|
||||||
|
assert(system.world == world, "System does not belong to this World.")
|
||||||
local s2r = world.systemsToRemove
|
local s2r = world.systemsToRemove
|
||||||
s2r[#s2r + 1] = system
|
s2r[#s2r + 1] = system
|
||||||
return system
|
return system
|
||||||
|
Loading…
Reference in New Issue
Block a user