I'm working on a small, data-driven game engine with some friends.
We use GameObjects (a.k.a. Entities, Actors, or whatever it is called in your favorite engine) to represent every entity in the game. These GameObjects owns Components, who communicates via message passing. This is a very well-known pattern, and although implementations differ greatly, it seems to be what every commercial, modern game engine is doing.
Now we have one problem: managing state. Let's say we are creating some kind of platform game. The hero of this game should be able to stand still, jump, attack...
We created some Finite State Machines to hold the player's state. Now the state should, in turn, be consumed by the other components. Running should trigger an animation and modify the player's velocity, attacking should stop the player and spawn a bullet...
But this creates a lot of dependencies. The Sprite component now has to be aware of the State component, and listen to state changes. The Movable component should listen to state changes too, to be able to change the player's speed. Nearly every component depends on the State component. This sounds like a dependency hell.
I think it's a very common problem, but I can't find a good solution for it. Are there some design patterns for situations like this?