Skip to content

Game.Routes.WaitingPassengers

Assembly: Assembly-CSharp
Namespace: Game.Routes

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
WaitingPassengers is an ECS component that stores counts and accumulation statistics for passengers that are waiting on a route. It is serialized/deserialized with backward compatibility checks against save/version constants (Version.passengerWaitTimeCost and Version.passengerWaitTimeCost2). The component is intended to be attached to entities that track passenger wait state in Cities: Skylines 2 route logic and can be used in queries (IQueryTypeParameter).


Fields

  • public int m_Count
    Stores the current number of waiting passengers. Serialized unconditionally.

  • public int m_OngoingAccumulation
    Accumulates ongoing waiting count over time. Only present in saved data when the serialized version is at or above Version.passengerWaitTimeCost2. Used to track in-progress accumulation for analytics/metrics.

  • public int m_ConcludedAccumulation
    Accumulates concluded waiting instances (e.g., completed waits). Only deserialized when reader.context.version >= Version.passengerWaitTimeCost.

  • public ushort m_SuccessAccumulation
    Counts successful pickups/completions related to waiting passengers. Deserialized only when reader.context.version >= Version.passengerWaitTimeCost.

  • public ushort m_AverageWaitingTime
    Stores average waiting time (likely in some compacted unit). Deserialized only when reader.context.version >= Version.passengerWaitTimeCost.

Properties

This type has no managed properties; it exposes only public fields and implements interfaces for ECS and serialization.

Constructors

  • public WaitingPassengers()
    Default (implicit) constructor initializes all numeric fields to zero. Instances are typically created and then updated by route systems or restored by the deserializer.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component fields to the provided writer in the following order: m_Count, m_OngoingAccumulation, m_ConcludedAccumulation, m_SuccessAccumulation, m_AverageWaitingTime. The writer is expected to handle versioning on the save side; this method always writes all fields (so saved data will include them).

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component fields from reader. Deserialization is version-aware:

  • m_Count is always read.
  • m_OngoingAccumulation is read only if reader.context.version >= Version.passengerWaitTimeCost2.
  • m_ConcludedAccumulation, m_SuccessAccumulation, and m_AverageWaitingTime are read only if reader.context.version >= Version.passengerWaitTimeCost. This preserves compatibility with older save formats where newer fields were not present.

Notes: - TWriter and TReader are generic writer/reader types from the Colossal.Serialization.Entities system. - The method uses ref locals to read directly into fields.

Usage Example

// Example: create and attach the component to an entity via EntityManager
var waiting = new WaitingPassengers {
    m_Count = 0,
    m_OngoingAccumulation = 0,
    m_ConcludedAccumulation = 0,
    m_SuccessAccumulation = 0,
    m_AverageWaitingTime = 0
};

entityManager.AddComponentData(entity, waiting);

// Example: component will be updated by route systems each frame/system update.
// When saving/loading, the game's serialization pipeline will call Serialize/Deserialize.
// No manual calls are normally required for save/load unless implementing a custom writer/reader.

Additional notes: - The presence of IQueryTypeParameter means this struct can be used directly in Entity queries (e.g., Entities.ForEach or System queries). - The conditional reads on Deserialize rely on the game's Version constants; if you introduce new fields in future mods, follow the same pattern to keep save compatibility.