Skip to content

Game.Routes.PathTargets

Assembly:
Assembly-CSharp (game code assembly — typical for Cities: Skylines 2 mods; confirm with your project build)

Namespace:
Game.Routes

Type:
struct

Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable

Summary:
PathTargets is a lightweight ECS component/struct that holds lane target information used by routing/path logic. It stores references to a start lane and an end lane (as Entity handles), a pair of curve position values (float2) and two runtime "ready" positions (float3) used by the system while preparing routes. The struct implements ISerializable to persist the essential data (start lane, end lane and curve positions) and implements IQueryTypeParameter / IComponentData so it can be used in queries and attached to entities in the DOTS/ECS world.


Fields

  • public Entity m_StartLane
    Start lane entity reference for the path target. Serialized by Serialize/Deserialize. Represents the lane where the path begins.

  • public Entity m_EndLane
    End lane entity reference for the path target. Serialized by Serialize/Deserialize. Represents the lane where the path ends.

  • public float2 m_CurvePositions
    Two float values representing curve-related position data used by the routing system (e.g., control points or offsets). Serialized by Serialize/Deserialize.

  • public float3 m_ReadyStartPosition
    Runtime-only world position for the prepared start point. This field is not written/read by the provided Serialize/Deserialize implementations and is intended for in-memory use during path preparation.

  • public float3 m_ReadyEndPosition
    Runtime-only world position for the prepared end point. Like m_ReadyStartPosition, it is not serialized and is used at runtime by path-building code.

Properties

  • None. (This struct exposes only public fields; there are no auto-properties.)

Constructors

  • public PathTargets()
    Default parameterless value-type constructor (implicit). All fields default to their default values (Entity = default(Entity), float2/float3 = 0). There is no explicit custom constructor in the source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes persistent fields to the given writer in this order:
  • m_StartLane (Entity)
  • m_EndLane (Entity)
  • m_CurvePositions (float2)
    Note: m_ReadyStartPosition and m_ReadyEndPosition are not serialized.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the same fields back (using ref locals to assign into the struct fields) in the same order:

  • m_StartLane
  • m_EndLane
  • m_CurvePositions

Notes on serialization: - The writer/reader are generic types constrained to IWriter / IReader — typical pattern used by Colossal's serialization system. - The order and types must match between Serialize and Deserialize; if you add/remove fields, update both methods and consider versioning.

Usage Example

// Creating and populating a PathTargets instance
var targets = new PathTargets
{
    m_StartLane = startLaneEntity,
    m_EndLane = endLaneEntity,
    m_CurvePositions = new float2(0.25f, 0.75f),
    // ready positions are computed at runtime and set later:
    m_ReadyStartPosition = float3.zero,
    m_ReadyEndPosition = float3.zero
};

// Serialization (example — writer from Colossal's serialization system)
writer.Write(targets.m_StartLane);
writer.Write(targets.m_EndLane);
writer.Write(targets.m_CurvePositions);

// Typical usage in a system:
// - Attach PathTargets as a component to an entity
// - Systems read m_StartLane/m_EndLane to drive routing
// - Compute and fill m_ReadyStartPosition / m_ReadyEndPosition during preparation

{{ Additional Info: - Types referenced: - Entity: Unity.Entities.Entity - float2/float3: Unity.Mathematics.float2 / Unity.Mathematics.float3 - IWriter / IReader: Colossal.Serialization.Entities (game serialization API) - When modifying the struct layout, update Serialize/Deserialize and any save compatibility logic. - Because ready positions are not serialized, they must be recomputed on load or initialization. }}