Fixed hooks invocation (case #3)

This commit is contained in:
Intrinsic 2025-01-16 16:30:39 -08:00
parent 0296c4b2f9
commit 1878b376e2
No known key found for this signature in database
2 changed files with 21 additions and 1 deletions

View file

@ -1158,7 +1158,7 @@ do
local idr_t_archetype = archetypes[archetype_id] local idr_t_archetype = archetypes[archetype_id]
local idr_t_types = idr_t_archetype.types local idr_t_types = idr_t_archetype.types
local on_remove = idr_t.hooks.on_remove
for _, child in idr_t_archetype.entities do for _, child in idr_t_archetype.entities do
table.insert(children, child) table.insert(children, child)
@ -1180,6 +1180,7 @@ do
end end
break break
else else
local on_remove = id_record.hooks.on_remove
local to = archetype_traverse_remove(world, id, idr_t_archetype) local to = archetype_traverse_remove(world, id, idr_t_archetype)
if on_remove then if on_remove then
for _, child in children do for _, child in children do

View file

@ -1699,6 +1699,25 @@ TEST("world:delete() invokes OnRemove hook", function()
world:delete(B) world:delete(B)
CHECK(called)
end
do CASE "#3"
local world = world_new()
local pair = jecs.pair
local viewingContainer = world:component()
local character = world:entity()
local container = world:entity()
local called = false
world:set(viewingContainer, jecs.OnRemove, function(e)
called = true
end)
world:add(character, pair(viewingContainer, container))
world:delete(container)
CHECK(called) CHECK(called)
end end
end) end)