Table of Contents

Class FixedComponentArray<T>

Namespace
KeenEyes
Assembly
KeenEyes.Core.dll

Fixed-capacity component storage for use in archetype chunks. Unlike ComponentArray<T>, this array does not grow and uses a simple pre-allocated array for predictable memory layout.

public sealed class FixedComponentArray<T> : IComponentArray where T : struct, IComponent

Type Parameters

T

The component type to store.

Inheritance
FixedComponentArray<T>
Implements
Inherited Members

Constructors

FixedComponentArray(int)

Fixed-capacity component storage for use in archetype chunks. Unlike ComponentArray<T>, this array does not grow and uses a simple pre-allocated array for predictable memory layout.

public FixedComponentArray(int capacity)

Parameters

capacity int

The fixed capacity.

Properties

Capacity

Gets the capacity of the array.

public int Capacity { get; }

Property Value

int

ComponentType

Gets the component type stored in this array.

public Type ComponentType { get; }

Property Value

Type

Count

Gets the number of components stored.

public int Count { get; }

Property Value

int

Methods

Add(in T)

Adds a component to the array.

public int Add(in T component)

Parameters

component T

The component to add.

Returns

int

The index where the component was added.

Exceptions

InvalidOperationException

Thrown when the array is at capacity.

AddBoxed(object)

Adds a component from a boxed value.

public int AddBoxed(object value)

Parameters

value object

The boxed component value to add.

Returns

int

The index where the component was added.

AsReadOnlySpan()

Gets a readonly span over the valid components in this array.

public ReadOnlySpan<T> AsReadOnlySpan()

Returns

ReadOnlySpan<T>

AsSpan()

Gets a span over the valid components in this array.

public Span<T> AsSpan()

Returns

Span<T>

Clear()

Clears all components from this array.

public void Clear()

CopyTo(int, IComponentArray)

Copies a component from this array to another array. Used during entity migration between archetypes.

public void CopyTo(int sourceIndex, IComponentArray destination)

Parameters

sourceIndex int

The index in this array.

destination IComponentArray

The destination array.

GetBoxed(int)

Gets the boxed component value at the specified index.

public object GetBoxed(int index)

Parameters

index int

The index of the component.

Returns

object

The boxed component value.

Remarks

This method boxes the component and should only be used for debugging or serialization scenarios. For performance-critical code, use the typed GetRef(int) method.

GetReadonly(int)

Gets a readonly reference to the component at the specified index.

public ref readonly T GetReadonly(int index)

Parameters

index int

Returns

T

GetRef(int)

Gets a reference to the component at the specified index.

public ref T GetRef(int index)

Parameters

index int

Returns

T

RemoveAtSwapBack(int)

Removes the component at the specified index by swapping with the last element.

public void RemoveAtSwapBack(int index)

Parameters

index int

The index to remove.

Set(int, in T)

Sets the component value at the specified index.

public void Set(int index, in T component)

Parameters

index int
component T

SetBoxed(int, object)

Sets the component value at the specified index from a boxed value.

public void SetBoxed(int index, object value)

Parameters

index int

The index of the component.

value object

The boxed component value.