Struct TickEntities
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
Empty
No entities.
public static TickEntities Empty { get; }
Property Value
IsArrayBacked
Whether the set is a pooled array range, which AsSpan() and the indexer read directly.
public bool IsArrayBacked { get; }
Property Value
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
indexint0-based.
Property Value
Exceptions
- ArgumentOutOfRangeException
indexis 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
GetEnumerator()
The allocation-free enumerator foreach binds to.
public TickEntities.Enumerator GetEnumerator()
Returns
Operators
implicit operator TickEntities(PooledEntityList)
A pooled list, whole.
public static implicit operator TickEntities(PooledEntityList list)
Parameters
listPooledEntityList
Returns
implicit operator TickEntities(PooledEntitySlice)
A range of a pooled list (a parallel chunk's share).
public static implicit operator TickEntities(PooledEntitySlice slice)
Parameters
slicePooledEntitySlice