From 1de93f91858fcb68612b84a1c75793cfee37fc3c Mon Sep 17 00:00:00 2001 From: Ukendio Date: Sat, 21 Sep 2024 18:51:50 +0200 Subject: [PATCH] invoke OnRemove hooks before moving --- src/init.luau | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/init.luau b/src/init.luau index 725e4c4..98a7885 100644 --- a/src/init.luau +++ b/src/init.luau @@ -822,13 +822,14 @@ local function world_remove(world: World, entity: i53, id: i53) local to = archetype_traverse_remove(world, id, from) if from and not (from == to) then - entity_move(entity_index, entity, record, to) local idr = world.componentIndex[id] local flags = idr.flags local has_on_remove = bit32.band(flags, ECS_ID_HAS_ON_REMOVE) ~= 0 if has_on_remove then invoke_hook(world, EcsOnRemove, id, entity) end + + entity_move(entity_index, entity, record, to) end end