ECS – System that calls other systems

I'm trying to build my first game (2D) with ECS but I always end up with some system calling other systems. Here is an example.

There is a RegionSystem that manages RegionComponents. In each frame, this system goes 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 on a teleporter, an animation will be played around the player, rotate and a new level will be charged.

When the player enters a hole, he will lose some health and will be repositioned in the level.

Then, first, you need the coordinates of the player's body to verify if it is in a region (checkpoint in the rectangle). Therefore, it will ask the RigidbodySystem to obtain the coordinates.

Then, if the player is within a region, it will call PlayerSystem_OnInsideRegion (regionInfo).

In turn, this function, PlayerSystem_OnInsideRegion must react differently depending on the type of region:

  • for the case of water, you must call SpriteSystem to change a sprite, PlayerSystem to set a Boolean value (m_inWater = True;) and RigidBodySystem to get the coordinates of the player's body;

  • in the case of the teleporter, you must call LevelSystem and tell him to change to another level in the following table;

  • for the case of the hole, well, simply decrease the m_health member of the player component, so it is not necessary to call another system here.

I have the feeling that 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 a particular type of message. But I also read that it can be difficult to react to them in the right order.