Building an ECS #1: Where are my Entities and Components
Created on 2024-03-28T12:13:58-05:00
An entity is a unique thing--with its own unique ID--representing stuff in your world.
Components are attributes of the entity and can be attached to entities.
A naive way to attach components is using a list on entities; this can be undesirable because fetching components requires a linear search every time (and getting components is very common.)
An archetype is a collection of components. If an entity belongs to it then it has all of those components.
Archetypes are useful when you want to iterate over groups of objects that have similar components.
Giving each component a set of which archetypes it belongs to can be cheaper than giving the archetypes a set of components they own. This is because if you create archetypes for every tuple of components, you will have very many archetypes.