Table of Contents

Struct EntityId

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

64-bit entity identifier: 48-bit monotonic EntityKey (upper) + 16-bit per-DB archetype routing id (lower). Routes to the correct per-archetype LinearHash and uniquely identifies an entity within the engine.

public readonly struct EntityId : IEquatable<EntityId>
Implements
Inherited Members

Remarks

EntityKey is monotonic per-archetype, never recycled — no ABA problem, no version field needed. 2^48 ≈ 281 T allocations per archetype.

ArchetypeId is the low 16 bits: the per-DB, engine-assigned archetype routing id (persisted in ArchetypeR1.RoutingId, re-matched by name on reopen). Up to 65,536 archetypes composable into one database. The word-aligned 48/16 split needs no mask constant — the routing id is (ushort)value and the key is value >> 16.

Fields

Null

The null entity sentinel.

public static readonly EntityId Null

Field Value

EntityId

Properties

ArchetypeId

16-bit per-DB archetype routing id (low bits). Routes to the correct per-archetype storage instance for the owning engine.

public ushort ArchetypeId { get; }

Property Value

ushort

EntityKey

48-bit monotonic key, unique within the archetype's LinearHash.

public long EntityKey { get; }

Property Value

long

IsNull

True if this is the null/default entity (no entity).

public bool IsNull { get; }

Property Value

bool

Methods

Equals(object)

Returns true when obj is an EntityId equal to this one.

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Equals(EntityId)

Returns true when other has the same packed identifier value.

public bool Equals(EntityId other)

Parameters

other EntityId

Returns

bool

GetHashCode()

Hash of the packed 64-bit identifier value.

public override int GetHashCode()

Returns

int

ToString()

Human-readable form, e.g. Entity(Key=42, Arch=3), or Entity(Null) for the null entity.

public override string ToString()

Returns

string

Operators

operator ==(EntityId, EntityId)

Value equality of two EntityId values.

public static bool operator ==(EntityId left, EntityId right)

Parameters

left EntityId
right EntityId

Returns

bool

operator !=(EntityId, EntityId)

Value inequality of two EntityId values.

public static bool operator !=(EntityId left, EntityId right)

Parameters

left EntityId
right EntityId

Returns

bool