Skip to content

Game.AccessLane

Assembly: Assembly-CSharp
Namespace: Game.Routes

Type: struct

Base: IComponentData, IQueryTypeParameter, IEquatable, ISerializable

Summary:
Represents a reference to a lane used by the routing system together with a position along the lane's curve. This lightweight value type is intended for use in Unity's ECS (IComponentData / query parameter) so it can be attached to entities or passed in queries. It implements custom serialization for save/load and value semantics via IEquatable for efficient comparisons in collections or job code.


Fields

  • public Unity.Entities.Entity m_Lane
    Holds the Entity identifier for the lane this AccessLane refers to. In Cities: Skylines 2 modding, this typically references a lane entity managed by the road/traffic systems.

  • public System.Single m_CurvePos
    A floating-point position along the lane's curve (usually normalized or in the lane's curve coordinate space). Indicates where along the lane the access point applies.

Properties

  • None

Constructors

  • public AccessLane(Unity.Entities.Entity lane, System.Single curvePos)
    Creates a new AccessLane with the given lane entity and curve position. Use this when creating component data or temporary route data in job/manager code.

Methods

  • public bool Equals(AccessLane other)
    Implements IEquatable. Returns true when both m_Lane and m_CurvePos are equal. Useful for fast value comparisons without boxing.

  • public override int GetHashCode()
    Provides a combined hash code based on m_Lane and m_CurvePos. Suitable for use when AccessLane is used as a key in hashed collections.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
    Serializes the struct in save files or network transfer. Writes m_Lane followed by m_CurvePos in that order. The writer must support writing Entity and float types.

  • public void Deserialize<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
    Deserializes data back into the struct. Reads m_Lane then m_CurvePos in the same order used by Serialize. Implemented with out/ref to fill the struct fields.

Usage Example

// Creating and using an AccessLane in ECS/component context
var laneEntity = someLaneEntity; // Unity.Entities.Entity obtained from lane manager
float curvePosition = 0.25f; // 25% along the lane curve

AccessLane access = new AccessLane(laneEntity, curvePosition);

// Equality check
AccessLane other = new AccessLane(laneEntity, 0.25f);
bool same = access.Equals(other); // true

// Example: assigning to an entity component (pseudo-code)
entityManager.AddComponentData(routeEntity, access);

// Serialization example (writer/reader types provided by the game's serialization system)
writer.Write(access.m_Lane);
writer.Write(access.m_CurvePos);
// Corresponding reader.Read(...) used inside Deserialize<TReader>

Notes: - When storing AccessLane in persistent data ensure the serialization order matches Serialize/Deserialize (m_Lane then m_CurvePos). - Be mindful that Entity values may need remapping when loading saved games (the game's serialization system typically handles this).