Game.Simulation.Flow.LayerState
Assembly: Game (Game.dll)
Namespace: Game.Simulation.Flow
Type: public struct LayerState
Base: System.ValueType
Summary:
LayerState is a lightweight value type used to track simple pool/slot metadata for a simulation "layer" in the game's flow system. It stores counts and free indices for two related arrays: elements and element references. Typical usage is to record current array lengths, how many entries are used, and the index of the next free slot for allocation/deallocation logic in the simulation layer.
Fields
-
public int m_ElementsLength
Stores the allocated length (capacity) of the elements array for the layer. Use this to know the current capacity and to detect when the array needs to grow. -
public int m_ElementRefsLength
Stores the allocated length (capacity) of the element references array. Similar purpose as m_ElementsLength but for the element-ref collection. -
public int m_UsedElementCount
Number of element slots currently in use. This is the logical count of active elements (≤ m_ElementsLength). -
public int m_UsedElementRefCount
Number of element-reference slots currently in use. This is the logical count of active element refs (≤ m_ElementRefsLength). -
public int m_FreeElementIndex
Index of the next free element slot (or head of a free list). Used by allocation code to quickly find a free element index without scanning. -
public int m_FreeElementRefIndex
Index of the next free element-reference slot (or head of a free list) for allocations of element refs.
Properties
- This struct does not define any managed properties; it exposes only the public fields above.
Constructors
public LayerState()
Structs in C# have an implicit parameterless constructor that initializes all integer fields to 0. There is no explicit constructor in the source. After default construction, all counts and indices are zero (no capacity, no used items, free indices at 0).
Methods
- This struct does not declare any methods. It is a plain data container.
Usage Example
// Initialize a LayerState (all fields zeroed).
LayerState layer = new LayerState();
// Set capacities when creating underlying arrays
layer.m_ElementsLength = 1024;
layer.m_ElementRefsLength = 2048;
// When allocating a new element:
int newIndex = layer.m_FreeElementIndex; // suppose free list logic resolves to a valid slot
layer.m_UsedElementCount++;
// When freeing an element:
layer.m_UsedElementCount--;
layer.m_FreeElementIndex = /* link freed index into free list */ newIndex;
// Simple check for resizing:
if (layer.m_UsedElementCount >= layer.m_ElementsLength)
{
// grow elements array and update m_ElementsLength accordingly
}
Notes: - Because LayerState is a struct, it is copied by value. Pass by reference (ref/out) when you intend to modify the original instance. - Concurrency: this type contains plain ints and has no internal synchronization. Any multi-threaded access must be synchronized externally. - The exact semantics of "free index" (single index vs. free-list head) depend on the surrounding implementation in the flow system.