Game.Prefabs.TransportStation
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase, IServiceUpgrade
Summary:
TransportStation is a prefab component used to define transport station buildings (bus stops, train stations, ports, airports) in the ECS-based game. It exposes configurable refuel/energy compatibility for different vehicle types and a comfort multiplier. The prefab contributes required component types for entity archetypes and initializes entity component data (TransportStationData, PublicTransportStationData and UpdateFrameData) during runtime. The class is decorated with a ComponentMenu attribute so it can be created/configured in editor tooling.
Fields
-
public EnergyTypes m_CarRefuelTypes
Holds bitflags of EnergyTypes supported for road vehicles (cars, buses). Values set here are merged into the entity's TransportStationData during Initialize. -
public EnergyTypes m_TrainRefuelTypes
Bitflags of EnergyTypes supported for trains. Merged into the TransportStationData on initialization. -
public EnergyTypes m_WatercraftRefuelTypes
Bitflags of EnergyTypes supported for watercraft (ships, boats). Merged into the TransportStationData on initialization. -
public EnergyTypes m_AircraftRefuelTypes
Bitflags of EnergyTypes supported for aircraft. Merged into the TransportStationData on initialization. -
public float m_ComfortFactor
A multiplier applied to comfort or service quality coming from this station; copied into TransportStationData.m_ComfortFactor during Initialize.
Properties
- None (no public properties declared in this class).
This prefab exposes configuration via public fields rather than properties.
Constructors
public TransportStation()
Default parameterless constructor. Instances are typically created by the editor/prefab system; no custom construction logic is defined in the class.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds component types that every instance of the prefab should contain. This implementation adds TransportStationData, PublicTransportStationData and UpdateFrameData component types (ReadWrite). -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds component types required for the entity archetype when this prefab is used. Adds Game.Buildings.TransportStation and PublicTransportStation component types. If the prefab does not include a ServiceUpgrade component but does include a CityServiceBuilding component, it also adds an Efficiency component type. -
public void GetUpgradeComponents(HashSet<ComponentType> components)
Implements IServiceUpgrade. Adds the component types that should be present when this prefab is used as an upgraded version of a building: Game.Buildings.TransportStation and PublicTransportStation. -
public override void Initialize(EntityManager entityManager, Entity entity)
Initializes the created entity's component data from the prefab fields. Reads the current TransportStationData from the entity, ORs the prefab's refuel EnergyTypes into the existing flags, sets the comfort factor, writes the TransportStationData back to the entity, and sets UpdateFrameData to 0.
Usage Example
// Example: configuring a TransportStation prefab (done in editor code or prefab setup)
TransportStation stationPrefab = /* obtain prefab reference */;
stationPrefab.m_CarRefuelTypes = EnergyTypes.Gasoline | EnergyTypes.Electric;
stationPrefab.m_TrainRefuelTypes = EnergyTypes.Diesel;
stationPrefab.m_WatercraftRefuelTypes = EnergyTypes.Diesel;
stationPrefab.m_AircraftRefuelTypes = EnergyTypes.JetFuel;
stationPrefab.m_ComfortFactor = 1.15f;
// When an entity is created from the prefab, Initialize(EntityManager, entity)
// will merge these refuel flags into the entity's TransportStationData and
// set the comfort factor and UpdateFrameData.
Notes: - EnergyTypes is an enum of supported fuel/energy types (flags). The prefab ORs its EnergyTypes into existing component data so multiple sources can contribute supported energies. - This prefab uses ECS ComponentType entries (ReadWrite) to declare needed data components for created entities and archetypes.