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):
- 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
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>
Open(EntityId)
Open an entity for read-only access.
public EntityRef Open(EntityId id)
Parameters
idEntityId
Returns
OpenMut(EntityId)
Open an entity for read-write access.
public EntityRef OpenMut(EntityId id)
Parameters
idEntityId