I'm trying to figure out how to implement a simple ECS with an Archetype approach, similar to what Unity's ECS uses.
An archetype is just a category for entities that have a specific set of components.
Let's say I had three components,
C, and I had the following systems:
- System 1 (Archetype requires component
- System 2 (Archetype requires components
- System 3 (Archetype requires components
- System 4 (Archetype requires components
Because components could be added and removed from entities on the fly, an entity switches archetypes whenever a component is added or removed.
I'm not quite sure what these archetype collections are supposed to look like. They must be arrays of some kind, but I'm not sure how to store and organize components in them that belong to a specific entity.
My question is, what would this look like in pure, vanilla C# code?
And could generics also help with this?