Skip to content

Commit

Permalink
invoke OnRemove hooks before moving
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Sep 21, 2024
1 parent b3da074 commit 1de93f9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1de93f9

Please sign in to comment.