Game.UI.InGame.GarbageVehicleSection
Assembly:
Assembly-CSharp (inferred)
Namespace:
Game.UI.InGame
Type:
class
Base:
VehicleSection
Summary:
UI section used by the in-game vehicle panel to present information for garbage trucks. The section determines its visibility by checking that the selected entity has Vehicle and GarbageTruck components and an Owner component, computes the vehicle's UI state key, selects a localization key depending on whether the truck is restricted to industrial waste, and exposes that localization key when the section writes its properties to JSON. The class relies on the ECS-style EntityManager and game-specific types such as GarbageTruck, GarbageTruckFlags, VehicleLocaleKey and VehicleUIUtils.
Fields
- (none declared as plain fields; this class uses auto-properties and overrides)
This class does not declare explicit backing fields in source — it declares a private auto-property for the vehicle key and an overridden computed property for group.
Properties
-
protected override string group { get; }
Provides the UI group name for this vehicle section. Returns the literal "GarbageVehicleSection". Used by the base VehicleSection for grouping and identification in the UI. -
private VehicleLocaleKey vehicleKey { get; set; }
Holds the localized vehicle type key used by the UI and written to JSON. It is set during OnProcess to either VehicleLocaleKey.IndustrialWasteTruck or VehicleLocaleKey.GarbageTruck depending on the truck's flags.
Constructors
public GarbageVehicleSection()
Parameterless constructor. Marked with [Preserve] attribute in source to avoid stripping by code optimization; no custom initialization is performed in the constructor.
Methods
-
private bool Visible()
Determines whether this section should be visible for the currently selected entity. Returns true only if the selected entity has Vehicle and GarbageTruck components and also has an Owner component. Used by OnUpdate to toggle base.visible. -
[Preserve] protected override void OnUpdate()
Override called by the UI update cycle. It updates base.visible by calling Visible(). -
protected override void OnProcess()
Called to populate the section state before rendering. Implementation: - Reads the GarbageTruck component data for the selected entity via EntityManager.
- Sets base.stateKey using VehicleUIUtils.GetStateKey(selectedEntity, componentData, EntityManager).
- Determines vehicleKey based on GarbageTruckFlags.IndustrialWasteOnly (if set, use IndustrialWasteTruck, otherwise GarbageTruck).
- Adds the vehicleKey.ToString() value to base.tooltipKeys.
-
Calls base.OnProcess().
-
public override void OnWriteProperties(IJsonWriter writer)
Writes this section's properties to a JSON writer. Calls base.OnWriteProperties(writer) then writes a "vehicleKey" property using the enum name of vehicleKey.
Notes and dependencies: - Uses an ECS-like EntityManager exposed from the base VehicleSection to query components: Vehicle, GarbageTruck, Owner. - Uses Game.Vehicles.GarbageTruck and Game.Common.GarbageTruckFlags to determine truck behavior. - Uses VehicleLocaleKey enum and VehicleUIUtils.GetStateKey to obtain localization/state keys. - [Preserve] attributes are applied to some members to avoid code stripping.
Usage Example
// The class itself demonstrates typical usage. Key parts shown below:
[Preserve]
protected override void OnUpdate()
{
// Show or hide this UI section based on whether the selected entity is a garbage truck with an owner.
base.visible = Visible();
}
protected override void OnProcess()
{
// Read the garbage truck component for the selected entity.
GarbageTruck componentData = base.EntityManager.GetComponentData<GarbageTruck>(selectedEntity);
// Compute and set the UI state key (provided by a utility in the game code).
base.stateKey = VehicleUIUtils.GetStateKey(selectedEntity, componentData, base.EntityManager);
// Choose the localization key based on whether the truck only handles industrial waste.
vehicleKey = ((componentData.m_State & GarbageTruckFlags.IndustrialWasteOnly) != 0)
? VehicleLocaleKey.IndustrialWasteTruck
: VehicleLocaleKey.GarbageTruck;
// Add the vehicle key to tooltips and continue base processing.
base.tooltipKeys.Add(vehicleKey.ToString());
base.OnProcess();
}
public override void OnWriteProperties(IJsonWriter writer)
{
base.OnWriteProperties(writer);
writer.PropertyName("vehicleKey");
writer.Write(Enum.GetName(typeof(VehicleLocaleKey), vehicleKey));
}