construct call with fragment

This commit is contained in:
BlackMATov
2024-12-26 15:45:58 +07:00
parent 755c3ddfff
commit d9a964d639
2 changed files with 3 additions and 3 deletions

View File

@@ -345,8 +345,8 @@ end
do
local f1, f2, f3, f4, f5 = evo.id(5)
evo.set(f1, evo.CONSTRUCT, function(_, a, b) return a - b end)
evo.set(f2, evo.CONSTRUCT, function(_, c) return c end)
evo.set(f1, evo.CONSTRUCT, function(_, _, a, b) return a - b end)
evo.set(f2, evo.CONSTRUCT, function(_, _, c) return c end)
evo.set(f3, evo.CONSTRUCT, function() return nil end)
evo.set(f4, evo.CONSTRUCT, function() return false end)
evo.set(f5, evo.CONSTRUCT, function(e) return e end)

View File

@@ -166,7 +166,7 @@ evolved.EXCLUDE_LIST = __acquire_id()
---@return evolved.component
local function __construct(entity, fragment, component, ...)
local default, construct = evolved.get(fragment, evolved.DEFAULT, evolved.CONSTRUCT)
if construct ~= nil then component = construct(entity, component, ...) end
if construct ~= nil then component = construct(entity, fragment, component, ...) end
if component == nil then component = default end
return component == nil and true or component
end