mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
* Initial commit * Add tests * Dedup observers * Handle filters on table creation * Handle Archetype deletion * Remove print * Fix type errors * Cleanup code * Manually inline code * Build terms for cached queries * Specialized cached query iterator * Remove shadowed variable * Inverse statement * Rework demo * Fix metatable * Use generalized iteration
40 lines
590 B
Text
40 lines
590 B
Text
--!optimize 2
|
|
--!native
|
|
|
|
-- original author @centau
|
|
|
|
local FAILURE = -1
|
|
local RUNNING = 0
|
|
local SUCCESS = 1
|
|
|
|
local function SEQUENCE(nodes)
|
|
return function(...)
|
|
for _, node in nodes do
|
|
local status = node(...)
|
|
if status <= RUNNING then
|
|
return status
|
|
end
|
|
end
|
|
return SUCCESS
|
|
end
|
|
end
|
|
|
|
local function FALLBACK(nodes)
|
|
return function(...)
|
|
for _, node in nodes do
|
|
local status = node(...)
|
|
if status > FAILURE then
|
|
return status
|
|
end
|
|
end
|
|
return FAILURE
|
|
end
|
|
end
|
|
|
|
local bt = {
|
|
SEQUENCE = SEQUENCE,
|
|
FALLBACK = FALLBACK,
|
|
RUNNING = RUNNING,
|
|
}
|
|
|
|
return bt
|