mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 20:33:54 -04:00
Fixed: Pool:evaluate should bypass Pool:add filter check
This commit is contained in:
parent
16e111176e
commit
9ae805aa43
2 changed files with 19 additions and 19 deletions
|
@ -8,23 +8,23 @@ local Type = require(PATH..".type")
|
||||||
local Components = {}
|
local Components = {}
|
||||||
|
|
||||||
local try = function (name)
|
local try = function (name)
|
||||||
if type(name) ~= "string" then
|
if type(name) ~= "string" then
|
||||||
return false, "ComponentsClass name is expected to be a string, got "..type(name)..")"
|
return false, "ComponentsClass name is expected to be a string, got "..type(name)..")"
|
||||||
end
|
end
|
||||||
|
|
||||||
local value = rawget(Components, name)
|
local value = rawget(Components, name)
|
||||||
if not value then
|
if not value then
|
||||||
return false, "ComponentClass '"..name.."' does not exist / was not registered"
|
return false, "ComponentClass '"..name.."' does not exist / was not registered"
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, value
|
return true, value
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns true if the containter has the ComponentClass with the specified name
|
--- Returns true if the containter has the ComponentClass with the specified name
|
||||||
-- @string name Name of the ComponentClass to check
|
-- @string name Name of the ComponentClass to check
|
||||||
-- @treturn boolean
|
-- @treturn boolean
|
||||||
function Components.has(name)
|
function Components.has(name)
|
||||||
return rawget(Components, name) and true or false
|
return rawget(Components, name) and true or false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns true and the ComponentClass if one was registered with the specified name
|
--- Returns true and the ComponentClass if one was registered with the specified name
|
||||||
|
@ -33,25 +33,25 @@ end
|
||||||
-- @treturn boolean
|
-- @treturn boolean
|
||||||
-- @treturn Component or error string
|
-- @treturn Component or error string
|
||||||
function Components.try(name)
|
function Components.try(name)
|
||||||
return try(name)
|
return try(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the ComponentClass with the specified name
|
--- Returns the ComponentClass with the specified name
|
||||||
-- @string name Name of the ComponentClass to get
|
-- @string name Name of the ComponentClass to get
|
||||||
-- @treturn Component
|
-- @treturn Component
|
||||||
function Components.get(name)
|
function Components.get(name)
|
||||||
local ok, value = try(name)
|
local ok, value = try(name)
|
||||||
|
|
||||||
if not ok then error(value, 2) end
|
if not ok then error(value, 2) end
|
||||||
|
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(Components, {
|
return setmetatable(Components, {
|
||||||
__index = function(_, name)
|
__index = function(_, name)
|
||||||
local ok, value = try(name)
|
local ok, value = try(name)
|
||||||
|
|
||||||
if not ok then error(value, 2) end
|
if not ok then error(value, 2) end
|
||||||
|
|
||||||
return value end
|
return value end
|
||||||
})
|
})
|
||||||
|
|
|
@ -72,7 +72,7 @@ function Pool:evaluate(e)
|
||||||
local eligible = self:eligible(e)
|
local eligible = self:eligible(e)
|
||||||
|
|
||||||
if not has and eligible then
|
if not has and eligible then
|
||||||
self:add(e)
|
self:add(e, true) --Bypass the check cause we already checked
|
||||||
elseif has and not eligible then
|
elseif has and not eligible then
|
||||||
self:remove(e)
|
self:remove(e)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue