Game.Buildings.TransportStation
Assembly: Assembly-CSharp (game code)
Namespace: Game.Buildings
Type: struct
Base: Implements IComponentData, IQueryTypeParameter, ISerializable
Summary:
TransportStation is an ECS component (struct) used by the game's building/transport systems to store per-station configuration and runtime data relevant to passenger/vehicle handling. It holds comfort and loading modifiers, the allowed refuel/energy types for different vehicle categories (car, train, watercraft, aircraft), and station flags. The type implements custom binary serialization (Serialize/Deserialize) used by the game's save/load system and respects versioned serialization (loading factor is conditionally read based on saved data version).
Fields
-
public float m_ComfortFactor
Comfort modifier for the station. Used to influence passenger satisfaction or comfort-related calculations. -
public float m_LoadingFactor
Loading speed/efficiency modifier for the station. Note: this field is versioned — older saves may not contain it. Deserialize only reads it when the save version meets the required threshold. -
public EnergyTypes m_CarRefuelTypes
Allowed energy/refuel types for cars that operate from this station. EnergyTypes is an enum (bitmask in many implementations) describing fuel/electric/hybrid categories. -
public EnergyTypes m_TrainRefuelTypes
Allowed refuel types for trains using this station. -
public EnergyTypes m_WatercraftRefuelTypes
Allowed refuel types for watercraft using this station (ferries, etc.). -
public EnergyTypes m_AircraftRefuelTypes
Allowed refuel types for aircraft serving this station (airports/heliports). -
public TransportStationFlags m_Flags
Station-specific flags describing enabled behaviors or states. TransportStationFlags is an enum (likely a flags enum) representing binary options for the station.
Properties
- This struct exposes no C# properties. All data members are public fields and serialization is handled via the ISerializable implementation.
Constructors
public TransportStation()
Default value-type constructor. Fields should be initialized explicitly by callers (e.g., when creating the component for an entity).
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the struct's state to the provided writer. Order and conversions used:- Writes m_ComfortFactor (float)
- Writes m_LoadingFactor (float)
-
Writes each EnergyTypes field and flags as a single byte cast: m_CarRefuelTypes, m_TrainRefuelTypes, m_WatercraftRefuelTypes, m_AircraftRefuelTypes, m_Flags
Note: EnergyTypes and TransportStationFlags are serialized as bytes here; ensure compatibility when changing enum definitions. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the struct's state from the provided reader. Behavior: - Reads m_ComfortFactor (float) unconditionally.
- Reads m_LoadingFactor (float) only if reader.context.version >= Version.transportLoadingFactor. This guards against older save formats that lack this field.
- Reads five bytes for the enums/flags and casts them back:
- byte -> m_CarRefuelTypes
- byte -> m_TrainRefuelTypes
- byte -> m_WatercraftRefuelTypes
- byte -> m_AircraftRefuelTypes
- byte -> m_Flags Important: Deserialization depends on the reader.context.version value — this is how the game ensures backward compatibility across save formats.
Usage Example
// Example: adding TransportStation as a component to an Entity and setting fields
var station = new Game.Buildings.TransportStation
{
m_ComfortFactor = 1.15f,
m_LoadingFactor = 0.9f,
m_CarRefuelTypes = EnergyTypes.Petrol | EnergyTypes.Electric, // example flags
m_TrainRefuelTypes = EnergyTypes.Diesel,
m_WatercraftRefuelTypes = EnergyTypes.Diesel,
m_AircraftRefuelTypes = EnergyTypes.JetA,
m_Flags = TransportStationFlags.Passenger | TransportStationFlags.Cargo
};
// Assuming you have an EntityManager 'entityManager' and an entity 'stationEntity':
entityManager.AddComponentData(stationEntity, station);
// Serialization example (pseudo-code, depending on game's writer implementation):
// writer is an IWriter provided by the game's save system
station.Serialize(writer);
// Deserialization is handled by the save/load system and will respect versioning:
// var station = new TransportStation();
// station.Deserialize(reader);
{{ Additional Notes: - EnergyTypes and TransportStationFlags are project-specific enums — check their definitions to understand bit layout and values. - Because enum values are serialized as bytes, adding new enum values or changing their numeric values can break compatibility; prefer appending values and maintaining existing numeric values. - This struct is intended for use in the Unity.Entities ECS environment; treat it as a plain data container without behavior beyond serialization. }}