Rendering order in an Entity System
- by Daedalus
Say I use a basic ES approach, and also inside Systems I hold lists of all entities that Systems are required to process.
How do I maintain this list of entities in desired rendering order, i.e. for a dumb 2D RenderingSystem?
I saw this discussion, and what they suggest is to do something like Z ordering - what I would probably do is just to store a "layer" int in DrawableComponent and then, inside RenderingSystem, just sort entities by mentioned "layer" whenever the entity list for RenderingSystem changes.
They also say we could just delete and recreate the entity whenever we want it on the top, but it seems too inflexible to me.
How is this problem usually solved?