I just recently learned about Entity Systems and want to try it out on a real example (I was developing a game recently and want to try to port it over Entity Systems). But I got problem right away. Actually that is two questions in one.
First would be:
In traditional OOP approach I had game loop which was picking action to do for idling units every 100ms (so-called 'turn'). But rendering obviously was run at every game loop iteration. How should I do that? Maybe I need something like individual interval for systems to run? Like RenderingSystem running every Update while AI Systems are running each 100ms. Or maybe there is some better approach which I should use?
Second question would be about about these AI Systems
I understand how to make AI which will manage every unit completely individually. However I have somewhat simultaneous pathfinding for all units which will do:
- Mark units that should start moving as 'moving'.
- Find path for every 'moving' unit to it's target (basically closest enemy). All 'moving' units aren't considered as obstacles for path but all not-'moving' units considered as obstacles.
- Try to move every unit one step at it's path. If can't make step (someone is already standing there) then mark path as invalid (to recalculate at next AI iteration) and move one step in direction of target (if there is free nodes).
- Mark all 'moving' units as not-'moving'
Besides there is addition: 3. Before making step we will check if we have enemy around us and instead of moving we will attack that enemy.
So, one AI iteration required to give action to each unit which will be run until it finishes. Then AI should give next action.
How I can make that in Entity System approach? Because in ES all systems are run one-after-another where I need to "jump" beetween them freely. Or maybe I'm overcomplicating things and should do something different instead of "jumping" between systems?