more pair checks

This commit is contained in:
BlackMATov
2025-08-29 05:56:23 +07:00
parent 12beee6eec
commit d4a7c7b77c
3 changed files with 278 additions and 218 deletions

View File

@@ -179,7 +179,17 @@ for _ = 1, math.random(1, 100) do
not evo.has_any(entity, __table_unpack(query_exclude_list)) not evo.has_any(entity, __table_unpack(query_exclude_list))
for fragment in evo.each(entity) do for fragment in evo.each(entity) do
if evo.has(fragment, evo.EXPLICIT) then local is_fragment_explicit = false
if not is_fragment_explicit and evo.is_pair(fragment) then
is_fragment_explicit = evo.has(evo.unpair(fragment), evo.EXPLICIT)
end
if not is_fragment_explicit and not evo.is_pair(fragment) then
is_fragment_explicit = evo.has(fragment, evo.EXPLICIT)
end
if is_fragment_explicit then
local is_fragment_included = false local is_fragment_included = false
if not is_fragment_included then if not is_fragment_included then

View File

@@ -91,20 +91,20 @@ do
assert(evo.has_any(e12, evo.pair(p1, evo.ANY), evo.pair(p2, evo.ANY))) assert(evo.has_any(e12, evo.pair(p1, evo.ANY), evo.pair(p2, evo.ANY)))
end end
do -- do
local p1, s1, p2, s2 = evo.id(4) -- local p1, s1, p2, s2 = evo.id(4)
evo.set(p1, s1) -- evo.set(p1, s1)
evo.set(s1, p1) -- evo.set(s1, p1)
evo.set(p2, s2) -- evo.set(p2, s2)
assert(not evo.empty(evo.pair(p1, s1))) -- assert(not evo.empty(evo.pair(p1, s1)))
assert(not evo.empty(evo.pair(p2, s2))) -- assert(not evo.empty(evo.pair(p2, s2)))
assert(not evo.empty_all(evo.pair(p1, s1), evo.pair(p2, s2))) -- assert(not evo.empty_all(evo.pair(p1, s1), evo.pair(p2, s2)))
assert(not evo.empty_any(evo.pair(p1, s1), evo.pair(p2, s2))) -- assert(not evo.empty_any(evo.pair(p1, s1), evo.pair(p2, s2)))
assert(not evo.empty_all(evo.pair(p1, s1), evo.pair(p2, s2), p1)) -- assert(not evo.empty_all(evo.pair(p1, s1), evo.pair(p2, s2), p1))
assert(not evo.empty_any(evo.pair(p1, s1), evo.pair(p2, s2), p1)) -- assert(not evo.empty_any(evo.pair(p1, s1), evo.pair(p2, s2), p1))
assert(not evo.empty_all(evo.pair(p1, s1), evo.pair(p2, s2), s2)) -- assert(not evo.empty_all(evo.pair(p1, s1), evo.pair(p2, s2), s2))
assert(evo.empty_any(evo.pair(p1, s1), evo.pair(p2, s2), s2)) -- assert(evo.empty_any(evo.pair(p1, s1), evo.pair(p2, s2), s2))
end -- end
do do
local p1, s1 = evo.id(2) local p1, s1 = evo.id(2)
@@ -1628,6 +1628,61 @@ do
assert(evo.name(evo.pair(evo.ANY, evo.ANY)) == '${ANY,ANY}') assert(evo.name(evo.pair(evo.ANY, evo.ANY)) == '${ANY,ANY}')
end end
do
do
local p, s = evo.id(2)
assert(evo.alive(evo.pair(p, s)))
end
do
local p, s = evo.id(2)
evo.destroy(p)
assert(not evo.alive(evo.pair(p, s)))
end
do
local p, s = evo.id(2)
evo.destroy(s)
assert(evo.alive(evo.pair(p, s)))
end
do
local p, s = evo.id(2)
evo.destroy(p, s)
assert(not evo.alive(evo.pair(p, s)))
end
end
do
do
local p1, p2, p3, s = evo.id(4)
local prefab = evo.builder()
:set(evo.pair(p1, s), 42)
:set(evo.pair(p2, s), 21)
:set(evo.pair(p3, s), 84)
:spawn()
local clone = evo.clone(prefab)
assert(evo.has(clone, evo.pair(p1, s)) and evo.get(clone, evo.pair(p1, s)) == 42)
assert(evo.has(clone, evo.pair(p2, s)) and evo.get(clone, evo.pair(p2, s)) == 21)
assert(evo.has(clone, evo.pair(p3, s)) and evo.get(clone, evo.pair(p3, s)) == 84)
end
do
local p1, p2, p3, s = evo.id(4)
evo.set(p1, evo.UNIQUE)
evo.set(p2, evo.UNIQUE)
local prefab = evo.builder()
:set(evo.pair(p1, s), 42)
:set(evo.pair(p2, s), 21)
:set(evo.pair(p3, s), 84)
:spawn()
local clone = evo.clone(prefab)
assert(not evo.has(clone, evo.pair(p1, s)) and evo.get(clone, evo.pair(p1, s)) == nil)
assert(not evo.has(clone, evo.pair(p2, s)) and evo.get(clone, evo.pair(p2, s)) == nil)
assert(evo.has(clone, evo.pair(p3, s)) and evo.get(clone, evo.pair(p3, s)) == 84)
end
end
-- TODO -- TODO
-- builder:has/has_all/has_any should work with wildcards / remove too? -- builder:has/has_all/has_any should work with wildcards / remove too?
-- should we provide wildcard support for get operations? -- should we provide wildcard support for get operations?

View File

@@ -378,17 +378,15 @@ end)()
---@param fmt string ---@param fmt string
---@param ... any ---@param ... any
---@diagnostic disable-next-line: unused-local, unused-function
local function __error_fmt(fmt, ...) local function __error_fmt(fmt, ...)
__lua_error(__lua_string_format('| evolved.lua | %s', __lua_error(__lua_string_format('| evolved.lua (e) | %s',
__lua_string_format(fmt, ...))) __lua_string_format(fmt, ...)))
end end
---@param fmt string ---@param fmt string
---@param ... any ---@param ... any
---@diagnostic disable-next-line: unused-local, unused-function
local function __warning_fmt(fmt, ...) local function __warning_fmt(fmt, ...)
__lua_print(__lua_string_format('| evolved.lua | %s', __lua_print(__lua_string_format('| evolved.lua (w) | %s',
__lua_string_format(fmt, ...))) __lua_string_format(fmt, ...)))
end end
@@ -4683,11 +4681,11 @@ end
---@nodiscard ---@nodiscard
function __evolved_pack(index, version) function __evolved_pack(index, version)
if index < 1 or index > 2 ^ 20 - 1 then if index < 1 or index > 2 ^ 20 - 1 then
__error_fmt('index (%d) is out of range [1, 2 ^ 20 - 1]', index) __error_fmt('id index (%d) is out of range [1, 2 ^ 20 - 1]', index)
end end
if version < 1 or version > 2 ^ 20 - 1 then if version < 1 or version > 2 ^ 20 - 1 then
__error_fmt('version (%d) is out of range [1, 2 ^ 20 - 1]', version) __error_fmt('id version (%d) is out of range [1, 2 ^ 20 - 1]', version)
end end
return index return index
@@ -4812,24 +4810,20 @@ end
---@return boolean ---@return boolean
---@nodiscard ---@nodiscard
function __evolved_alive(entity) function __evolved_alive(entity)
if not __evolved_is_pair(entity) then local entity_index, _, entity_options = __evolved_unpack(entity)
local entity_index = entity % 2 ^ 20
if entity_options < __PAIR_OPTS then
if __freelist_ids[entity_index] ~= entity then if __freelist_ids[entity_index] ~= entity then
return false return false
end end
return true
else else
local primary_index = entity % 2 ^ 20 local primary = __freelist_ids[entity_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= entity_index then
local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= primary_index then
return false return false
end end
end
return true return true
end
end end
---@param ... evolved.entity entities ---@param ... evolved.entity entities
@@ -4878,24 +4872,20 @@ end
---@return boolean ---@return boolean
---@nodiscard ---@nodiscard
function __evolved_empty(entity) function __evolved_empty(entity)
if not __evolved_is_pair(entity) then local entity_index, _, entity_options = __evolved_unpack(entity)
local entity_index = entity % 2 ^ 20
if entity_options < __PAIR_OPTS then
if __freelist_ids[entity_index] ~= entity then if __freelist_ids[entity_index] ~= entity then
return true return true
end end
return not __entity_chunks[entity_index]
else else
local primary_index = entity % 2 ^ 20 local primary = __freelist_ids[entity_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= entity_index then
local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= primary_index then
return true return true
end end
return not __entity_chunks[primary_index]
end end
return not __entity_chunks[entity_index]
end end
---@param ... evolved.entity entities ---@param ... evolved.entity entities
@@ -4945,36 +4935,22 @@ end
---@return boolean ---@return boolean
---@nodiscard ---@nodiscard
function __evolved_has(entity, fragment) function __evolved_has(entity, fragment)
if not __evolved_is_pair(entity) then local entity_index, _, entity_options = __evolved_unpack(entity)
local entity_index = entity % 2 ^ 20
if entity_options < __PAIR_OPTS then
if __freelist_ids[entity_index] ~= entity then if __freelist_ids[entity_index] ~= entity then
return false return false
end end
else
local primary = __freelist_ids[entity_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= entity_index then
return false
end
end
local entity_chunk = __entity_chunks[entity_index] local entity_chunk = __entity_chunks[entity_index]
if not entity_chunk then return entity_chunk and __chunk_has_fragment(entity_chunk, fragment) or false
return false
end
return __chunk_has_fragment(entity_chunk, fragment)
else
local primary_index = entity % 2 ^ 20
local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= primary_index then
return false
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then
return false
end
return __chunk_has_fragment(primary_chunk, fragment)
end
end end
---@param entity evolved.entity ---@param entity evolved.entity
@@ -4982,36 +4958,28 @@ end
---@return boolean ---@return boolean
---@nodiscard ---@nodiscard
function __evolved_has_all(entity, ...) function __evolved_has_all(entity, ...)
if not __evolved_is_pair(entity) then local argument_count = __lua_select('#', ...)
local entity_index = entity % 2 ^ 20
if argument_count == 0 then
return true
end
local entity_index, _, entity_options = __evolved_unpack(entity)
if entity_options < __PAIR_OPTS then
if __freelist_ids[entity_index] ~= entity then if __freelist_ids[entity_index] ~= entity then
return __lua_select('#', ...) == 0 return false
end
else
local primary = __freelist_ids[entity_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= entity_index then
return false
end
end end
local entity_chunk = __entity_chunks[entity_index] local entity_chunk = __entity_chunks[entity_index]
if not entity_chunk then return entity_chunk and __chunk_has_all_fragments(entity_chunk, ...) or false
return __lua_select('#', ...) == 0
end
return __chunk_has_all_fragments(entity_chunk, ...)
else
local primary_index = entity % 2 ^ 20
local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= primary_index then
return __lua_select('#', ...) == 0
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then
return __lua_select('#', ...) == 0
end
return __chunk_has_all_fragments(primary_chunk, ...)
end
end end
---@param entity evolved.entity ---@param entity evolved.entity
@@ -5019,36 +4987,28 @@ end
---@return boolean ---@return boolean
---@nodiscard ---@nodiscard
function __evolved_has_any(entity, ...) function __evolved_has_any(entity, ...)
if not __evolved_is_pair(entity) then local argument_count = __lua_select('#', ...)
local entity_index = entity % 2 ^ 20
if argument_count == 0 then
return false
end
local entity_index, _, entity_options = __evolved_unpack(entity)
if entity_options < __PAIR_OPTS then
if __freelist_ids[entity_index] ~= entity then if __freelist_ids[entity_index] ~= entity then
return false return false
end end
else
local primary = __freelist_ids[entity_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= entity_index then
return false
end
end
local entity_chunk = __entity_chunks[entity_index] local entity_chunk = __entity_chunks[entity_index]
if not entity_chunk then return entity_chunk and __chunk_has_any_fragments(entity_chunk, ...) or false
return false
end
return __chunk_has_any_fragments(entity_chunk, ...)
else
local primary_index = entity % 2 ^ 20
local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= primary_index then
return false
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then
return false
end
return __chunk_has_any_fragments(primary_chunk, ...)
end
end end
---@param entity evolved.entity ---@param entity evolved.entity
@@ -5056,12 +5016,18 @@ end
---@return evolved.component ... components ---@return evolved.component ... components
---@nodiscard ---@nodiscard
function __evolved_get(entity, ...) function __evolved_get(entity, ...)
if not __evolved_is_pair(entity) then local entity_index, _, entity_options = __evolved_unpack(entity)
local entity_index = entity % 2 ^ 20
if entity_options < __PAIR_OPTS then
if __freelist_ids[entity_index] ~= entity then if __freelist_ids[entity_index] ~= entity then
return return
end end
else
local primary = __freelist_ids[entity_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= entity_index then
return
end
end
local entity_chunk = __entity_chunks[entity_index] local entity_chunk = __entity_chunks[entity_index]
@@ -5071,44 +5037,45 @@ function __evolved_get(entity, ...)
local entity_place = __entity_places[entity_index] local entity_place = __entity_places[entity_index]
return __chunk_get_components(entity_chunk, entity_place, ...) return __chunk_get_components(entity_chunk, entity_place, ...)
else
local primary_index = entity % 2 ^ 20
local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
if not primary or primary % 2 ^ 20 ~= primary_index then
return
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then
return
end
local primary_place = __entity_places[primary_index]
return __chunk_get_components(primary_chunk, primary_place, ...)
end
end end
---@param entity evolved.entity ---@param entity evolved.entity
---@param fragment evolved.fragment ---@param fragment evolved.fragment
---@param component evolved.component ---@param component evolved.component
function __evolved_set(entity, fragment, component) function __evolved_set(entity, fragment, component)
if __debug_mode then local entity_index, _, entity_options = __evolved_unpack(entity)
if __evolved_is_pair(entity) then
__error_fmt('the pair (%s) cannot be used as an entity', __id_name(entity)) if entity_options >= __PAIR_OPTS then
__error_fmt('the pair (%s) cannot be changed', __id_name(entity))
elseif __freelist_ids[entity_index] ~= entity then
__error_fmt('the id (%s) is not alive and cannot be changed', __id_name(entity))
end end
if __evolved_is_wildcard(fragment) then local fragment_primary, fragment_secondary, fragment_options = __evolved_unpack(fragment)
__error_fmt('the wildcard fragment (%s) cannot be used as a fragment', __id_name(fragment))
if fragment_options < __PAIR_OPTS then
local fragment_index = fragment_primary
if fragment_index == __ANY_INDEX then
__error_fmt('the id (%s) is a wildcard and cannot be set', __id_name(fragment))
elseif __freelist_ids[fragment_index] ~= fragment then
__error_fmt('the id (%s) is not alive and cannot be set', __id_name(fragment))
end
else
local primary_index, secondary_index = fragment_primary, fragment_secondary
if fragment_options >= __PRI_WILDCARD_OPTS then
__error_fmt('the pair (%s) is a wildcard and cannot be set', __id_name(fragment))
end end
if not __evolved_alive(entity) then local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
__error_fmt('the entity (%s) is not alive and cannot be used', __id_name(entity)) if not primary or primary % 2 ^ 20 ~= primary_index then
__error_fmt('the pair (%s) has no alive primary id and cannot be set', __id_name(fragment))
end end
if not __evolved_alive(fragment) then local secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
__error_fmt('the fragment (%s) is not alive and cannot be used', __id_name(fragment)) if not secondary or secondary % 2 ^ 20 ~= secondary_index then
__error_fmt('the pair (%s) has no alive secondary id and cannot be set', __id_name(fragment))
end end
end end
@@ -5117,8 +5084,6 @@ function __evolved_set(entity, fragment, component)
return return
end end
local entity_index = entity % 2 ^ 20
local entity_chunks = __entity_chunks local entity_chunks = __entity_chunks
local entity_places = __entity_places local entity_places = __entity_places
@@ -5348,15 +5313,12 @@ function __evolved_remove(entity, ...)
return return
end end
if __evolved_is_pair(entity) then local entity_index, _, entity_options = __evolved_unpack(entity)
-- pairs cannot have fragments, nothing to remove
return
end
local entity_index = entity % 2 ^ 20 if entity_options >= __PAIR_OPTS then
__error_fmt('the pair (%s) cannot be changed', __id_name(entity))
if __freelist_ids[entity_index] ~= entity then elseif __freelist_ids[entity_index] ~= entity then
-- this entity is not alive, nothing to remove -- the id is not alive, nothing to remove
return return
end end
@@ -5468,12 +5430,12 @@ function __evolved_clear(...)
for argument_index = 1, argument_count do for argument_index = 1, argument_count do
---@type evolved.entity ---@type evolved.entity
local entity = __lua_select(argument_index, ...) local entity = __lua_select(argument_index, ...)
local entity_index = entity % 2 ^ 20 local entity_index, _, entity_options = __evolved_unpack(entity)
if __evolved_is_pair(entity) then if entity_options >= __PAIR_OPTS then
-- pairs cannot have fragments, nothing to clear __warning_fmt('the pair (%s) cannot be changed', __id_name(entity))
elseif __freelist_ids[entity_index] ~= entity then elseif __freelist_ids[entity_index] ~= entity then
-- this entity is not alive, nothing to clear -- the id is not alive, nothing to clear
else else
local chunk = entity_chunks[entity_index] local chunk = entity_chunks[entity_index]
local place = entity_places[entity_index] local place = entity_places[entity_index]
@@ -5546,12 +5508,12 @@ function __evolved_destroy(...)
for argument_index = 1, argument_count do for argument_index = 1, argument_count do
---@type evolved.entity ---@type evolved.entity
local entity = __lua_select(argument_index, ...) local entity = __lua_select(argument_index, ...)
local entity_index = entity % 2 ^ 20 local entity_index, _, entity_options = __evolved_unpack(entity)
if __evolved_is_pair(entity) then if entity_options >= __PAIR_OPTS then
-- pairs cannot be destroyed, nothing to do __warning_fmt('the pair (%s) cannot be changed', __id_name(entity))
elseif __freelist_ids[entity_index] ~= entity then elseif __freelist_ids[entity_index] ~= entity then
-- this entity is not alive, nothing to destroy -- the id is not alive, nothing to destroy
else else
local is_fragment = local is_fragment =
minor_chunks[entity] or minor_chunks[entity] or
@@ -5590,21 +5552,39 @@ end
---@param fragment evolved.fragment ---@param fragment evolved.fragment
---@param component evolved.component ---@param component evolved.component
function __evolved_batch_set(query, fragment, component) function __evolved_batch_set(query, fragment, component)
if __debug_mode then local query_index, _, query_options = __evolved_unpack(query)
if __evolved_is_pair(query) then
__error_fmt('the pair (%s) cannot be used as a query', __id_name(query)) if query_options >= __PAIR_OPTS then
__error_fmt('the pair (%s) cannot be queried', __id_name(query))
elseif __freelist_ids[query_index] ~= query then
__error_fmt('the id (%s) is not alive and cannot be queried', __id_name(query))
end end
if __evolved_is_wildcard(fragment) then local fragment_primary, fragment_secondary, fragment_options = __evolved_unpack(fragment)
__error_fmt('the wildcard fragment (%s) cannot be used as a fragment', __id_name(fragment))
if fragment_options < __PAIR_OPTS then
local fragment_index = fragment_primary
if fragment_index == __ANY_INDEX then
__error_fmt('the id (%s) is a wildcard and cannot be set', __id_name(fragment))
elseif __freelist_ids[fragment_index] ~= fragment then
__error_fmt('the id (%s) is not alive and cannot be set', __id_name(fragment))
end
else
local primary_index, secondary_index = fragment_primary, fragment_secondary
if fragment_options >= __PRI_WILDCARD_OPTS then
__error_fmt('the pair (%s) is a wildcard and cannot be set', __id_name(fragment))
end end
if not __evolved_alive(query) then local primary = __freelist_ids[primary_index] --[[@as evolved.id?]]
__error_fmt('the query (%s) is not alive and cannot be used', __id_name(query)) if not primary or primary % 2 ^ 20 ~= primary_index then
__error_fmt('the pair (%s) has no alive primary id and cannot be set', __id_name(fragment))
end end
if not __evolved_alive(fragment) then local secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
__error_fmt('the fragment (%s) is not alive and cannot be used', __id_name(fragment)) if not secondary or secondary % 2 ^ 20 ~= secondary_index then
__error_fmt('the pair (%s) has no alive secondary id and cannot be set', __id_name(fragment))
end end
end end
@@ -5645,6 +5625,14 @@ function __evolved_batch_remove(query, ...)
return return
end end
local query_index, _, query_options = __evolved_unpack(query)
if query_options >= __PAIR_OPTS then
__error_fmt('the pair (%s) cannot be queried', __id_name(query))
elseif __freelist_ids[query_index] ~= query then
__error_fmt('the id (%s) is not alive and cannot be queried', __id_name(query))
end
if __defer_depth > 0 then if __defer_depth > 0 then
__defer_batch_remove(query, ...) __defer_batch_remove(query, ...)
return return
@@ -5696,12 +5684,19 @@ function __evolved_batch_clear(...)
for argument_index = 1, argument_count do for argument_index = 1, argument_count do
---@type evolved.query ---@type evolved.query
local query = __lua_select(argument_index, ...) local query = __lua_select(argument_index, ...)
local query_index, _, query_options = __evolved_unpack(query)
if query_options >= __PAIR_OPTS then
__warning_fmt('the pair (%s) cannot be queried', __id_name(query))
elseif __freelist_ids[query_index] ~= query then
__warning_fmt('the id (%s) is not alive and cannot be queried', __id_name(query))
else
for chunk in __evolved_execute(query) do for chunk in __evolved_execute(query) do
chunk_count = chunk_count + 1 chunk_count = chunk_count + 1
chunk_list[chunk_count] = chunk chunk_list[chunk_count] = chunk
end end
end end
end
for chunk_index = 1, chunk_count do for chunk_index = 1, chunk_count do
local chunk = chunk_list[chunk_index] local chunk = chunk_list[chunk_index]
@@ -5744,7 +5739,13 @@ function __evolved_batch_destroy(...)
for argument_index = 1, argument_count do for argument_index = 1, argument_count do
---@type evolved.query ---@type evolved.query
local query = __lua_select(argument_index, ...) local query = __lua_select(argument_index, ...)
local query_index, _, query_options = __evolved_unpack(query)
if query_options >= __PAIR_OPTS then
__warning_fmt('the pair (%s) cannot be queried', __id_name(query))
elseif __freelist_ids[query_index] ~= query then
__warning_fmt('the id (%s) is not alive and cannot be queried', __id_name(query))
else
for chunk, entity_list, entity_count in __evolved_execute(query) do for chunk, entity_list, entity_count in __evolved_execute(query) do
clearing_chunk_count = clearing_chunk_count + 1 clearing_chunk_count = clearing_chunk_count + 1
clearing_chunk_list[clearing_chunk_count] = chunk clearing_chunk_list[clearing_chunk_count] = chunk
@@ -5767,6 +5768,7 @@ function __evolved_batch_destroy(...)
end end
end end
end end
end
if purging_fragment_count > 0 then if purging_fragment_count > 0 then
__destroy_fragment_list(purging_fragment_list, purging_fragment_count) __destroy_fragment_list(purging_fragment_list, purging_fragment_count)
@@ -5798,16 +5800,12 @@ end
---@return evolved.each_state? iterator_state ---@return evolved.each_state? iterator_state
---@nodiscard ---@nodiscard
function __evolved_each(entity) function __evolved_each(entity)
if __evolved_is_pair(entity) then local entity_index, _, entity_options = __evolved_unpack(entity)
-- pairs cannot be used as entities, nothing to iterate
return __iterator_fns.__each_iterator
end
local entity_index = entity % 2 ^ 20 if entity_options >= __PAIR_OPTS then
__error_fmt('the pair (%s) cannot be iterated', __id_name(entity))
if __freelist_ids[entity_index] ~= entity then elseif __freelist_ids[entity_index] ~= entity then
-- this entity is not alive, nothing to iterate __error_fmt('the id (%s) is not alive and cannot be iterated', __id_name(entity))
return __iterator_fns.__each_iterator
end end
local entity_chunks = __entity_chunks local entity_chunks = __entity_chunks
@@ -5836,16 +5834,12 @@ end
---@return evolved.execute_state? iterator_state ---@return evolved.execute_state? iterator_state
---@nodiscard ---@nodiscard
function __evolved_execute(query) function __evolved_execute(query)
if __evolved_is_pair(query) then local query_index, _, query_options = __evolved_unpack(query)
-- pairs cannot be used as queries, nothing to execute
return __iterator_fns.__execute_major_iterator
end
local query_index = query % 2 ^ 20 if query_options >= __PAIR_OPTS then
__error_fmt('the pair (%s) cannot be executed', __id_name(query))
if __freelist_ids[query_index] ~= query then elseif __freelist_ids[query_index] ~= query then
-- this query is not alive, nothing to execute __error_fmt('the id (%s) is not alive and cannot be executed', __id_name(query))
return __iterator_fns.__execute_major_iterator
end end
---@type evolved.chunk[] ---@type evolved.chunk[]
@@ -6035,13 +6029,14 @@ function __evolved_process(...)
for argument_index = 1, argument_count do for argument_index = 1, argument_count do
---@type evolved.system ---@type evolved.system
local system = __lua_select(argument_index, ...) local system = __lua_select(argument_index, ...)
local system_index, _, system_options = __evolved_unpack(system)
if __evolved_is_pair(system) then if system_options >= __PAIR_OPTS then
-- pairs cannot be used as systems, nothing to process __warning_fmt('the pair (%s) cannot be processed', __id_name(system))
elseif not __evolved_alive(system) then elseif __freelist_ids[system_index] ~= system then
-- this system is not alive, nothing to process __warning_fmt('the id (%s) is not alive and cannot be processed', __id_name(system))
elseif __evolved_has(system, __DISABLED) then elseif __evolved_has(system, __DISABLED) then
-- this system is disabled, nothing to process -- the system is disabled, nothing to process
else else
__system_process(system) __system_process(system)
end end