Game.Routes.RouteNumber
Assembly:
Assembly-CSharp (common for Cities: Skylines 2 runtime types; actual assembly name may vary)
Namespace: Game.Routes
Type:
struct
Base:
IComponentData, IQueryTypeParameter, ISerializable
Summary:
A lightweight ECS component that carries a numeric identifier for a route. Used by the game's routing systems to tag entities with a route number and to persist that number across save/load via the Colossal serialization interfaces.
Fields
public System.Int32 m_Number
Holds the route identifier (integer). Default value is 0 for a newly created struct. This field is read/written by the Serialize/Deserialize implementations and is meant to be set when creating or updating route-related entities.
Properties
- (none)
This struct exposes no properties; it only contains the public integer field m_Number.
Constructors
public RouteNumber()
The struct uses the implicit default constructor which initializes m_Number to 0. You can create an initialized instance with object initializer syntax:new RouteNumber { m_Number = 5 }
.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes the component by writing the integer m_Number into the provided writer. Called by the game's serialization pipeline when saving component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Deserializes the component by reading an integer from the provided reader into m_Number. Called by the game's serialization pipeline when loading component state.
Usage Example
using Unity.Entities;
using Game.Routes;
// Create an entity and attach a RouteNumber component with route ID 42
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = em.CreateEntity();
em.AddComponentData(entity, new RouteNumber { m_Number = 42 });
// During serialization the framework will call:
// writer.Write(m_Number);
// During deserialization the framework will call:
// reader.Read(out m_Number);