Table of Contents

Struct TickEntities

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

The entities a system run receives (Entities): a range of a pooled array, or a view that walks clusters or a partition.

public readonly struct TickEntities : IReadOnlyCollection<EntityId>, IEnumerable<EntityId>, IEnumerable
Implements
Inherited Members

Remarks

A value, so a system run allocates nothing for it. Entities was an IReadOnlyCollection<EntityId>, and every serial run boxed the PooledEntityList it was handed into it, and every parallel chunk its PooledEntitySlice: one object per system per tick, a steady MMORPG shard's last avoidable allocation (#1623 residual). foreach binds to the struct enumerator below and allocates nothing either; going through the interface (LINQ) still boxes, as it always did.

The backing array is pooled: do not hold this, or anything read from it by reference, beyond the system's Execute scope.

Properties

Count

How many entities.

public int Count { get; }

Property Value

int

Empty

No entities.

public static TickEntities Empty { get; }

Property Value

TickEntities

IsArrayBacked

Whether the set is a pooled array range, which AsSpan() and the indexer read directly.

public bool IsArrayBacked { get; }

Property Value

bool

this[int]

The entity at index, for an array-backed set. A cluster or partition view has no random access: enumerate it instead.

public EntityId this[int index] { get; }

Parameters

index int

0-based.

Property Value

EntityId

Exceptions

ArgumentOutOfRangeException

index is outside the set.

NotSupportedException

The set is a view, which only enumerates.

Methods

AsSpan()

The entities as a span, for an array-backed set; empty for a view (check IsArrayBacked).

public ReadOnlySpan<EntityId> AsSpan()

Returns

ReadOnlySpan<EntityId>

GetEnumerator()

The allocation-free enumerator foreach binds to.

public TickEntities.Enumerator GetEnumerator()

Returns

TickEntities.Enumerator

Operators

implicit operator TickEntities(PooledEntityList)

A pooled list, whole.

public static implicit operator TickEntities(PooledEntityList list)

Parameters

list PooledEntityList

Returns

TickEntities

implicit operator TickEntities(PooledEntitySlice)

A range of a pooled list (a parallel chunk's share).

public static implicit operator TickEntities(PooledEntitySlice slice)

Parameters

slice PooledEntitySlice

Returns

TickEntities