Check only destination archetype first

This commit is contained in:
Ukendio 2024-05-04 15:10:29 +02:00
parent 6fe05d29c1
commit 440eea9ab3

View file

@ -343,11 +343,11 @@ function World.remove(world: World, entityId: i53, componentId: i53)
local record = ensureRecord(world.entityIndex, entityId)
local sourceArchetype = record.archetype
local destinationArchetype = archetypeTraverseRemove(world, componentId, sourceArchetype)
if not sourceArchetype or not destinationArchetype then
if not destinationArchetype then
return
end
if not (sourceArchetype == destinationArchetype) then
if sourceArchetype and not (sourceArchetype == destinationArchetype) then
moveEntity(world.entityIndex, entityId, record, destinationArchetype)
end
end