Skip to content

Game.Prefabs.TransportDepot

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase, IServiceUpgrade

Summary:
TransportDepot is a prefab component used to define transport depot buildings (bus, tram, taxi, etc.) in the ECS-based simulation. It exposes configuration used to initialize the entity's TransportDepotData and related components (UpdateFrameData) and supplies the set of component types that should be present on the prefab/archetype. The component also controls which extra components are added for upgrades or service-specific behavior (e.g., Efficiency for city services, ServiceDistrict for taxis).


Fields

  • public TransportType m_TransportType
    Stores the transport mode of the depot (e.g., Bus, Tram, Taxi). This determines some archetype components and size defaults.

  • public EnergyTypes m_EnergyTypes = EnergyTypes.Fuel
    Specifies which energy types the depot supports/uses (fuel, electric, etc.). Default is Fuel.

  • public SizeClass m_SizeClass = SizeClass.Undefined
    Size classification of the depot. If left Undefined, Initialize() sets a default (Taxi -> Small, otherwise Large).

  • public int m_VehicleCapacity = 10
    Maximum number of vehicles the depot can own/store.

  • public float m_ProductionDuration
    Duration value used by the depot for vehicle production/creation cycles (used to fill TransportDepotData).

  • public float m_MaintenanceDuration
    Duration value used by the depot for vehicle maintenance cycles (used to fill TransportDepotData).

  • public bool m_DispatchCenter
    If true, this depot acts as a dispatch center. Value copied into TransportDepotData on initialization.

Properties

  • None

Constructors

  • public TransportDepot()
    Default parameterless constructor. Instances are typically configured in editor/prefab data; no custom construction logic is present in the class.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the minimal component set required for prefab instances: TransportDepotData and UpdateFrameData (read/write). Called when building prefab component lists so the entity created from the prefab has the required components.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds the set of components that should exist on the archetype for this prefab. Always adds Game.Buildings.TransportDepot. If the prefab does not have a ServiceUpgrade component it will add:

  • Efficiency (if the prefab has CityServiceBuilding)
  • ServiceDistrict (only if m_TransportType == TransportType.Taxi)
  • ServiceDispatch
  • OwnedVehicle These are added as ComponentType.ReadWrite entries.

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Adds the component types required when this building is upgraded: Game.Buildings.TransportDepot, ServiceDispatch, and OwnedVehicle.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Populates the entity's TransportDepotData and UpdateFrameData. Copies m_TransportType, m_DispatchCenter, m_EnergyTypes, m_SizeClass, m_VehicleCapacity, m_ProductionDuration, and m_MaintenanceDuration into a TransportDepotData struct. If m_SizeClass is Undefined, it defaults to Small for taxis and Large for other transport types. Finally sets UpdateFrameData(2) on the entity. Uses entityManager.SetComponentData to write the data.

Usage Example

// Example: a prefab's initialization routine will call Initialize on the TransportDepot component.
// The prefab author sets fields (m_TransportType, m_VehicleCapacity, etc.) in the inspector.
// During entity creation the engine will call:
TransportDepot depotPrefab = /* obtained from prefab */;
depotPrefab.Initialize(entityManager, entity);

// After Initialize runs, the entity will have TransportDepotData populated and UpdateFrameData set.