Game.Prefabs.TransportDepotData
Assembly:
Game
Namespace:
Game.Prefabs
Type:
struct
Base:
Implements: IComponentData, IQueryTypeParameter, ICombineData
Summary:
Data component representing configuration and runtime/static data for a transport depot prefab. Contains the transport type, supported energy types, size class, whether the depot is a dispatch center, vehicle capacity and timing values for production and maintenance. Used as an ECS component (Unity.Entities.IComponentData) and supports combining and (de)serialization for prefab merging and persistence.
Fields
-
public TransportType m_TransportType
Transport mode handled by this depot (enum). Serialized as an int. -
public EnergyTypes m_EnergyTypes
Bitmasked energy types supported by the depot (flags enum). Combined using bitwise OR when merging data and serialized as a single byte. -
public SizeClass m_SizeClass
Size class of the depot (enum). During deserialization, this is read only if the reader format has the BpPrefabData tag; otherwise defaults to SizeClass.Large. Serialized as a byte when present. -
public bool m_DispatchCenter
Whether this depot functions as a dispatch center. Serialized as a bool. -
public int m_VehicleCapacity
Total vehicle capacity of the depot. Combined by summation when merging data and serialized as an int. -
public float m_ProductionDuration
Production duration time (float). Combined by summation when merging data and serialized as a float. -
public float m_MaintenanceDuration
Maintenance duration time (float). Combined by summation when merging data and serialized as a float.
Properties
- This type does not expose managed properties; it exposes public fields and implements interface members for combine and (de)serialization.
Constructors
public TransportDepotData()
Default struct constructor (value-type default initialization). Fields should be assigned explicitly when creating instances; otherwise they'll be default(T) for their types.
Methods
public void Combine(TransportDepotData otherData)
Merges another TransportDepotData into this instance:- m_EnergyTypes |= otherData.m_EnergyTypes (bitwise OR)
- m_DispatchCenter |= otherData.m_DispatchCenter (logical OR)
- m_VehicleCapacity += otherData.m_VehicleCapacity
- m_ProductionDuration += otherData.m_ProductionDuration
-
m_MaintenanceDuration += otherData.m_MaintenanceDuration Use when aggregating data from multiple prefab sources (e.g., blueprint merging).
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes fields to the provided writer in the following order: - m_DispatchCenter (bool)
- m_VehicleCapacity (int)
- m_ProductionDuration (float)
- m_MaintenanceDuration (float)
- m_TransportType (written as int)
- m_EnergyTypes (written as byte)
-
m_SizeClass (written as byte) Ensure writer supports the expected types and that consumers read in the same order.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads fields from the provided reader in the order matching Serialize. Special handling: - Reads transport type as an int and energy types as a byte and casts them into enums.
- If reader.context.format.Has(FormatTags.BpPrefabData) is true, reads an additional byte for SizeClass. Otherwise sets m_SizeClass = SizeClass.Large by default. Uses out/ref reads to populate the struct's fields directly.
Usage Example
// Construct and initialize
var depot = new TransportDepotData
{
m_TransportType = TransportType.Bus,
m_EnergyTypes = EnergyTypes.Gasoline | EnergyTypes.Electric,
m_SizeClass = SizeClass.Medium,
m_DispatchCenter = true,
m_VehicleCapacity = 12,
m_ProductionDuration = 30f,
m_MaintenanceDuration = 10f
};
// Combine with another depot data (e.g., from a blueprint merge)
var extra = new TransportDepotData
{
m_EnergyTypes = EnergyTypes.Electric,
m_DispatchCenter = false,
m_VehicleCapacity = 3,
m_ProductionDuration = 5f,
m_MaintenanceDuration = 2f
};
depot.Combine(extra); // merges energy flags and accumulates capacities/durations
// Serialization (writer implementation provided by game's serialization system)
public void SaveDepot<TWriter>(TWriter writer, TransportDepotData data) where TWriter : IWriter
{
data.Serialize(writer);
}
// Deserialization (reader implementation provided by game's serialization system)
public TransportDepotData LoadDepot<TReader>(TReader reader) where TReader : IReader
{
var data = new TransportDepotData();
data.Deserialize(reader);
return data;
}