Skip to content

Game.Routes.TransportStop

Assembly: Game (Assembly-CSharp)
Namespace: Game.Routes

Type: struct (value type) — TransportStop : IComponentData, IQueryTypeParameter, ISerializable

Base: System.ValueType

Summary:
Represents a transport stop component used by the routing/transport systems. Holds runtime data and serialization logic for per-stop state such as access restriction entity, comfort and loading factors, and flags. Implements IComponentData so it can be stored on an Entity, IQueryTypeParameter for queries, and ISerializable to handle save/load behavior. The Deserialize method contains version checks to maintain backward compatibility with older save formats.


Fields

  • public Entity m_AccessRestriction
    Holds an Entity that represents an access restriction (e.g., a pathfinding access-restriction object). Serialized by Write; on deserialization it is read only if the reader context version is >= Version.pathfindAccessRestriction. If older version, this field will remain its default value.

  • public float m_ComfortFactor
    A multiplier or factor representing passenger comfort at the stop. This value is written and read unconditionally (present in all supported versions shown here).

  • public float m_LoadingFactor
    A multiplier representing loading behavior at the stop (affects boarding/alighting speed or weights). Written in Serialize, but the Deserialize method reads it only if the reader context version is >= Version.transportLoadingFactor — this ensures compatibility with saves before that feature existed.

  • public StopFlags m_Flags
    Bitflags describing state/behavior of the stop (StopFlags is a flags enum defined elsewhere). In Serialize it is written as a uint; in Deserialize a uint is read and cast back to StopFlags.

Properties

  • None defined on this struct. (All data is exposed as public fields for ECS/component usage.)

Constructors

  • public TransportStop()
    Default parameterless constructor (compiler provided for structs). Initializes fields to their default values (Entity.Null for m_AccessRestriction, 0.0f for floats, zero for flags). You can initialize fields explicitly when creating the struct.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component data to the provided writer. Order:
  • m_AccessRestriction (Entity)
  • m_ComfortFactor (float)
  • m_LoadingFactor (float)
  • m_Flags as a uint

Note: Serialize writes all fields in this order. The reader must expect the same order or perform version-aware reads.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component data from the provided reader. The method performs version checks to stay compatible with older save formats:
  • If reader.context.version >= Version.pathfindAccessRestriction, it reads m_AccessRestriction.
  • Always reads m_ComfortFactor.
  • If reader.context.version >= Version.transportLoadingFactor, reads m_LoadingFactor.
  • Reads a uint and casts it to StopFlags for m_Flags.

Ensure that the reader context version constants (Version.pathfindAccessRestriction, Version.transportLoadingFactor) are defined elsewhere in the codebase and reflect save-file feature introductions.

Usage Example

// Create and initialize a TransportStop component
var stop = new TransportStop {
    m_AccessRestriction = Entity.Null, // or reference to an access restriction entity
    m_ComfortFactor = 1.0f,
    m_LoadingFactor = 1.0f,
    m_Flags = StopFlags.None
};

// Add to an entity via EntityManager (example)
entityManager.AddComponentData(entity, stop);

// Example: serialization (framework normally calls this when saving)
writer.Write(stop.m_AccessRestriction);
writer.Write(stop.m_ComfortFactor);
writer.Write(stop.m_LoadingFactor);
writer.Write((uint)stop.m_Flags);

// Example: deserialization must respect version checks shown in Deserialize above

Notes and tips: - Because this is an ECS component (IComponentData), prefer direct field access and value-type semantics; avoid boxing. - Pay attention to version checks in Deserialize when modifying serialization layout — add new fields guarded by version checks to maintain backward compatibility. - StopFlags and Version symbols are defined elsewhere; consult their definitions for valid flag values and version constants.