Im doing a 2D grid-based retro rts like dune 2 (using c++). Land units and buildings are referred to by a pointer for each tile: if the tile is not empty, it points to the unit standing there.
So units can quickly find nearby units when scanning for targets (for example)
I just added air units, they move regardless of tiles and can "swarm" like air units in starcraft/starcraft 2.
So many can be "on" the same tile.
What is a good way to handle them? I have all units in the world in a list but looping through them might get slow when the unit count gets very high.
Should i have a airUnitList for each tile and move the unit reference between these lists when the unit is moving?
A lot of lists!
Or maybe lists in a grid covering 10x10 tiles each?
What would you recommend?
Thanks!