mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-15 04:15:28 +07:00
destroy impl
This commit is contained in:
@@ -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
|
||||
|
||||
12
evolved.lua
12
evolved.lua
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user