Skip to content

Game.Routes.WaypointDefinition

Assembly: Assembly-CSharp
Namespace: Game.Routes

Type: struct

Base: Unity.Entities.IBufferElementData

Summary:
Defines a single waypoint element used with Unity DOTS dynamic buffers to represent route waypoints. Each element stores a 3D position (Unity.Mathematics.float3) and two Entity references: m_Connection to link to another waypoint/entity, and m_Original to keep a reference to an original source entity (for example, a prefab or source node). The struct is annotated with [InternalBufferCapacity(0)], meaning no elements are stored inline on the entity — all elements are stored in the dynamic buffer memory.


Fields

  • public float3 m_Position
    Holds the waypoint position in world space (Unity.Mathematics.float3). Used for path layout, rendering gizmos, and navigation calculations.

  • public Entity m_Connection
    An Entity reference intended to link this waypoint to another waypoint or route-related entity. Initialized to Entity.Null by the constructor.

  • public Entity m_Original
    An Entity reference that can be used to track the original source (for example an originating node or prefab). Initialized to Entity.Null by the constructor.

Properties

  • This struct exposes no C# properties; it only contains public fields for use in DOTS buffers.

Constructors

  • public WaypointDefinition(float3 position)
    Initializes a waypoint with the given position and sets m_Connection and m_Original to Entity.Null.

Methods

  • This struct declares no methods. It is a plain data container (IBufferElementData) intended to be stored in a DynamicBuffer.

Usage Example

// Create and populate a dynamic buffer on an entity
Entity routeEntity = ...;
var em = EntityManager;

// Add the buffer to an entity (if not already present)
var buffer = em.AddBuffer<Game.Routes.WaypointDefinition>(routeEntity);

// Append a waypoint
buffer.Add(new Game.Routes.WaypointDefinition(new float3(10f, 0f, 5f)));

// Modify an existing waypoint (DynamicBuffer<T> indexer returns a ref)
ref var wp = ref buffer[0];
wp.m_Connection = someOtherEntity;
wp.m_Original = originalEntity;

// Alternatively, in a system using Entities.ForEach or ComponentSystem:
// var buf = GetBuffer<WaypointDefinition>(entity);
// buf.Add(new WaypointDefinition(position));

Additional notes: - Because of [InternalBufferCapacity(0)], the buffer has no inline capacity; all elements are allocated out-of-line. This is appropriate when you expect variable or large numbers of waypoints. - Use Entity.Null to represent "no connection" or "no original" until you set valid Entity references.