Currently, I am learning about entity-component-systems, and I have a question concerning the components. How would the systems handle dependent components?
For example, In a 2D game, I have a game object entity that has the following components:
RenderComponent
- contains current character spriteAnimationComponent
- contains set of sprites and frame indexCharacterStateComponent
- tells what the character is actually doing
Given player input, such as "move_forward", I am not sure which of the following procedures should happen:
System Polling:
Input
notifiesStateSystem
.StateSystem
updatesCharacterStateComponent
.AnimationSystem
readsCharacterStateComponent
changes.AnimationSystem
updatesAnimationComponent
.RenderSystem
readsAnimationComponent
changes.RenderSystem
updatesRenderComponent
.RenderSystem
drawsRenderComponent
normally.
All-in-one Updates:
Input
notifiesCharacterSystem
.CharacterSystem
updatesCharacterStateComponent
,AnimationComponent
andRenderComponent
.AnimationSystem
iteratesAnimationSystem
normally.RenderSystem
drawsRenderComponent
normally.
I am not quite sure how the engine would respond to a change in one component that is 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 System Polling).
How would the entity system handle dependent components?