Option 'IncludeDisabledEntities' doesn't work

In an isystem. I want to enable the WalkToLobby component. This component may or may not be enbled currently. So I use WithOptions(EntityQueryOptions.IncludeDisabledEntities) instead of withdisabled<WalkToLobby>(). But the query excludes entities with walkToLobby disabled.

To debug, I tried to remove the EnabledRefRW<WalkToLobby>>() . Those excluded entities were then included.

Is there any thing wrong with my understanding about the option?

        void SpawnPeople(ref SystemState state)
        {
            var quests = SystemAPI.GetComponentRO<SpawnQuests>(msn);

            foreach (var (people, inPool, walkToLobby) in SystemAPI.
            Query<RefRW<People>, EnabledRefRW<InPool>, EnabledRefRW<WalkToLobby>>()
            .WithOptions(EntityQueryOptions.IncludeDisabledEntities)
            .WithAll<InPool>())
            {
                if (!quests.ValueRO.value.TryDequeue(out var massing)) return;

                inPool.ValueRW = false;
                walkToLobby.ValueRW = true;

                people.ValueRW.massing = massing;
                people.ValueRW.building = SystemAPI.GetComponentRO<Massing>(massing).ValueRO.host;
            }
        }

That option is for the Disabled component, not for enableable components. It refers to the entity being disabled. You’re looking for EntityQueryOptions.IgnoreComponentEnabledState.

It would ideally be done with WithPresent, but it doesn’t work properly. Tertle has a fork with a fix, though.

3 Likes