I'm trying to build my first (2D) game with ECS but I always end up with some system calling other systems. Here's an example.
There is a RegionSystem that manages RegionComponents. On each frame, this system loops through all the RegionComponents and checks if the player is inside any of them.
When the player enters the water, the player's sprite must be changed from PLAYER_RUNNING to PLAYER_SIWMMING.
When the player steps onto a teleporter, an animation will play around the player, he'll be rotating and a new level will be loaded.
When the player steps into a hole, he will lose some health and will be repositioned in the level.
So, first of all, it needs the coordinates of the player's body to check if it is in a region (check point in rectangle). Hence it will ask the RigidbodySystem to get the coordinates.
Then if the player is inside a region, it will call PlayerSystem_OnInsideRegion(regionInfo).
In turn this function, PlayerSystem_OnInsideRegion must react differently depending on the type of the region:
for the water case, it needs to call the SpriteSystem to change a sprite, the PlayerSystem to set a boolean (m_inWater = True;) and the RigidBodySystem to get the coordinates of the player's body;
for the teleporter case, it needs to call the LevelSystem and tell him to switch to another level on the next frame;
for the hole case, well, simply descrease the member m_health of the player component, so no need to call another system here.
I have the feeling this is a horrible design and does not fit the ECS architecture. I read that people use a message system where systems can subscribe and unsubscribe to particular type of message. But I also read that it can be tricky to react to them in a proper order.