Game.PathfindSetupBuffer
Assembly:
Game (inferred from file path: Game\Simulation)
Namespace: Game.Simulation
Type:
struct PathfindSetupBuffer
Base:
Implements: IPathfindTargetBuffer (value type / struct)
Summary:
A lightweight container used to enqueue pathfinding setup work items into a Unity.Collections.NativeQueue for processing by the pathfinding system. The struct holds a ParallelWriter to allow thread-safe enqueueing from jobs/worker threads and an integer setup index that is stamped into each enqueued PathfindSetupTarget. The buffer itself does not own the underlying queue — the queue must be created, provided and disposed by the caller.
Fields
-
public NativeQueue<PathfindSetupTarget>.ParallelWriter m_Queue
Parallel writer for a NativeQueue of PathfindSetupTarget. Used to enqueue PathfindSetupTarget instances in a thread-safe manner from jobs or multiple threads. This writer must be obtained from a valid NativeQueuevia AsParallelWriter() and the queue's lifetime must be managed externally. -
public int m_SetupIndex
Integer identifier (setup index) that is assigned to each PathfindSetupTarget when enqueued. Typically used to group or identify a particular pathfinding setup batch.
Properties
- This type does not declare any properties.
Constructors
public PathfindSetupBuffer()
Implicit default struct constructor. Note: before using Enqueue you must assign m_Queue (to a valid ParallelWriter) and set m_SetupIndex appropriately.
Methods
public void Enqueue(PathTarget pathTarget)
Creates a new PathfindSetupTarget with m_SetupIndex set to this buffer's m_SetupIndex and m_PathTarget set to the provided pathTarget, then enqueues it using m_Queue.Enqueue(...). This is intended to be safe for use from job worker threads when m_Queue is a ParallelWriter. Caller responsibilities: ensure m_Queue is initialized and the backing NativeQueue remains valid for the duration of usage.
Usage Example
// create the queue (lifetime managed by caller)
var queue = new NativeQueue<PathfindSetupTarget>(Allocator.TempJob);
// prepare the buffer with a ParallelWriter and a setup index
var buffer = new PathfindSetupBuffer
{
m_Queue = queue.AsParallelWriter(),
m_SetupIndex = 42
};
// create or obtain a PathTarget (from Game.Pathfind)
PathTarget target = new PathTarget { /* ... */ };
// enqueue a setup target (can be called from jobs when using the ParallelWriter)
buffer.Enqueue(target);
// when finished on the producer side, consume the queue on the main thread or a consumer job
// remember to Dispose() the queue when done
queue.Dispose();
Notes and tips: - The struct itself does not allocate or dispose the NativeQueue — manage the queue lifetime externally. - Use AsParallelWriter() when creating m_Queue if you will enqueue from multiple threads/jobs. - Ensure PathfindSetupTarget and PathTarget definitions are compatible with burst/jobs if used in jobs.