Lately I've been working on a small personal project which is basically an Entity Component System framework with autoupdated Systems.
While I have a pretty good idea on the way the framework should work, because of lack of experience I am having trouble with actually keeping everything decoupled.
Some details on the framework:
Each entity is defined by it's components.
Systems are responsible for the actually modifying the entities by changing their components.
In order to improve locality of reference, instead of keeping each component in the appropriate entity, all components are stored in homogenous vectors and each entity keeps a list of indices to each vector.
Since each System modifies specific components, it should keep a list only of the entities with the corresponding components. This 'registration' to the Systems happens whenever a component is added or removed from an entity.
How I dealt with all of this until now was to have a ComponentManager, an EntityManager and a SystemManager. These classes however have very tight coupling with each other. The EntitManager needs to have access to the ComponentManager in order to handle the size of the the index lists and the mapping of each component type to them. It also needs access to actually add the components in the appropriate vector. Another coupling is between the EntityManager and the SystemManager. Whenever an entity is created, it needs to be added to the list of the appropriate Systems.
A general event bus would appear to help but I am not sure how to implement it without making it global.
How do I improve this design by removing coupling while still maintaining the system's functionality?