#Query Multiple SharedComponent Values for use as a quadrant type system?

1 messages · Page 1 of 1 (latest)

vapid wraith
#

Currently I'm using a SharedComponent that holds a single ZoneId value. My map is broken up into sections (currently 64x64 quadrants) and each has a unique ZoneId. Most of my entities have this SharedComponent to specify what Zone they are in because my Entities often need to find nearby Entities. I set the SharedComponent Filter on FindClosest IJobEntities.

I want to expand my search radius to include neighbor zones and would like to utilize a single FindClosest IJobEntities that checks all the Entities in any of the 9 Zones, but an EntityQuery is limited to just two shared components per Query, which seems to apply even for multiple values of the same SharedComponent.

What is the best way to approach this?

  • A single pre-built query won't work because a single query can only have 2 SharedComponent Filters
  • I could build a compound query via AddAdditionalQuery, but that requires building new queries on the fly. (is that okay? Building a query seems to require allocations)
  • I could run a job per zone, but then I have to merge the resulting jobs to find the closest of the results and that could get messy and require additional NativeContainers to hold the results.
  • Should I move away from SharedComponents and just search the whole map?

My current testing setup is a 4096x4096 map with 4096 Zones, and each Zone has approximately 50 Entities that need to be checked in them (220k total across the map).

keen pine
#

i like the job per zone best

#

probably, anyway? depends how many components per entity, but i bet shared components are fine for this

vapid wraith
#

Thanks, I'll give it a try