Skip to content

Game.UI.InGame.PassengersSection

Assembly:
Assembly-CSharp.dll

Namespace:
Game.UI.InGame

Type:
public class (CompilerGenerated)

Base:
InfoSectionBase

Summary:
PassengersSection is a UI info section used by the in-game inspector to show passenger-related information for a selected vehicle or vehicle prefab (including composed public-transport vehicles). It reads ECS components (Vehicle, Passenger, PrefabRef, passengers buffers, etc.) from the EntityManager to compute current passenger count, pet count, and maximum passenger capacity. It also accounts for dummy traffic (generating pseudo-random passengers/pets for display) and adjusts localization key for special vehicle types (e.g., prisoner transport). This class is intended for use inside the game's UI system and can be referenced or extended by mods that need to display or export passenger information.


Fields

  • (none)
    This class does not declare explicit backing fields; it uses auto-properties and overrides from InfoSectionBase to hold runtime state. Internal backing fields for auto-properties are compiler-generated.

Properties

  • protected override string group => "PassengersSection"
    Identifies the UI group name used by the base InfoSection system. This expression-bodied override returns a constant identifying this section.

  • private int passengers { get; set; }
    Current counted number of passenger creatures (excluding pets) on the selected vehicle(s). Updated during OnProcess.

  • private int maxPassengers { get; set; }
    Total passenger capacity for the selected vehicle(s)/prefab(s). Computed by scanning vehicle prefab components (PersonalCarData, TaxiData, PoliceCarData, PublicTransportVehicleData).

  • private int pets { get; set; }
    Count of pet-type passengers (Game.Creatures.Pet) found on the selected vehicle(s).

  • private VehiclePassengerLocaleKey vehiclePassengerKey { get; set; }
    Localization key used when presenting the passenger type (e.g., Passenger, Prisoner). Determined in OnProcess for special transport types such as prisoner transport.

  • protected override Entity selectedEntity { get; }
    Override that resolves the effective selected Entity. If the base selectedEntity has a Controller component, the section will use the controller's m_Controller Entity instead (so passenger info reflects the actual vehicle entity).

  • protected override Entity selectedPrefab { get; }
    Override that resolves the effective selected prefab Entity. If the selectedEntity has a Controller that references a PrefabRef, the section returns that referenced prefab; otherwise it falls back to the base selectedPrefab.

Constructors

  • public PassengersSection()
    Default constructor. Marked with [Preserve] so it is retained in builds. No custom initialization is performed beyond what the base InfoSectionBase initializes.

Methods

  • protected override void Reset()
    Resets internal counters (passengers, maxPassengers, pets) to zero. Called by the base lifecycle when the section is being reset/prepared for reuse.

  • private bool Visible()
    Determines whether the section should be visible for the current selection. Returns false if the selected entity is not a vehicle, does not have passengers, or is involved in an accident. For different vehicle types it inspects the associated prefab/component passenger capacities (personal cars, taxis, police cars, public transport vehicles and composed vehicles via layout buffers) to decide whether the section is relevant (i.e., has capacity > 0).

  • [Preserve] protected override void OnUpdate()
    Sets base.visible according to Visible(). Called each update tick by the UI system to show/hide the section.

  • protected override void OnProcess()
    Main processing method that:

  • Scans either the selectedEntity buffer of LayoutElement (for transport compositions) or the selectedEntity passenger buffer to count actual passengers and pets.
  • Accumulates maxPassengers by calling AddPassengerCapacity on prefab(s).
  • Adjusts behavior for personal cars and public transport, setting flags like dummy traffic and a minimum passenger value for cars.
  • If the vehicle is marked as dummy traffic (PseudoRandomSeed present), it uses the seed to generate a pseudo-random passenger and pet count within reasonable bounds to display for traffic replicas.
  • Ensures passenger counts do not go negative. This is where the section derives the passenger/pet counts and the vehiclePassengerKey.

  • private void AddPassengerCapacity(Entity prefab)
    Helper that inspects a prefab Entity for known vehicle data components (PersonalCarData, TaxiData, PoliceCarData, PublicTransportVehicleData) and increments maxPassengers by the appropriate capacity field (m_PassengerCapacity or m_CriminalCapacity for police vehicles).

  • public override void OnWriteProperties(IJsonWriter writer)
    Writes the computed passenger properties to a JSON writer. The written properties are:

  • "passengers": current passenger count
  • "maxPassengers": computed passenger capacity
  • "pets": current pet count
  • "vehiclePassengerKey": the enum name of vehiclePassengerKey This method can be used by the UI/serialization system or mods to export the current passenger state.

Usage Example

// Example: how the section exports its computed values to JSON (similar to how the game uses it).
var section = new PassengersSection();
// ... the game's UI lifecycle calls Reset(), OnUpdate(), OnProcess(), etc.
// When ready to serialize:
IJsonWriter writer = GetJsonWriterSomehow();
section.OnWriteProperties(writer);
// Resulting JSON contains fields: passengers, maxPassengers, pets, vehiclePassengerKey

Notes for modders: - The section relies on ECS components and buffers (Vehicle, Passenger, PrefabRef, LayoutElement, PersonalCarData, PublicTransportVehicleData, TaxiData, PoliceCarData, PseudoRandomSeed). To mimic or extend its behavior, ensure your code queries the same ECS data or subscribes during the appropriate UI lifecycle events. - Dummy traffic uses PseudoRandomSeed with PseudoRandomSeed.kDummyPassengers — the randomization is deterministic per vehicle seed and is intended purely for display of non-player traffic. - When composing public transport from multiple vehicle entities (layout buffer), the class sums capacities across the composition.