// The container:
// std::vector<std::unordered_map<std::string, std::vector<Entity*> > > entityLayerList;
for (auto& layerIndex : entityLayerList) {
for (auto& entityList : layerIndex) {
for (Entity* entityIndex : entityList.second) {
}
}
}
A vector of maps of vectors seems a bit crazy but if it's working fine, the method should be fine.
One thing you can do to reduce "layers of grids" is to store them all in one place and then sort them to draw them in the correct order.
To do this, you'd first need to add a z (or depth) value to each tile. Then, to avoid sorting the actual vector, create a duplicate vector of pointers to each member of the original vector and sort those pointers based on the z value of what they are pointing to. You can also do this with a vector of indices instead of pointers. Remember to fill the 'sortable vector' with initial values. For a pointer vector, a pointer to each tile. For an index vector, a index to each tile (basically an increasing value from 0).
Co-incidentally, I've just applied one of these methods (the index version) to something to sort 3D shapes in one vector.
See it here (but this branch might not last forever):
https://github.com/Hapaxia/SelbaWard/blob/starfield3d/src/SelbaWard/Starfield3d.cpp#L253-L257(click to show/hide)