Hey Franco,
thanks for quick reply!
I saw that Edge handles nearly all collections via maps which basically nullifies ordering of items by default.
It would be great to have some kind of mechanics to order the components in the systems by some rules ( sorting by z-index for example ) and to be manipulate positions in the list ( be able to simulate some kind of hierarchy between components as mentioned in ACDB example ).
Not sure myself what would be bulletproof approach for this problem of mine ( regarding parent/child transforms ) but as I said ability to manipulate the order of components in the lists would surely open possibilities to do creative stuff with them.
When ordering would be available I was thinking about this ( theoretically, I don't know internal workings of the systems since they are build entirely from the macros thus their code is not easy to comprehend by looking at the github :)
- In the system, I would override 'updateAdded' function. Don't know for sure if this is a callback when entity is added in the system. Correct me if I'm wrong.
- In the overrided updateAdded I can then set the correct index or whatever to put the added entity to desired position in the list( if they are implemented with arrays for a simple example here ). Or sort the list or whatever I want.
Voila!
Maybe it would be great to control the overall update in the system not per entity as shown in github example. Is that possible by overriding the _process_ function?
That way I could write system:
- with additional, let's say linked list of entities where I could control the entity ordering.
- make a loop through all entites in overriden _process function but using my ( ordered ) list
- override 'updateAdded' and put entiities in my linked list orderer as it suits me
- overrid 'updateRemoved' to do clean-up stuff in the custom list
I was investigating a bit what people are doing in artemis,ash and similar are doing and it seems that they are doing exactly the same:
Check out for 'protected void inserted(Entity e)'
Personally I would no't like for Edge systems to be too 'smart' and do the sortings and stuff out of the box but to provide certain hooks for overriding and bending them to programmer's needs.
Regarding the rendering I was pointing to ordering of layers and ordering of sprites in the layers. That's also related to the order manipulation and sorting ( which layer/sprite comes above, which below; if doing 2D stuff ).
As you mentioned, layers could be done as separate systems but sprite components would be always drawn in the order they are created as there is no way to alter their list indexes afterwards ( maps ).
Thanks again Franco for the help!
Dinko