Skip to content

Game.Routes.VehicleTiming

Assembly: Assembly-CSharp
Namespace: Game.Routes

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
VehicleTiming is a small value-type component used by the game's routing/vehicle systems to track timing information per-entity (or per-route). It stores the last departure frame and a running average of travel time. The struct implements ISerializable so its two fields are persisted in save data in a fixed order and can be used in ECS queries via IQueryTypeParameter.


Fields

  • public uint m_LastDepartureFrame
    Stores the frame index (uint) when the vehicle or route last departed. Default (when the struct is zero-initialized) is 0. This value is written first during serialization.

  • public float m_AverageTravelTime
    Running average of travel time (in game time units, float). Default is 0. This value is written second during serialization.

Properties

  • This type defines no CLR properties. It exposes only the two public fields above and implements serialization through ISerializable.

Constructors

  • public VehicleTiming()
    Implicit default parameterless constructor provided for structs. When created without initialization, m_LastDepartureFrame == 0 and m_AverageTravelTime == 0f. In ECS usage, the component will be zeroed when added unless explicitly set.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component state to the provided writer. Serialization order:
  • m_LastDepartureFrame (uint)
  • m_AverageTravelTime (float)
    The implementation copies each field to a local variable then calls writer.Write on them.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component state from the provided reader into the fields. Deserialization reads values in the same order they were written and assigns them to m_LastDepartureFrame and m_AverageTravelTime respectively.

Usage Example

// Example: creating and initializing the component for an entity
var timing = new Game.Routes.VehicleTiming
{
    m_LastDepartureFrame = (uint)currentFrame,
    m_AverageTravelTime = 12.5f
};

// Example: serializing (pseudocode — actual writer comes from the game's serialization system)
writer.Write(timing.m_LastDepartureFrame);
writer.Write(timing.m_AverageTravelTime);

// Example: deserializing into an existing component instance
reader.Read(out timing.m_LastDepartureFrame);
reader.Read(out timing.m_AverageTravelTime);

Notes: - The struct is small and blittable (8 bytes: 4 for uint + 4 for float), making it suitable for tight ECS memory layouts. - Serialization relies on a stable order of fields; changing field order or types will break compatibility with saved data.