what we have is basically a map of 2D tiles, now stored in a matrix. Visually 3D and batched up in the scene graph. What we need is to monitor tile states, health & effects etc. For visual effects like blinking tiles, I’m not sure now what is the best way to arrange this data in code. Player input can also toggle visual changes to these tiles. Using Control / tile seems a bit impossible (and also is there a penalty on performance? like 200x200 map would create a whole lot of controls). And with controls, perhaps multiple tiles would not blink in unison without some time based formula. So… an AppState to handle these or what? Any suggestions? Thanks.
Either event based logic, or a appstate, that loops over your data, and updates the visual representation one by one.
You can also limit the update rate for performance reasons, like update 20tiles each frame, instead of all at once.
And to add to that, only update tiles which are visible if only performing visual updates.
It should be an AppState …
can also be an Controller if you represent your terrain in only one Spatial.
The question it how you update 200x200 of unit of data without too much iterations, right? You need more data structure not only Tiles…
- Is there a view (20x20) for example that seen by players, so the tiles outside of that view don’t need update?
- Is there tiles that belong in a whole like a road, path, a lake and relatively unchanged, relatively update on by its own ways? If there is , for reasons you should also have Data structure for that kind of things: TileRoad (as a 2d line), TileLake (as a Rectangle), TileArea (as Poligon). Later you will need a library to work with that geometry soup, but it much faster than tiles.
- Is there movements that smaller than tiles and have to be transform to tile position, or relative infos that tied to a tile at one time. You should expand the tile class to save that temporary infos, as much as you need.
For example, I my RPG i usually prepare 4-5 primitive data and a Map as UserData for a Tile. It will be very useful for things like path finding, level design, triggers and such.