I am trying to develop a 2D entity component based game with multiple layers as tilemaps (front or back from the scene).
I currently handle the tilemap layers in a 3 dimension array[z][y][x]. Each tile from the map is an entity and have a positionComponent which define x, y and z. The array structure is very convenient to update and render only visibles entities (in the viewport).
I have also added an 1 dimension array to handle the ennemies and items. The problem is that I want to fusion the tilemap and ennemy array in one single structure (I want to update and render entities within a single strcture).
As the entities already have a positionComponent defining x, y and z, is there a good way to get rid of the 3 dimensions array without loosing performance?
Ideal will be to be able to do something like entities.get(z, y, x).