Return empty query when Without removes all archetypes

This commit is contained in:
Ukendio 2024-07-13 04:11:48 +02:00
parent e486c11dc2
commit 570b72c778

View file

@ -455,7 +455,10 @@ local function add(world: World, entityId: i53, componentId: i53)
local record = entityIndex.sparse[entityId] local record = entityIndex.sparse[entityId]
local from = record.archetype local from = record.archetype
local to = archetypeTraverseAdd(world, componentId, from) local to = archetypeTraverseAdd(world, componentId, from)
if from and not (from == world.ROOT_ARCHETYPE) then if from == to then
return
end
if from then
moveEntity(entityIndex, entityId, record, to) moveEntity(entityIndex, entityId, record, to)
else else
if #to.types > 0 then if #to.types > 0 then
@ -793,6 +796,10 @@ local function preparedQuery(compatibleArchetypes: { Archetype },
end end
end end
if #compatibleArchetypes == 0 then
return EmptyQuery
end
return self return self
end end