destroy impl

This commit is contained in:
BlackMATov
2024-12-18 23:13:12 +07:00
parent 684fbd34bd
commit 898e9f1716
2 changed files with 23 additions and 2 deletions

View File

@@ -457,3 +457,16 @@ do
assert(last_set_component == 45)
assert(last_assign_component == 45)
end
do
local f = evo.id()
local e = evo.id()
assert(evo.insert(e, f, 42))
assert(evo.has(e, f))
assert(evo.alive(e))
evo.destroy(e)
assert(not evo.has(e, f))
assert(not evo.alive(e))
end

View File

@@ -501,9 +501,17 @@ end
---@param id evolved.id
function evolved.destroy(id)
if __alive_id(id) then
__release_id(id)
if not __alive_id(id) then
return
end
local index = __unpack_id(id)
while __entity_chunks[index] do
evolved.clear(id)
end
__release_id(id)
end
---@param entity evolved.entity