Currently, I am still learning about entity-component-system, and I have the following question concerning the components.
How would the systems handle dependent components?
For example, In a 2D game, I have an entity (game unit) that has the following components:
RenderComponent - contains current character sprite
AnimationComponent - contains set of sprites and frame index
CharacterStateComponent - tells what the character is actually doing
Now, given a character input such as "move_forward", I am not sure which one of the following procedures should happen:
Process 1 - System Polling
Input notifies StateSystem.
StateSystem updates CharacterStateComponent.
AnimationSystem reads CharacterStateComponent changes.
AnimationSystem updates AnimationComponent.
RenderSystem reads AnimationComponent changes.
RenderSystem updates RenderComponent.
RenderSystem draws RenderComponent normally.
Process 2 - All-in-one Updates
Input notifies CharacterSystem.
CharacterSystem updates CharacterStateComponent, AnimationComponent, and RenderComponent.
AnimationSystem iterates AnimationSystem normally.
RenderSystem draws RenderComponent normally.
I am not quite sure how the engine would respond to a change in one component that suppose to update other components as well. I believe there will be performance issue when it comes to each system having to poll its prerequisite component changes (As shown in Process 1).
Thus, how do you guy normally deal with this?