Table of Contents

Class EntityAccessor

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Base class providing MVCC-correct entity access at a frozen TSN. Holds the minimum state needed for entity reads and SingleVersion/Transient writes: engine reference, epoch scope, component accessor cache, and ChangeSet.

Transaction extends this with spawn/destroy, commit/rollback, and TransactionChain insertion. PointInTimeAccessor wraps per-thread instances of this class for lock-free parallel entity access.

public class EntityAccessor : IDisposable
Inheritance
EntityAccessor
Implements
Derived
Inherited Members

Constructors

EntityAccessor()

Creates a new EntityAccessor with empty component-lookup caches; an internal init path binds it before use.

public EntityAccessor()

Properties

TSN

Transaction sequence number defining this accessor's MVCC read snapshot; entity visibility is evaluated against this value.

public long TSN { get; }

Property Value

long

Methods

Dispose()

Releases the accessor's cached chunk accessors, drops excess dirty-page marks, and resets its state for reuse. A bare accessor holds no persistent epoch scope, so none is exited here; Transaction overrides this to add a thread-affinity check and exit its own epoch scope.

public virtual void Dispose()

For<TArch>()

Create a fast-path ArchetypeAccessor<TArch> pre-bound to a specific archetype. Bypasses epoch checks, archetype lookup, and MVCC visibility on every Open/OpenMut call. Intended for PTA workers in parallel QuerySystems where these checks are redundant.

public ArchetypeAccessor<TArch> For<TArch>() where TArch : class

Returns

ArchetypeAccessor<TArch>

Type Parameters

TArch

GetClusterEnumerator<TArch>()

Get a full cluster enumerator over all active clusters, bypassing ArchetypeAccessor<TArch>. See GetClusterEnumerator<TArch>(int, int) for details.

public ClusterEnumerator<TArch> GetClusterEnumerator<TArch>() where TArch : class

Returns

ClusterEnumerator<TArch>

Type Parameters

TArch

GetClusterEnumerator<TArch>(int, int)

Get a scoped cluster enumerator for parallel iteration, bypassing ArchetypeAccessor<TArch>. Eliminates EntityMap accessor creation, duplicate cluster ChunkAccessors, and ComponentInfo pre-warming that are unnecessary for pure cluster-iteration systems (systems that only use GetSpan/GetReadOnlySpan, never Open/OpenMut).

public ClusterEnumerator<TArch> GetClusterEnumerator<TArch>(int startIndex, int endIndex) where TArch : class

Parameters

startIndex int

Inclusive start into Typhon.Engine.Internals.ArchetypeClusterState.ActiveClusterIds. Use StartClusterIndex.

endIndex int

Exclusive end index. Use EndClusterIndex.

Returns

ClusterEnumerator<TArch>

Type Parameters

TArch

GetClusterEnumerator<TArch>(int[], int, int)

Get a scoped cluster enumerator over an explicit cluster-id source array (issue #231). Used by tier-filtered QuerySystems that read ClusterIds at dispatch time:

foreach (var cluster in ctx.Accessor.GetClusterEnumerator<Ant>(ctx.ClusterIds, ctx.StartClusterIndex, ctx.EndClusterIndex)) { ... }

When clusterIds is the archetype's ActiveClusterIds, this is semantically equivalent to GetClusterEnumerator<TArch>(int, int). When it is a per-tier cluster list, the enumerator iterates only the tier's clusters.

public ClusterEnumerator<TArch> GetClusterEnumerator<TArch>(int[] clusterIds, int startIndex, int endIndex) where TArch : class

Parameters

clusterIds int[]
startIndex int
endIndex int

Returns

ClusterEnumerator<TArch>

Type Parameters

TArch

Open(EntityId)

Open an entity for reading. Throws if not found or not visible.

public EntityRef Open(EntityId id)

Parameters

id EntityId

Returns

EntityRef

OpenMut(EntityId)

Open an entity for reading and writing (SV/Transient only). Override in Transaction to add EnsureMutable + state transition.

public virtual EntityRef OpenMut(EntityId id)

Parameters

id EntityId

Returns

EntityRef

TryOpen(EntityId, out EntityRef)

Try to open an entity. Returns false if the entity doesn't exist or isn't visible.

public bool TryOpen(EntityId id, out EntityRef entity)

Parameters

id EntityId
entity EntityRef

Returns

bool