Optimized Lists. Added pool.added and .removed. Added entity:ensure

This commit is contained in:
Justin van der Leij 2018-10-02 21:52:23 +02:00
parent e2b7af87fd
commit 11255fd722
7 changed files with 104 additions and 48 deletions

View file

@ -14,6 +14,9 @@ Pool.__index = Pool
function Pool.new(name, filter)
local pool = setmetatable(List(), Pool)
pool.added = {}
pool.removed = {}
pool.name = name
pool.filter = filter
@ -22,6 +25,12 @@ function Pool.new(name, filter)
return pool
end
function Pool:flush()
for i = 1, math.max(#self.added, #self.removed) do
self.added[i], self.removed[i] = nil, nil
end
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