I am wondering whether there are any recommended techniques in ECS for structured, multi-entity data. Specifically, I am working on a 3 dimensional tile map structure where each tile can have complex functionality, and any number of attached (also complex) entities to each tile. In addition, I need to be able to easily refer to adjacent tiles and be able to look up specific tiles by their position in the tile map.
My current plan is to have an entity for every different object within the tile, as children of the ‘base tile’ entity which also contains components with other information about the tile, which is itself a child of the tilemap entity, which contains components about overall tile map information.
In addition, I will then have a singleton which connects all of these together so that each entity is accessible by it’s position, as well as collecting the entities within a tile together for easy lookup. If possible, all data in the singleton will be derivable from information stored on entities, otherwise i imagine some networking and saving/loading hell may ensue.
I would like to know whether there are any flaws in this plan, or whether there are any better ways to do it? In addition, whether it is easy to maintain the singleton’s state when tiles or tile pieces are added or deleted.
A third and final question is about the split between runtime and definition data. Theoretically the majority of the data on a tile piece is defined pre-compile time, such as mesh information, and some other data is derivable, such as a tile’s LocalToWorld based on it’s position in the tilemap. Is it possible to go without these components comfortably and still work with most systems, such as rendering and physics, or will i need to have a large (but not deal-breaking) amount of duplicated data across all these different tiles?
I’m still relatively terrible at designing ECS based and Data oriented systems, so I’m sorry if a lot of these are very simple things. I’m in the process of porting over some very object-oriented systems at the moment and want to make sure i’m doing it right. I’m also going to be porting over an interaction system later, where a coder should be able to easily code arbitrary player-initiated actions against arbitrary objects, can run continuously, etc, which should be a lot of fun too :(.