Struct ArchetypeAccessor<TArch>
Fast-path entity accessor pre-bound to a specific archetype. Bypasses epoch checks, archetype lookup, and null guards that are redundant for PTA workers.
Created via For<TArch>(). Must be disposed after use.
public ref struct ArchetypeAccessor<TArch> where TArch : class
Type Parameters
TArch
- Inherited Members
Remarks
What it skips per-entity vs ResolveEntity(EntityId, bool, bool):
- EpochThreadRegistry.IsCurrentThreadInScope check (ThreadStatic access)
- ArchetypeRegistry.GetMetadata lookup
- Null guards on archetype state and entity map
- EntityMap ChunkAccessor cache check (always same archetype)
Versioned components are supported — revision chain walk is performed only for Versioned slots. SV/Transient slots skip the chain walk entirely (the common fast path for game systems).
Cluster storage: when the archetype uses cluster storage, Resolve reads ClusterEntityRecord from the EntityMap and populates EntityRef's cluster fields for direct SoA access.
Properties
ClusterCount
Number of active clusters (clusters with at least one live entity).
public int ClusterCount { get; }
Property Value
HasClusterStorage
True if this archetype uses cluster storage.
public bool HasClusterStorage { get; }
Property Value
Methods
ClusterCountIn(RealmId)
How many clusters of this archetype are in realm realm.
public int ClusterCountIn(RealmId realm)
Parameters
realmRealmId
Returns
Exceptions
- InvalidOperationException
realmis not registered.
Dispose()
Release the cached EntityMap and cluster ChunkAccessors.
public void Dispose()
GetClusterEnumerator()
Get an enumerator over active clusters for direct SoA iteration. The enumerator owns its own ChunkAccessor and must be disposed.
public ClusterEnumerator<TArch> GetClusterEnumerator()
Returns
- ClusterEnumerator<TArch>
GetClusterEnumerator(int, int)
Get a scoped enumerator over a range of active clusters for parallel dispatch. Each worker gets a non-overlapping range [startIndex, endIndex) into Typhon.Engine.Internals.ArchetypeClusterState.ActiveClusterIds. Use StartClusterIndex/EndClusterIndex for the range.
public ClusterEnumerator<TArch> GetClusterEnumerator(int startIndex, int endIndex)
Parameters
Returns
- ClusterEnumerator<TArch>
GetClusterEnumerator(int[], int, int)
Get a scoped enumerator over an explicit cluster-id source array (issue #231). Typical usage from a tier-filtered QuerySystem:
foreach (var cluster in ctx.Accessor.GetClusterEnumerator<Ant>(ctx.ClusterIds, ctx.StartClusterIndex, ctx.EndClusterIndex)) { ... }
When clusterIds is the archetype's ActiveClusterIds, this overload is semantically equivalent
to GetClusterEnumerator(int, int). When it is a per-tier cluster list, the enumerator iterates only the tier's clusters.
public ClusterEnumerator<TArch> GetClusterEnumerator(int[] clusterIds, int startIndex, int endIndex)
Parameters
Returns
- ClusterEnumerator<TArch>
GetClusterEnumerator(RealmId)
An enumerator over the clusters of this archetype in realm realm only (Realms): O(clusters in that realm), not a filter over
every realm's. An archetype without a [RealmKey] lives in realm 0 — all its clusters there, none elsewhere. The enumerator owns its own
ChunkAccessor and must be disposed.
public ClusterEnumerator<TArch> GetClusterEnumerator(RealmId realm)
Parameters
realmRealmId
Returns
- ClusterEnumerator<TArch>
Remarks
Like GetClusterEnumerator(), the list is live: walk it from a system, or outside the tick fence.
Exceptions
- InvalidOperationException
The archetype does not use cluster storage, or
realmis not registered.
IsAlive(EntityId)
Check whether id is an entity of this archetype visible at the accessor's TSN — the predicate every open above uses.
public bool IsAlive(EntityId id)
Parameters
idEntityId
Returns
Open(EntityId)
Open an entity for reading. Throws if it is not an entity of this archetype visible at the accessor's TSN.
public EntityRef Open(EntityId id)
Parameters
idEntityId
Returns
OpenMut(EntityId)
Open an entity for reading and writing. Throws if it is not an entity of this archetype visible at the accessor's TSN.
public EntityRefMut OpenMut(EntityId id)
Parameters
idEntityId
Returns
TryOpen(EntityId, out EntityRef)
Try to open an entity for reading. Returns false if it is not an entity of this archetype visible at the accessor's TSN.
public bool TryOpen(EntityId id, out EntityRef entity)
Parameters
Returns
TryOpenMut(EntityId, out EntityRefMut)
Try to open an entity for reading and writing, in one resolve. Returns false if it is not an entity of this archetype visible at the accessor's TSN.
public bool TryOpenMut(EntityId id, out EntityRefMut entity)
Parameters
idEntityIdentityEntityRefMut