mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Fix entity deletion swap logic
This commit is contained in:
parent
1bfcba7422
commit
a5dad9aa4d
2 changed files with 17 additions and 0 deletions
|
@ -950,6 +950,7 @@ local function archetype_delete(world: World, archetype: Archetype, row: number,
|
|||
record_to_move.row = row
|
||||
end
|
||||
|
||||
delete = entities[row]
|
||||
entities[row] = move
|
||||
end
|
||||
|
||||
|
|
|
@ -1045,6 +1045,22 @@ TEST("world:component()", function()
|
|||
end)
|
||||
|
||||
TEST("world:delete", function()
|
||||
do CASE "invoke OnRemove hooks"
|
||||
local world = world_new()
|
||||
|
||||
local e1 = world:entity()
|
||||
local e2 = world:entity()
|
||||
|
||||
local Stable = world:component()
|
||||
world:set(Stable, jecs.OnRemove, function(e)
|
||||
CHECK(e == e1)
|
||||
end)
|
||||
|
||||
world:set(e1, Stable, true)
|
||||
world:set(e2, Stable, true)
|
||||
|
||||
world:delete(e1)
|
||||
end
|
||||
do CASE "delete recycled entity id used as component"
|
||||
local world = world_new()
|
||||
local id = world:entity()
|
||||
|
|
Loading…
Reference in a new issue