Struct ArchetypeId
- Namespace
- KeenEyes
- Assembly
- KeenEyes.Core.dll
Unique identifier for an archetype based on its component type combination. Two archetypes with the same set of component types will have the same ArchetypeId.
public readonly struct ArchetypeId : IEquatable<ArchetypeId>
- Implements
- Inherited Members
Remarks
The ArchetypeId is computed by sorting component types by their full name and combining their hash codes. This ensures a stable, consistent identifier regardless of the order in which components were added.
ArchetypeId is immutable and implements value equality semantics.
Constructors
ArchetypeId(IEnumerable<Type>)
Creates an ArchetypeId from a collection of component types.
public ArchetypeId(IEnumerable<Type> types)
Parameters
typesIEnumerable<Type>The component types for this archetype.
Properties
ComponentCount
Gets the number of component types in this archetype.
public int ComponentCount { get; }
Property Value
ComponentTypes
Gets the component types that make up this archetype.
public ImmutableArray<Type> ComponentTypes { get; }
Property Value
Methods
Equals(ArchetypeId)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(ArchetypeId other)
Parameters
otherArchetypeIdAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Has(Type)
Checks if this archetype contains a specific component type.
public bool Has(Type type)
Parameters
typeTypeThe component type to check for.
Returns
- bool
True if this archetype contains the component type.
Has<T>()
Checks if this archetype contains a specific component type.
public bool Has<T>() where T : struct, IComponent
Returns
- bool
True if this archetype contains the component type.
Type Parameters
TThe component type to check for.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
With(Type)
Creates a new ArchetypeId with an additional component type.
public ArchetypeId With(Type type)
Parameters
typeTypeThe component type to add.
Returns
- ArchetypeId
A new ArchetypeId with the added component type.
With<T>()
Creates a new ArchetypeId with an additional component type.
public ArchetypeId With<T>() where T : struct, IComponent
Returns
- ArchetypeId
A new ArchetypeId with the added component type.
Type Parameters
TThe component type to add.
Without(Type)
Creates a new ArchetypeId without the specified component type.
public ArchetypeId Without(Type type)
Parameters
typeTypeThe component type to remove.
Returns
- ArchetypeId
A new ArchetypeId without the component type.
Without<T>()
Creates a new ArchetypeId without the specified component type.
public ArchetypeId Without<T>() where T : struct, IComponent
Returns
- ArchetypeId
A new ArchetypeId without the component type.
Type Parameters
TThe component type to remove.
Operators
operator ==(ArchetypeId, ArchetypeId)
Equality operator.
public static bool operator ==(ArchetypeId left, ArchetypeId right)
Parameters
leftArchetypeIdrightArchetypeId
Returns
operator !=(ArchetypeId, ArchetypeId)
Inequality operator.
public static bool operator !=(ArchetypeId left, ArchetypeId right)
Parameters
leftArchetypeIdrightArchetypeId