For mob grid. Map updates every 1 second or so but reading happens every frame and contains the list of mob entities in a grid cell (cell size is 3x3). MobGridSystem looks for mobs and periodically updated the mob location on the grid. Then for example in the steering system, I am going to look for nearby entities. Also when placing an object on the ground I will check if there is no mob over there. Reading can happen from the networking thread or AI thread.
I can’t remember… are you a Zay-ES user or not?
There are reasons to do things the way you are and using the concurrent* classes should mean that you are ok.
But note that in my own code, I include the grid cell ID right in the position component such that it is always set at the same time as the position and I can query for it through the ES, build entity sets around filters, etc…
That may not work in your case but I thought I would mention it. There is no separate update process in that case.
Good idea. I think I may put it in a separate component (GridPosition for example) rather than the BodyPosition component (as it is handled especially via transition buffer and is not like a regular component) so I won’t send unnecessary updates to the client.
Yes, in my case I have a separate position from BodyPosition… since BodyPosition’s idea of position depends on precisely when you ask. I use it only for network synching.
…I have an additional position for recording where things are persistently and that’s the one with the grid.
…but yeah, on the server, if you want a grid-based index then you will have to do something more immediate. (In my case, my physics engine is already managing that grid and I can just ask it.)