How do you implement hierarchical render order in an entity system?
For example: two player entities each carry a gun entity. If you set the player entities to zindex = 0 and the gun entities to zindex = 1, then player 1 might render behind player 2 but his gun will render in front of player two.
I'm migrating a game from a scene-graph system where the order is self-evident from the parent/child relationship. The only way I can see of achieving the above is to simulate that parent/child relationship by giving every entity its own reserved range of z-indexes like so. player1 z=0 player1-gun z=1 ... player2 z=5 player2-gun z=6
This would require some kind of auto assignment system. Is this how it's done or is there some pattern I'm missing?