Game.Routes.RouteLane
Assembly: Assembly-CSharp
Namespace: Game.Routes
Type: struct
Base: IComponentData, IQueryTypeParameter, IEquatable
Summary:
Represents a link between two lane entities that together form part of a route. Stores the start and end lane Entity references and the curve positions along those lanes (typically used to mark positions along the lane spline). This struct is an ECS component (IComponentData) so it can be attached to entities, supports being used as a query parameter, and implements serialization helpers for save/load through Colossal's serialization system.
Fields
-
public Entity m_StartLane
Holds the Entity that represents the start lane for this route segment. This is an ECS Entity (value type) reference. -
public Entity m_EndLane
Holds the Entity that represents the end lane for this route segment. -
public float m_StartCurvePos
Float value indicating the position along the start lane's curve/spline where this route segment begins. Typically used to order or place route points along a lane (commonly normalized between 0 and 1, but depends on calling/consuming code). -
public float m_EndCurvePos
Float value indicating the position along the end lane's curve/spline where this route segment ends.
Properties
- (none)
This type exposes only public fields; it does not declare C# properties.
Constructors
public RouteLane(Entity startLane, Entity endLane, float startCurvePos, float endCurvePos)
Creates a new RouteLane instance initialized with the provided start/end lane entities and the curve positions. Parameters:- startLane: Entity for the start lane.
- endLane: Entity for the end lane.
- startCurvePos: curve position on the start lane.
- endCurvePos: curve position on the end lane.
Methods
-
public bool Equals(RouteLane other)
Implements IEquatable. Returns true when start lane, end lane, startCurvePos and endCurvePos all match the corresponding fields of the other instance. -
public override int GetHashCode()
Returns a combined hash code based on all four fields (m_StartLane, m_EndLane, m_StartCurvePos, m_EndCurvePos). Useful when using RouteLane as a key in hash-based collections. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component fields to a generic writer provided by Colossal.Serialization. The implementation writes start lane, end lane, startCurvePos and endCurvePos in that order. Used for saving component data. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component fields from a generic reader provided by Colossal.Serialization. The implementation reads into the struct's fields in the same order they were written. Used when loading saved data.
Usage Example
using Unity.Entities;
using Colossal.Serialization.Entities;
using Game.Routes;
// create a RouteLane and attach it to an entity using an EntityManager
Entity startLane = /* obtain start lane entity */;
Entity endLane = /* obtain end lane entity */;
var routeLane = new RouteLane(startLane, endLane, 0.0f, 1.0f);
// Example: set as a component on an entity
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity someEntity = em.CreateEntity();
em.AddComponentData(someEntity, routeLane);
// Example: compare two RouteLane instances
var other = new RouteLane(startLane, endLane, 0.0f, 1.0f);
bool equal = routeLane.Equals(other); // true
// Serialization (illustrative; actual writer obtained from save pipeline)
void Save<TWriter>(TWriter writer, RouteLane rl) where TWriter : IWriter
{
rl.Serialize(writer);
}
void Load<TReader>(TReader reader, out RouteLane rl) where TReader : IReader
{
rl = default;
rl.Deserialize(reader);
}