Entity Component System

Often used in video games, ECS stands for Entity, Component, System—the three parts of ECS. Entities are "things" in the game world. In a city simulator, like Cities Skyline, every pedestrian, vehicle, and build would be an Entity. Unlike in Object Oriented Programming, Entities do not have a specific software analog, but exist in terms of their Components. A Component represents some behavior that can be applied to an Entity. Entities are defined by the composition of their respective Components. Say a game like Starcraft allowed some units to regenerate health. A regeneration Component could be created to represent this behavior. Regeneration Components would then be enlisted for every Entity that currently existed which was intended to regenerate health. A health regeneration System would then run continuously to update the health of all regenerating entities by visiting every regeneration Component in turn. Every type of Component relates to a System. The System is a singleton, often with no mutable state. The state for each Entity is housed in the Component, which often lacks the logic to update the state.

Components can also be dynamically applied or detached from Entities dynamically, due to changes in the game state. If a regenerating unit fills their health bar, they no longer need to regenerate health, and the regenerate health Component can be removed from that Entity. Once the unit takes additional damage, the Component would be reapplied. See [[State Pattern]].

Composition Over Inheritance Aspect Oriented Programming Data Oriented Design

https://en.wikipedia.org/wiki/Entity_component_system https://www.dataorienteddesign.com/dodmain/ https://www.youtube.com/watch?v=W3aieHjyNvw http://www.sebaslab.com/the-quest-for-maintainable-code-and-the-path-to-ecs/

#software #games