#Disabled entities
1 messages · Page 1 of 1 (latest)
EntityQueryOptions.IncludeDisabledEntities
There are a few ways to make a query, but I think most common one is with .WithOptions()
Can you do this with IJobEntities that are deriving their queries from an IAspect? I couldn't spot where to add options to this setup.
Looks like I found a solution. You can add attributes above the job like:
[WithDisabled(typeof(UninitializedTag))]
public partial struct FooJob : IJobEntity
WithNone also works.
WithNone is essentitally just WithAbsentOrDisabled.
It's important to distinguish between disabled entities and disabled components. These two features have similar names, but have virtually nothing to do with each other implementation-wise.
Disabling an entity with EntityManager.SetEnabled(Entity,false) automatically excludes it from all entity queries, unless the .IncludeDisabledEntities option is passed at query creation time, as @hexed patrol said. This makes the query match both enabled and disabled entities; if you want to match only disabled entities, I suppose you could also add .WithAll<Disabled>() to the query, in addition to the .IncludeDisabledEntities option (both would be necessary).
Disabling a component with SetComponentEnabled<T>(Entity,false) makes the entity behave as though it does not have the component for query-matching purposes, but does not disable the entity. To match an entity with a specific enableable component disabled, then @round glacier's suggestion is correct: use [WithDisabled(typeof(T))] on the job or .WithDisabled<T>() on the query.
Thanks Cort! I often see a lot of mentions of querys, but haven't found a nice way to use them with an aspect centric workflow. Are these two concepts meant to work together, or is one replacing the other?
I definitely wouldn't say one is "replacing" the other; they're pretty distinct concepts in my head. A query is a way to identify a specific set of entities to process, based on what components they have / don't have. An aspect is a way to temporarily wrap multiple components of an entity in a convenient abstract interface.