Archetype.md
July 25, 2024 · View on GitHub
Friflo.Engine.ECS
Friflo.Engine.ECS
Archetype Class
An Archetype store entities with a specific set of IComponent and ITag types.
See Example.
public sealed class Archetype
Inheritance System.Object 🡒 Archetype
Remarks
E.g. all entities with a Position and Rotation component are store in the same archetype.
In case of removing one of these components or adding a new one from / to an Entity the entity is moved to a different archetype.
This is the basic pattern for an archetype base ECS. This approach enables efficient entity / component queries.
A query result is simply the union of all archetypes having the requested components.
Queries can be created via generic EntityStoreBase.Query() methods.
| Properties | |
|---|---|
| Capacity | The current capacity reserved to store entity components. |
| ComponentCount | Number of ComponentTypes managed by the archetype. |
| ComponentTypes | The IComponent types managed by the archetype. |
| Count | Number of entities / components stored in the Archetype |
| Entities | Return all Entity's stored in the Archetype. |
| EntityCount | Obsolete. Renamed to Count. |
| EntityIds | Return the entity ids stored in the archetype. |
| Name | |
| Store | The EntityStore owning the archetype. |
| Tags | The ITag types managed by the archetype. |
| Methods | |
|---|---|
| Components<TComponent>() | Return the components of the specified TComponent type stored in the archetype. |
| CreateEntities(int) | |
| CreateEntity() | Create an Entity with the ComponentTypes and Tags managed by the archetype. |
| CreateEntity(int) | |
| EnsureCapacity(int) | Allocates memory for entity components in the archetype to enable adding entity components without reallocation. |
| ToString() |