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
CapacityThe current capacity reserved to store entity components.
ComponentCountNumber of ComponentTypes managed by the archetype.
ComponentTypesThe IComponent types managed by the archetype.
CountNumber of entities / components stored in the Archetype
EntitiesReturn all Entity's stored in the Archetype.
EntityCountObsolete. Renamed to Count.
EntityIdsReturn the entity ids stored in the archetype.
Name
StoreThe EntityStore owning the archetype.
TagsThe 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()