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
TThe 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
capacityintThe fixed capacity.
Properties
Capacity
Gets the capacity of the array.
public int Capacity { get; }
Property Value
ComponentType
Gets the component type stored in this array.
public Type ComponentType { get; }
Property Value
Count
Gets the number of components stored.
public int Count { get; }
Property Value
Methods
Add(in T)
Adds a component to the array.
public int Add(in T component)
Parameters
componentTThe 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
valueobjectThe 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
sourceIndexintThe index in this array.
destinationIComponentArrayThe destination array.
GetBoxed(int)
Gets the boxed component value at the specified index.
public object GetBoxed(int index)
Parameters
indexintThe 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
indexint
Returns
- T
GetRef(int)
Gets a reference to the component at the specified index.
public ref T GetRef(int index)
Parameters
indexint
Returns
- T
RemoveAtSwapBack(int)
Removes the component at the specified index by swapping with the last element.
public void RemoveAtSwapBack(int index)
Parameters
indexintThe index to remove.
Set(int, in T)
Sets the component value at the specified index.
public void Set(int index, in T component)
Parameters
indexintcomponentT
SetBoxed(int, object)
Sets the component value at the specified index from a boxed value.
public void SetBoxed(int index, object value)