alive/empty/has/get function work only with primary fragment in pairs now

This commit is contained in:
BlackMATov
2025-08-17 21:45:15 +07:00
parent 0e6f23d30b
commit e9084f818b
2 changed files with 9 additions and 36 deletions

View File

@@ -1113,6 +1113,9 @@ do
assert(not evo.empty(evo.pair(p, s)))
evo.destroy(s)
assert(not evo.empty(evo.pair(p, s)))
evo.destroy(p)
assert(evo.empty(evo.pair(p, s)))
end

View File

@@ -4892,18 +4892,13 @@ function __evolved_alive(entity)
return true
else
local primary_index, secondary_index = __evolved_unpack(entity)
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 secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
if not secondary or secondary % 2 ^ 20 ~= secondary_index then
return false
end
return true
end
end
@@ -4963,18 +4958,13 @@ function __evolved_empty(entity)
return not __entity_chunks[entity_index]
else
local primary_index, secondary_index = __evolved_unpack(entity)
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 true
end
local secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
if not secondary or secondary % 2 ^ 20 ~= secondary_index then
return true
end
return not __entity_chunks[primary_index]
end
end
@@ -5041,18 +5031,13 @@ function __evolved_has(entity, fragment)
return __chunk_has_fragment(entity_chunk, fragment)
else
local primary_index, secondary_index = __evolved_unpack(entity)
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 secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
if not secondary or secondary % 2 ^ 20 ~= secondary_index then
return false
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then
@@ -5083,18 +5068,13 @@ function __evolved_has_all(entity, ...)
return __chunk_has_all_fragments(entity_chunk, ...)
else
local primary_index, secondary_index = __evolved_unpack(entity)
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 secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
if not secondary or secondary % 2 ^ 20 ~= secondary_index then
return __lua_select('#', ...) == 0
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then
@@ -5125,18 +5105,13 @@ function __evolved_has_any(entity, ...)
return __chunk_has_any_fragments(entity_chunk, ...)
else
local primary_index, secondary_index = __evolved_unpack(entity)
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 secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
if not secondary or secondary % 2 ^ 20 ~= secondary_index then
return false
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then
@@ -5168,18 +5143,13 @@ function __evolved_get(entity, ...)
local entity_place = __entity_places[entity_index]
return __chunk_get_components(entity_chunk, entity_place, ...)
else
local primary_index, secondary_index = __evolved_unpack(entity)
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 secondary = __freelist_ids[secondary_index] --[[@as evolved.id?]]
if not secondary or secondary % 2 ^ 20 ~= secondary_index then
return
end
local primary_chunk = __entity_chunks[primary_index]
if not primary_chunk then