Currently, I am still learning about entity-component-systementity-component-systems, and I have the followinga question concerning the components. How would the systems handle dependent components?
How would the systems handle dependent components?
For example, In a 2D game, I have an entity (game unit)a game object entity 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
RenderComponent- contains current character spriteAnimationComponent- contains set of sprites and frame indexCharacterStateComponent- tells what the character is actually doing
NowGiven player input, given a character input such as "move_forward""move_forward", I am not sure which one of the following procedures should happen:
Process 1 - System Polling
InputSystem Polling:
Inputnotifies StateSystemStateSystem.StateSystem
StateSystemupdates CharacterStateComponentCharacterStateComponent.AnimationSystem
AnimationSystemreads CharacterStateComponentCharacterStateComponentchanges.AnimationSystem
AnimationSystemupdates AnimationComponentAnimationComponent.RenderSystem
RenderSystemreads AnimationComponentAnimationComponentchanges.RenderSystem
RenderSystemupdates RenderComponentRenderComponent.RenderSystem
RenderSystemdraws RenderComponentRenderComponentnormally.
Process 2 - All-in-one Updates
InputAll-in-one Updates:
Inputnotifies CharacterSystemCharacterSystem.CharacterSystem
CharacterSystemupdates CharacterStateComponentCharacterStateComponent, AnimationComponent,AnimationComponentand RenderComponentRenderComponent.AnimationSystem iterates
AnimationSystemiterates AnimationSystemAnimationSystemnormally.RenderSystem draws
RenderSystemdraws RenderComponentRenderComponentnormally.
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 (Asas shown in Process 1System Polling).
Thus, how do you guy normally deal with thisHow would the entity system handle dependent components?