Hello everyone. I've recently started to experiment with trying to implement an Entity Component System for my XNA/Monogame projects. Up until now, I've been using the usual OOP style but as my games have grown bigger, I realized I've been having lots of trouble keeping my base class from being bloated. Some quick google searches later, and I ended up reading articles about Entity Component Systems (in particle this article: http://t-machine.org/index.php/2007/11/11/entity-systems-are-the-future-of-mmog-development-part-2/ ). This system seems to solve a lot of the problems I've had and as such, I would like to try to implement an Entity Component System (in particular, a one where the components are just data and the systems control the logic).
However, I've been having some problems implementing this type of system. I understand the reasoning and the concepts behind the organization, but I can't seem to put a finger down on actually translating this into code. In particular, implementing Systems. Some problems I've been having include:
1. How do I know what system to call and when? I was thinking of just constantly looping a list of entities in my game class and checking to see if each entity satisfied a criteria and then passing that entity to a system, but that seems to be too time consuming--especially the more entities there are. Is there a more efficient way of doing this? I was thinking of potentially just testing the id of the entity but that seems like a naive and hacky way of going about it.
2. How to implement specific systems. For example, for a collision system, I'm having trouble implementing it. Would I just loop through each entity that has a Collidable component, first check to see if it collides with any map tiles and then loop through the other entities and check if they collide with one another? Also, before now, my collision system usually relied on knowing what the next position would be and then fixing the position accordingly. With an ECS, wouldn't I want my collision system to have nothing to do with my physics system? Or am I overthinking this.
Any help would be great! Thank you in advance.