Fixed hooks invocation in the event of relationship target deletion. (#179)
Some checks are pending
analysis / Run Luau Analyze (push) Waiting to run
deploy-docs / build (push) Waiting to run
deploy-docs / Deploy (push) Blocked by required conditions
publish-npm / publish (push) Waiting to run
unit-testing / Run Luau Tests (push) Waiting to run

* Fixed hooks invocation (case #3)

* Reverted world:component() to world:entity()

Co-authored-by: lolmanurfunny <77128366+lolmanurfunny@users.noreply.github.com>

* Removed whitespace

---------

Co-authored-by: lolmanurfunny <77128366+lolmanurfunny@users.noreply.github.com>
This commit is contained in:
Intrinsic 2025-01-16 16:46:14 -08:00 committed by GitHub
parent 0296c4b2f9
commit 5e3739036a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

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

View file

@ -1699,6 +1699,25 @@ TEST("world:delete() invokes OnRemove hook", function()
world:delete(B)
CHECK(called)
end
do CASE "#3"
local world = world_new()
local pair = jecs.pair
local viewingContainer = world:entity()
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)
end
end)