Get component array for a specific archetype

GetComponentDataFromEntity returns a ComponentDataFromEntity. This data type contains component data for all entities.
I was wondering if is it possible to only get component data of a speficic archetype?
Is it is possible, does it make any difference in performance to only get component data for that specific archetype?

Further explanation:
I have many moving entities on screen. Bullets, Enemies, etc.
I have different systems controlling positions of each archetype with IJobParallelFor job.
I was wondering if it’s possible to only give Bullets’ Translate component to bullets job. This way these systems can work in parallel (Since they are not modifying the positions of same archetypes).

query.ToComponentDataArray(Allocator) and query.CopyFromComponentDataArray for apply
IJobForEach with required type and RequireComponentTag’s or IJobForEach with EntityQuery overload on Schedule

Thank you. I didn’t know that you can execute foreach job on query.
So basically I can do this:

shootingQuery = GetEntityQuery(ComponentType.ReadOnly<IsShooting>(), ComponentType.ReadOnly<Armed>());
shootingQuery.SetFilter(new IsShooting(true));

and schedule a shooting job like this:

And it will only execute the ShootBulletsJob on the entities that have IsShooting = true.
Is this correct?

Yes, in that case IJFE will run on your query set of entities.

1 Like