Game.UI.InGame.PrivateVehicleSection
Assembly: Assembly-CSharp
Namespace: Game.UI.InGame
Type: class
Base: VehicleSection
Summary:
UI section for displaying information about player-owned (private) vehicles in the in-game UI. This section is shown for household vehicles and taxis, determines whether the section should be visible for the currently selected entity, gathers keeper (owner) information for personal cars, selects an appropriate vehicle locale key (Taxi vs HouseholdVehicle), and serializes these details to JSON for the UI. Relies on ECS components (Vehicle, Owner, PersonalCar, Taxi) and the base VehicleSection functionality.
Fields
-
private Entity keeperEntity
Stores the entity ID of the keeper (owner) of a PersonalCar when applicable. If no keeper is available or relevant, this is set to Entity.Null. Backed by an auto-property in the class. -
private VehicleLocaleKey vehicleKey
Indicates which localized vehicle key should be used for tooltips/labels (VehicleLocaleKey.Taxi or VehicleLocaleKey.HouseholdVehicle). Backed by an auto-property in the class.
Properties
protected override string group => "PrivateVehicleSection"
Group identifier used by the UI framework to group this section. The override returns the literal string "PrivateVehicleSection".
Constructors
public PrivateVehicleSection()
Default constructor. Marked with [Preserve] attribute in source to prevent stripping. No special initialization beyond base construction.
Methods
-
protected override void Reset()
Resets the section to its default state by calling base.Reset() and clearing internal keeperEntity to Entity.Null. Called when the UI section is being reset or recycled. -
private bool Visible()
Determines whether this UI section should be visible for the currently selectedEntity. Returns true when: - selectedEntity has both Vehicle and Owner components, and
-
either has a PersonalCar component or has a Taxi component. Otherwise returns false.
-
[Preserve] protected override void OnUpdate()
Called every update tick by the UI system. Sets base.visible based on the result of Visible() so the section appears/disappears dynamically. -
protected override void OnProcess()
Gathers and prepares per-entity data for display: - Retrieves base.stateKey via VehicleUIUtils.GetStateKey(selectedEntity, base.EntityManager).
- If the vehicle is not parked and the selectedEntity has a PersonalCar component, sets keeperEntity to the PersonalCar.m_Keeper value; otherwise clears it to Entity.Null.
- Chooses vehicleKey = VehicleLocaleKey.Taxi if the entity has a Taxi component, otherwise VehicleLocaleKey.HouseholdVehicle.
- Adds the vehicleKey string to base.tooltipKeys.
-
Calls base.OnProcess() to let the base class do its processing.
-
public override void OnWriteProperties(IJsonWriter writer)
Serializes section-specific properties to JSON for the UI: - Writes "keeper": null when no keeperEntity; otherwise binds the keeperEntity name via m_NameSystem.BindName(writer, keeperEntity).
- Writes "keeperEntity": the keeper entity ID or null.
- Writes "vehicleKey": the enum name of vehicleKey (e.g., "Taxi" or "HouseholdVehicle"). Also calls base.OnWriteProperties(writer) first to include base properties.
Usage Example
[Preserve]
protected override void OnUpdate()
{
// Keep the section visible only when the selected entity is a household vehicle or taxi
base.visible = Visible();
}
// Example: overriding OnProcess to inspect collected data (this is similar to the class implementation)
protected override void OnProcess()
{
base.stateKey = VehicleUIUtils.GetStateKey(selectedEntity, base.EntityManager);
keeperEntity = Entity.Null;
if (base.stateKey != VehicleStateLocaleKey.Parked)
{
if (base.EntityManager.TryGetComponent<PersonalCar>(selectedEntity, out var personalCar))
{
keeperEntity = personalCar.m_Keeper;
}
}
vehicleKey = (base.EntityManager.HasComponent<Taxi>(selectedEntity)
? VehicleLocaleKey.Taxi
: VehicleLocaleKey.HouseholdVehicle);
base.tooltipKeys.Add(vehicleKey.ToString());
base.OnProcess();
}
{{ Additional notes: - This class depends on ECS components and utility types: Unity.Entities.Entity, Vehicle, Owner, PersonalCar, Taxi, VehicleUIUtils, VehicleStateLocaleKey, VehicleLocaleKey, IJsonWriter, and a name binding system available as m_NameSystem in the base class. - The class uses [Preserve] on the constructor and OnUpdate to avoid stripping by build tooling. - selectedEntity, base.EntityManager, base.visible, base.tooltipKeys, base.stateKey, and m_NameSystem are provided by the VehicleSection base class. }}