Skip to content

Game.Prefabs.TransportStationData

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

Type: struct

Base: System.ValueType, IComponentData, IQueryTypeParameter, ICombineData, ISerializable

Summary:
TransportStationData is an ECS component data struct used by transport station prefabs. It stores runtime/configuration values for a transport station such as comfort and loading factors plus allowed refuel energy types per vehicle category. It implements ICombineData to merge values (summing numeric factors and OR-ing EnergyTypes flags) and ISerializable to read/write a compact binary representation (floats for factors and bytes for EnergyTypes flags).


Fields

  • public float m_ComfortFactor
    Holds the comfort factor for the station. This is added when combining multiple data sources.

  • public float m_LoadingFactor
    Holds the loading factor for the station. This is added when combining multiple data sources.

  • public EnergyTypes m_CarRefuelTypes
    Bitmask of allowed refuel energy types for cars. Combined with bitwise OR when merging.

  • public EnergyTypes m_TrainRefuelTypes
    Bitmask of allowed refuel energy types for trains. Combined with bitwise OR when merging.

  • public EnergyTypes m_WatercraftRefuelTypes
    Bitmask of allowed refuel energy types for watercraft. Combined with bitwise OR when merging.

  • public EnergyTypes m_AircraftRefuelTypes
    Bitmask of allowed refuel energy types for aircraft. Combined with bitwise OR when merging.

Properties

  • None. This struct exposes only public fields; there are no C# properties defined.

Constructors

  • public TransportStationData()
    Default parameterless constructor (implicit). All numeric/enum fields default to 0 (floats = 0f, EnergyTypes = 0).

Methods

  • public void Combine(TransportStationData otherData)
    Merges another TransportStationData into this instance:
  • Adds numeric factors: m_ComfortFactor and m_LoadingFactor are incremented by the corresponding values from otherData.
  • Merges energy-type flags: each m_*RefuelTypes field is bitwise-OR'd with the corresponding value from otherData. Use case: combining stacked prefab/component contributions into a single aggregated value.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the data into a writer in a compact order:

  • Writes m_ComfortFactor (float)
  • Writes m_LoadingFactor (float)
  • Writes m_CarRefuelTypes as a byte
  • Writes m_TrainRefuelTypes as a byte
  • Writes m_WatercraftRefuelTypes as a byte
  • Writes m_AircraftRefuelTypes as a byte Note: EnergyTypes values are cast to byte for serialization—ensure enum values fit in a byte or serialization format changes accordingly.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads values in the same order they are written by Serialize:

  • Reads into m_ComfortFactor (ref float)
  • Reads into m_LoadingFactor (ref float)
  • Reads four bytes and casts each to EnergyTypes for the four refuel-type fields The method uses direct refs for floats and casts bytes to EnergyTypes for the enum fields.

Usage Example

// Combine two TransportStationData instances
TransportStationData a = new TransportStationData { m_ComfortFactor = 1.0f, m_CarRefuelTypes = EnergyTypes.Gasoline };
TransportStationData b = new TransportStationData { m_ComfortFactor = 0.5f, m_CarRefuelTypes = EnergyTypes.Electric };
a.Combine(b); // a.m_ComfortFactor == 1.5f, a.m_CarRefuelTypes == (Gasoline | Electric)

// Serialize to a writer (pseudo-code, depends on actual IWriter implementation)
using (var writer = new BinaryWriterAdapter(stream))
{
    a.Serialize(writer);
}

// Deserialize from a reader (pseudo-code)
TransportStationData loaded;
using (var reader = new BinaryReaderAdapter(stream))
{
    loaded.Deserialize(reader);
}

Additional notes: - EnergyTypes is used as a flags/bitmask enum (combined with | in Combine). Ensure any custom EnergyTypes values you add remain compatible with byte-based serialization. - As an IComponentData and IQueryTypeParameter, this struct is intended for use with Unity.Entities-based queries and storage within the game's ECS systems.