invoke OnRemove hooks before moving

This commit is contained in:
Ukendio 2024-09-21 18:51:50 +02:00
parent b3da0745bc
commit 1de93f9185

View file

@ -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