Moved some files

This commit is contained in:
Justin van der Leij 2018-04-07 18:24:52 +02:00
parent 281bb53a5b
commit 6c98c259e4
10 changed files with 673 additions and 676 deletions

39
pool.lua Normal file
View file

@ -0,0 +1,39 @@
local PATH = (...):gsub('%.[^%.]+$', '')
local List = require(PATH..".list")
local Pool = {}
Pool.__index = Pool
--- Creates a new Pool
-- @param name Identifier for the Pool.
-- @param filter Table containing the required Components
-- @return The new Pool
function Pool.new(name, filter)
local pool = setmetatable(List(), Pool)
pool.name = name
pool.filter = filter
pool.__isPool = true
return pool
end
--- Checks if an Entity is eligible for the Pool.
-- @param e The Entity to check
-- @return True if the entity is eligible, false otherwise
function Pool:eligible(e)
for _, component in ipairs(self.filter) do
if not e.components[component] or e.removed[component] then
return false
end
end
return true
end
return setmetatable(Pool, {
__index = List,
__call = function(_, ...) return Pool.new(...) end,
})