Game.Pathfind.AvailabilityElement
Assembly: Assembly-CSharp (typical for game/mod code)
Namespace: Game.Pathfind
Type: struct
Base: IBufferElementData
Summary:
AvailabilityElement is a Unity ECS buffer element used by the pathfinding system to associate an "edge" entity with a small availability vector (float2). The struct is blittable and marked with InternalBufferCapacity(0), meaning the dynamic buffer has no inline storage capacity on the entity and elements are stored in heap-managed buffer memory. The interpretation of the two components in m_Availability depends on the pathfinding logic (for example, they might represent availability for two directions, two lanes, or two metrics used by pathfinding algorithms).
Fields
-
public Entity m_Edge
Associates this availability entry with a specific edge entity (the edge referenced in pathfinding). Typically this is the Entity representing a road edge, segment, or other connectivity unit in the pathfinding graph. -
public float2 m_Availability
A two-component availability vector (Unity.Mathematics.float2). The meaning of each component depends on the pathfinding implementation (e.g., forward/backward availability, availability for two lanes, or other per-edge metrics). Use float2 to keep the struct compact and SIMD-friendly.
Properties
- None
This struct contains only public fields and implements IBufferElementData. There are no properties defined.
Constructors
- Default (implicit) constructor
As a plain value type (struct), AvailabilityElement has the default parameterless constructor which zero-initializes fields. You typically create instances using an object initializer: new AvailabilityElement { m_Edge = edgeEntity, m_Availability = new float2(x, y) };
Methods
- None
There are no instance or static methods declared on this struct.
Usage Example
// Example in a SystemBase or other ECS code:
// Ensure the entity has a DynamicBuffer<AvailabilityElement> before adding entries.
using Unity.Mathematics;
using Unity.Entities;
// Add/Get a buffer and add an availability element
Entity someEntity = /* entity that stores availability buffer */;
Entity edgeEntity = /* the edge entity to reference */;
var buffer = EntityManager.GetBuffer<AvailabilityElement>(someEntity);
buffer.Add(new AvailabilityElement {
m_Edge = edgeEntity,
m_Availability = new float2(1.0f, 0.5f) // semantics depend on pathfinding usage
});
// Reading buffer entries
foreach (var entry in buffer)
{
Entity referencedEdge = entry.m_Edge;
float2 availability = entry.m_Availability;
// Use availability.x / availability.y as needed by your pathfinding logic
}
Additional notes: - The struct is small and suitable for large numbers of entries in a DynamicBuffer. Because of InternalBufferCapacity(0), expect buffer storage to be allocated externally rather than inline on entity memory. - Ensure that any systems that write to or read from this buffer handle concurrency (jobs) correctly via proper Entities.ForEach / Jobs / Commands patterns.