Remove use of table.pack

This commit is contained in:
bakpakin 2015-03-22 08:15:44 +08:00
parent f3b2e9a0e5
commit f4c6ce1004

View File

@ -29,7 +29,6 @@ jojo.World = World
jojo.Aspect = Aspect jojo.Aspect = Aspect
jojo.System = System jojo.System = System
local tpack = table.pack
local tinsert = table.insert local tinsert = table.insert
local tremove = table.remove local tremove = table.remove
local tconcat = table.concat local tconcat = table.concat
@ -98,10 +97,8 @@ end
-- Composes multiple Aspects into one Aspect. The resulting Aspect will match -- Composes multiple Aspects into one Aspect. The resulting Aspect will match
-- any Entity that matches all sub Aspects. -- any Entity that matches all sub Aspects.
function Aspect.compose(...) function Aspect.compose(...)
local args = tpack(...)
local newa = {{}, {}, {}} local newa = {{}, {}, {}}
for j = 1, args.n do for _, a in ipairs{...} do
local a = args[j]
if a[4] then if a[4] then
return Aspect() return Aspect()
end end
@ -175,7 +172,7 @@ end
-- Systems after creation. -- Systems after creation.
function World:init(...) function World:init(...)
local args = tpack(...) local args = {...}
-- Table of Entity IDs to status -- Table of Entity IDs to status
self.status = {} self.status = {}
@ -205,7 +202,7 @@ end
-- Adds Entities to the World. An Entity is just a table of Components. -- Adds Entities to the World. An Entity is just a table of Components.
function World:add(...) function World:add(...)
local args = tpack(...) local args = {...}
local status = self.status local status = self.status
local entities = self.entities local entities = self.entities
for _, e in ipairs(args) do for _, e in ipairs(args) do
@ -222,7 +219,7 @@ end
-- Call this function on any Entities that have changed such that they would -- Call this function on any Entities that have changed such that they would
-- now match different systems. -- now match different systems.
function World:changed(...) function World:changed(...)
local args = tpack(...) local args = {...}
local status = self.status local status = self.status
for _, e in ipairs(args) do for _, e in ipairs(args) do
status[e._id] = "add" status[e._id] = "add"
@ -233,7 +230,7 @@ end
-- Frees Entities from the World. -- Frees Entities from the World.
function World:free(...) function World:free(...)
local args = tpack(...) local args = {...}
local status = self.status local status = self.status
for _, e in ipairs(args) do for _, e in ipairs(args) do
status[e._id] = "free" status[e._id] = "free"