I'll try to explain better. First of all, it is a platformer, just to let you understand better. Now, I have these components:
- Floor -> indicates that entities falling upon this entity will stop on top of it (they behave like a floor, nothing more)
- Gravity -> indicates that this entity can fall down
What the system should do is only stop the entities with the Gravity component on top of the entities with the Floor component. Only this.
But, not only "real floor" (terrain) entities have the Floor component: also bonus boxes have it, they are solid and they COMPLETELY behave like a floor until the player breaks them to obtain the bonus (and I'd manage this in another system). And maybe also other entities in the world would behave like floors, even though they are not proper floors. I can't make a group "floors", because bonus boxes would also belong to the "bonus" group, and it would be a mess...
And, also, not only the player has gravity: there are also some enemies that have gravity. So I can't make a group "gravity entities", because some of them would also belong to the "enemies" group, and so on... It would be dificult to use groups, because a single entity would belong to 2, 3, 4 groups maybe...
So I thought that the easiest way to handle this was to get a list of ALL entities that have the Gravity component (player, enemies... all of them), then a list of ALL the enetites that have a Floor component (proper floors, solid bonus boxes, etc...), and then check for collisions. Nothing changes if the entity is a player or an enemy, it just have to stop on top of the floor/box/whatever. So there should be only one system for all of them, right?
What's the problem? I could make a system like:
which will obtain all the entites with the Gravity component. That's ok, but now how can I get the list of all the entities with the Floor component (so that I can check for collisions with ALL of that entities, not only floors, or only boxes, but all of them)? And if I make a system like:
how can I get a list of ALL the entities with a Gravity component to check for collisions?
Of course I'd want to check for this kind of collision only the entities that have the Gravity component because it doesn't make sense to perform the check on an entity that doesn't have that component, it just wouldn't fall down... The same for the Floor component. So, what could be a way of handling this kind of collision?