EntityQuery a specific Archetype

EntityQuery queries all entities that have the components described in the query.
What i’d like to query is all the entities of a certain archetype. So entities that have ONLY the components i pass as parameter.

Is there functionality that either queries an archetype or queries in an “Only” manner. I could not find a function that did this. And the EntityQueryDesc only has “Any”, “All” and “None”.

(One workaround i thought of is adding an empty component per unique combination, but this seems convoluted while this functionality should be easily implemented by Unity)

1 Answer

1

Have the archetype contain its own entity type, and then be sure to never use entities as components.

public class ExampleEntity : MonoBehavior
{
     private EntityManager eMan;
     public EntityArchetype eArch;

     void Start ()
     {
          eArch = eMan.CreateArchetype
          (
               typeof(ExampleEntity)
               // ...
          )
          // ...
     }
}

(in some system somewhere…)

EntityQuery eQuer = GetEntityQuery(typeof(ExampleEntity));