ArchetypeId class

Identifies an archetype by its set of component types.

An archetype is defined by a unique combination of component types. Entities with the same set of components share an archetype and are stored together for cache-efficient iteration.

Example

// Create an archetype for entities with Position and Velocity
final archetype = ArchetypeId.of([
  ComponentId.of<Position>(),
  ComponentId.of<Velocity>(),
]);
Annotations
  • @immutable

Constructors

ArchetypeId.empty()
Creates an empty archetype (entity with no components).
factory
ArchetypeId.of(Iterable<ComponentId> componentIds)
Creates an ArchetypeId from an iterable of ComponentIds.
factory

Properties

components → List<ComponentId>
The sorted list of component IDs that define this archetype.
final
hashCode → int
The hash code for this object.
no setteroverride
isEmpty → bool
Returns true if this archetype has no components.
no setter
length → int
The number of component types in this archetype.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

contains(ComponentId componentId) → bool
Returns true if this archetype contains the given componentId.
containsAll(ArchetypeId other) → bool
Returns true if this archetype contains all components in other.
containsAny(ArchetypeId other) → bool
Returns true if this archetype contains any component in other.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
withComponent(ComponentId componentId) → ArchetypeId
Returns a new ArchetypeId with the given componentId added.
withoutComponent(ComponentId componentId) → ArchetypeId
Returns a new ArchetypeId with the given componentId removed.

Operators

operator ==(Object other) → bool
The equality operator.
override