Original Post
So I wanted to follow up on my previous topic about component based entity design since that thread was... not super helpful for me, despite some attempts. Hopefully this can help others who come along looking for similar implementation details. This is for a non-gamedev project, but many of the basics fit.
Anyways, the implementation is broken into 3 distinct pieces:
The Entity in this design is very, very thin. It contains a definition, and a collection of components. Since the project is in C#, the component store ends up being a private list of dynamic, with public methods to extract typed instances.
Composition
Anyways, the implementation is broken into 3 distinct pieces:
- The entity that is a common aggregation of functionality.
- Components that are individual composable units of functionality.
- And a definition that is immutable and readonly. It defines what an entity is, and is used by the components to determine if the component is applicable, and if so, what flavor of component to use.
The Entity in this design is very, very thin. It contains a definition, and a collection of components. Since the project is in C#, the component store ends up being a private list of dynamic, with public methods to extract typed instances.