From 570b72c7782d6171eae73c72b2a48a43b0a001c2 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Sat, 13 Jul 2024 04:11:48 +0200 Subject: [PATCH] Return empty query when Without removes all archetypes --- src/init.luau | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/init.luau b/src/init.luau index 3b6523a..2e9ea47 100644 --- a/src/init.luau +++ b/src/init.luau @@ -455,7 +455,10 @@ local function add(world: World, entityId: i53, componentId: i53) local record = entityIndex.sparse[entityId] local from = record.archetype 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) else if #to.types > 0 then @@ -793,6 +796,10 @@ local function preparedQuery(compatibleArchetypes: { Archetype }, end end + if #compatibleArchetypes == 0 then + return EmptyQuery + end + return self end