Skip to content

Game.Buildings.TransportDepot

Assembly: Game (inferred from file path: Game\Buildings)
Namespace: Game.Buildings

Type: struct

Base: Implements IComponentData, IQueryTypeParameter, ISerializable

Summary:
TransportDepot is an ECS component that represents per-depot runtime state for a transport depot building. It stores a reference to a "target request" entity used by the service/dispatch system, flags describing depot state, the number of available vehicles, and a float describing maintenance requirement. The component implements ISerializable and performs version-gated serialization/deserialization so older save versions remain compatible.


Fields

  • public Entity m_TargetRequest
    This is an Entity reference pointing to the transport request entity associated with the depot (for example a request for vehicles or service). In serialization the field is written and read only when the save version supports reverse service requests (checked during Deserialize).

  • public TransportDepotFlags m_Flags
    A bit-flag enum describing depot state (such as enabled/disabled, has pending requests, etc.). When serialized the flags are stored as a single byte (written as (byte)m_Flags). During deserialization the stored byte is cast back to TransportDepotFlags.

  • public byte m_AvailableVehicles
    Number of currently available vehicles at this depot. This field is only read from older/newer saves when the game version supports taxi/vehicle counts (checked against Version.taxiDispatchCenter in Deserialize).

  • public float m_MaintenanceRequirement
    A floating-point value representing the depot's maintenance requirement (used for upkeep or scheduling maintenance). This value is only read/written when the save version supports transport maintenance (checked against Version.transportMaintenance in Deserialize).

Properties

  • None.
    This struct exposes fields directly and does not provide managed properties.

Constructors

  • public TransportDepot()
    Default parameterless struct constructor (implicitly provided by C#). Fields default to their zero values: m_TargetRequest = Entity.Null, m_Flags = default(TransportDepotFlags), m_AvailableVehicles = 0, m_MaintenanceRequirement = 0f. If you need custom initialization, construct with an object initializer.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component state to the provided writer in a fixed order:
  • m_TargetRequest is written as an Entity.
  • m_Flags is written as a single byte ((byte)m_Flags).
  • m_AvailableVehicles is written as a byte.
  • m_MaintenanceRequirement is written as a float.
    The Serialize method does not itself check version flags; it writes all four values in this order.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component state from the provided reader. Deserialization uses version-gated reads to preserve compatibility with older saves:

  • If reader.context.version >= Version.reverseServiceRequests then m_TargetRequest is read (otherwise it is left as default/Entity.Null).
  • A byte is always read into a temporary value (this becomes the stored flags byte).
  • If reader.context.version >= Version.taxiDispatchCenter then m_AvailableVehicles is read.
  • If reader.context.version >= Version.transportMaintenance then m_MaintenanceRequirement is read.
  • Finally, the earlier-read flags byte is cast to TransportDepotFlags and stored into m_Flags.
    Note: The method relies on the specific order and presence/absence of fields depending on version. When creating compatible writers/readers for custom serialization, match the same ordering and version checks.

Usage Example

// Create and add a TransportDepot component to an entity (EntityManager/ECS usage)
var depot = new TransportDepot
{
    m_TargetRequest = Entity.Null, // set to a real request entity if available
    m_Flags = TransportDepotFlags.None,
    m_AvailableVehicles = 5,
    m_MaintenanceRequirement = 0.25f
};

entityManager.AddComponentData(depotEntity, depot);

// Example: when implementing custom serialization helpers, the component's
// Serialize/Deserialize will be called by the game's save/load systems.
// If you need to manually serialize, call the methods with an appropriate writer/reader:

// writer.Write / reader.Read must match the game's IWriter/IReader semantics.
// The component's Deserialize implementation will skip fields based on reader.context.version,
// so provide the same versioning info when mocking reads for tests.