mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-03 04:43:56 -04:00
Redoing folder layouts
This commit is contained in:
parent
167f432bc9
commit
5afe539d86
12 changed files with 802 additions and 21 deletions
37
concord/pool.lua
Normal file
37
concord/pool.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
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
|
||||
|
||||
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,
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue