Class Group
Namespace: KenseiECS
Owning group: keeps the dense arrays of its pools aligned so that every entity holding all owned components sits at the same dense index in each pool, packed at the front. Iteration then reads the component arrays directly — no sparse lookups, one bounds check per span.
A pool can be owned by one group only. Entities gain and lose membership as components are added and removed; the group is always exact.
Usage:
var group = world.Group<Position, Velocity>();
var pos = group.Data1;
var vel = group.Data2;
for (int i = 0; i < pos.Length; i++) {
pos[i].X += vel[i].X;
}Iterate in reverse when destroying entities or removing owned components inside the loop: the last member is swapped into the freed slot.
public abstract class GroupInheritance
Derived
Group<T1, T2>, Group<T1, T2, T3, T4>, Group<T1, T2, T3>
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Properties
Count
Number of entities holding every owned component.
public int Count { get; }Property Value
Entities
Entity indices of the members, aligned with the data spans.
public ReadOnlySpan<int> Entities { get; }Property Value
PoolCount
Number of owned component pools.
public int PoolCount { get; }Property Value
Methods
GetPool(int)
Owned pool at index, in type-argument order.
public ComponentPoolBase GetPool(int index)Parameters
index int
Pool index, from 0 to PoolCount - 1.
Returns
The owned component pool.
