Skip to content

Game.CarNavigationLane

Assembly:
(assembly not specified in source file)

Namespace: Game.Vehicles

Type: struct

Base: IBufferElementData, ISerializable

Summary:
CarNavigationLane is an ECS buffer element struct used to store navigation-related information for cars. It holds a reference to a lane Entity, a 2D curve position along that lane (float2), and lane-specific flags (CarLaneFlags). The struct is marked with [InternalBufferCapacity(8)], providing a default internal capacity for the dynamic buffer, and implements custom binary serialization/deserialization via the Colossal.Serialization.Entities interfaces.


Fields

  • public Entity m_Lane
    Reference to the lane Entity this navigation entry refers to. Used to link navigation data to a specific road lane.

  • public float2 m_CurvePosition
    2D position along the lane curve (Unity.Mathematics.float2). Represents the location on the lane curve relevant for navigation.

  • public CarLaneFlags m_Flags
    Flags describing properties of the lane (stored as a CarLaneFlags enum). Used to convey lane attributes when performing navigation decisions or when serializing state.

Properties

  • None (this struct exposes public fields; it implements IBufferElementData so instances are stored in DynamicBuffer)

Constructors

  • public CarNavigationLane()
    No explicit constructors are defined in source — the default parameterless value-type constructor is used.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the struct members into the provided writer. The implementation writes m_Lane (Entity), m_CurvePosition (float2), and m_Flags cast to uint. Used by the game's custom serialization system.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the struct members from the provided reader. The implementation reads into m_Lane and m_CurvePosition, then reads a uint and casts it back to CarLaneFlags for m_Flags.

Notes: - The serialization methods use generic writer/reader interfaces (IWriter / IReader) from Colossal.Serialization.Entities. - Flags are serialized as a uint to preserve bitflags.

Usage Example

// Example: adding a navigation entry to an entity's DynamicBuffer in a SystemBase or similar ECS code.
Entity myEntity = /* existing entity with a buffer of CarNavigationLane */;
var buffer = EntityManager.GetBuffer<Game.Vehicles.CarNavigationLane>(myEntity);

// Create a new navigation entry
Game.Vehicles.CarNavigationLane entry = new Game.Vehicles.CarNavigationLane
{
    m_Lane = laneEntity,                       // some Entity representing the lane
    m_CurvePosition = new Unity.Mathematics.float2(0.5f, 0.0f),
    m_Flags = Game.Vehicles.CarLaneFlags.None  // example flags value
};

buffer.Add(entry);

Additional info: - The attribute [InternalBufferCapacity(8)] hints the default capacity of the DynamicBuffer when added: it will allocate space for up to 8 elements before needing to heap-allocate additional storage. This can improve performance for small, frequently-used buffers. - Ensure CarLaneFlags and the lane Entity lifetimes are managed appropriately so references remain valid when deserializing or using entries at runtime.