Skip to content

Game.Pathfind.FlowAction

Assembly:
Assembly-CSharp (Assembly-CSharp.dll)

Namespace: Game.Pathfind

Type:
struct (implements System.IDisposable)

Base:
System.ValueType

Summary:
FlowAction is a small value-type wrapper around a Unity.Collections.NativeQueue of FlowActionData used by the pathfinding/flow system. It provides allocation of the native queue with a specified Allocator and implements IDisposable so the underlying native memory can be freed. This struct is intended to hold queued flow/action data for processing by the game's pathfinding flow systems.


Fields

  • public Unity.Collections.NativeQueue<FlowActionData> m_FlowData
    This is the underlying native queue that stores FlowActionData items. It is allocated in the constructor using the supplied Allocator. As a NativeQueue, it allocates unmanaged memory and must be disposed to avoid leaks. Note that this field is publicly accessible; callers can call Enqueue/Dequeue on it or obtain a parallel writer via m_FlowData.AsParallelWriter() for job use.

Properties

  • None (no properties are defined on this struct)

Constructors

  • public FlowAction(Unity.Collections.Allocator allocator)
    Initializes the internal NativeQueue using the provided Allocator (e.g., Allocator.Temp, Allocator.TempJob, Allocator.Persistent). Choose the allocator appropriate to the lifetime of the queue (Persistent for long-lived across frames, TempJob for within-job lifetime, etc.).

Methods

  • public void Dispose() : System.Void
    Disposes the internal NativeQueue and releases its native memory. Call this when the FlowAction (and its queue) is no longer needed to avoid memory leaks. Because FlowAction is a struct, take care to avoid accidental copies that could lead to multiple disposers referencing the same native queue.

Usage Example

// Create a FlowAction and use its queue.
// Pick an allocator appropriate to your lifetime (Persistent shown for long-lived storage).
var flowAction = new Game.Pathfind.FlowAction(Unity.Collections.Allocator.Persistent);

// Enqueue a FlowActionData item (FlowActionData type definition is provided elsewhere).
flowAction.m_FlowData.Enqueue(default(FlowActionData));

// When finished, dispose to free native memory.
flowAction.Dispose();

Additional notes: - Avoid making unintended copies of FlowAction (it is a value type). Copying will copy the NativeQueue struct by value and can lead to unsafe ownership semantics and double-dispose issues. - For multi-threaded/job usage, use m_FlowData.AsParallelWriter() to obtain a concurrent writer suitable for Unity.Jobs. - Always match the allocator choice to expected lifetime: Allocator.Persistent for persistent mod data, Allocator.TempJob for job-scoped queues, Allocator.Temp only for very short-lived use within a single frame.