Make tiny.add, tiny.remove, and similar methods return entities and systems.

This commit is contained in:
bakpakin 2015-07-06 22:01:06 -04:00
parent c1f1225248
commit 19ae03707f

View File

@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-- @author Calvin Rose -- @author Calvin Rose
-- @license MIT -- @license MIT
-- @copyright 2015 -- @copyright 2015
local tiny = { _VERSION = "1.1-5" } local tiny = { _VERSION = "scm" }
-- Local versions of standard lua functions -- Local versions of standard lua functions
local tinsert = table.insert local tinsert = table.insert
@ -388,6 +388,7 @@ function tiny.addEntity(world, entity)
if world.entities[entity] then if world.entities[entity] then
tiny_removeEntity(world, entity) tiny_removeEntity(world, entity)
end end
return entity
end end
tiny_addEntity = tiny.addEntity tiny_addEntity = tiny.addEntity
@ -395,6 +396,7 @@ tiny_addEntity = tiny.addEntity
function tiny.addSystem(world, system) function tiny.addSystem(world, system)
local s2a = world.systemsToAdd local s2a = world.systemsToAdd
s2a[#s2a + 1] = system s2a[#s2a + 1] = system
return system
end end
tiny_addSystem = tiny.addSystem tiny_addSystem = tiny.addSystem
@ -411,6 +413,7 @@ function tiny.add(world, ...)
end end
end end
end end
return ...
end end
tiny_add = tiny.add tiny_add = tiny.add
@ -418,6 +421,7 @@ tiny_add = tiny.add
function tiny.removeEntity(world, entity) function tiny.removeEntity(world, entity)
local e2r = world.entitiesToRemove local e2r = world.entitiesToRemove
e2r[#e2r + 1] = entity e2r[#e2r + 1] = entity
return entity
end end
tiny_removeEntity = tiny.removeEntity tiny_removeEntity = tiny.removeEntity
@ -425,6 +429,7 @@ tiny_removeEntity = tiny.removeEntity
function tiny.removeSystem(world, system) function tiny.removeSystem(world, system)
local s2r = world.systemsToRemove local s2r = world.systemsToRemove
s2r[#s2r + 1] = system s2r[#s2r + 1] = system
return system
end end
tiny_removeSystem = tiny.removeSystem tiny_removeSystem = tiny.removeSystem
@ -441,6 +446,7 @@ function tiny.remove(world, ...)
end end
end end
end end
return ...
end end
tiny_remove = tiny.remove tiny_remove = tiny.remove