Skip to content

Game.UI.InGame.ExtractorVehicleSection

Assembly:
Likely Assembly-CSharp (game runtime). The class is part of the game's UI code for in-game vehicle panels.

Namespace:
Game.UI.InGame

Type:
public class

Base:
VehicleSection

Summary:
ExtractorVehicleSection is a UI section class used by the in-game vehicle UI to display and update information for extractor-type vehicles (e.g., mining, forestry, drilling, fishing, farming, etc.). It determines visibility and the localized vehicle/state keys based on the selected entity's ownership, attachments and the resource output of associated industrial processes. The class serializes the vehicle locale key into JSON when writing properties.


Fields

  • No private instance fields are declared directly in this class.
    The class relies on base class fields/properties (such as selectedEntity, owner, stateKey, EntityManager, visible) and on a private auto-property (vehicleKey) to store state.

Properties

  • protected override string group { get; }
    The section group identifier returned as "ExtractorVehicleSection". Used by the UI system to group and identify the section.

  • private VehicleLocaleKey vehicleKey { get; set; }
    Holds the locale key identifying the type of vehicle (e.g., Extracting, MiningVehicle, FarmingVehicle, etc.). Defaulted in Reset() to VehicleLocaleKey.Vehicle and updated in OnProcess() based on the resource type of the attached renter/prefab.

Constructors

  • public ExtractorVehicleSection()
    Default constructor. Marked with [Preserve] in the source; no custom initialization beyond base constructor is performed here.

Methods

  • protected override void Reset()
    Overrides VehicleSection.Reset(). Resets local state for the UI section: sets vehicleKey to VehicleLocaleKey.Vehicle and sets base.stateKey to VehicleStateLocaleKey.Working. Also calls base.Reset() to allow the base class to reset its state.

  • private bool Visible()
    Helper method that returns true if the currently selected entity has a Game.Vehicles.WorkVehicle component AND also has an Owner component. Used to determine if this UI section should be shown for the selected entity.

  • [Preserve] protected override void OnUpdate()
    Called by the UI update loop. Sets base.visible according to Visible(), i.e., shows/hides this section based on whether the selected entity is an owned work vehicle.

  • protected override void OnProcess()
    Main processing routine that examines ownership/attachment relationships to determine which vehicle locale key and state key to show:

  • If the owner has an Attachment component (or nested owner->attachment) and that attachment buffer contains a renter, the code gets the renter's PrefabRef and examines its IndustrialProcessData.m_Output.m_Resource.
    • Maps resource types to VehicleStateLocaleKey (e.g., Farming, Harvesting, Drilling, Mining, Fishing, Extracting) and to VehicleLocaleKey (e.g., FarmVehicle, ForestryVehicle, DrillingVehicle, MiningVehicle, FishingVehicle, ExtractingVehicle).
    • After mapping, updates base.owner to wrap the attachment buffer for use by the base UI.
  • Else, if the owner entity's owner is a prefab that has ServiceObjectData, it wraps that owner entity for display.
  • Otherwise, sets base.owner to an empty EntityWrapper (Entity.Null). This method uses EntityManager to query components such as Owner, Attachment, PrefabRef, IndustrialProcessData and ServiceObjectData.

  • public override void OnWriteProperties(IJsonWriter writer)
    Serializes this section's properties. Calls base.OnWriteProperties(writer) then writes a "vehicleKey" property containing the name of the current VehicleLocaleKey enum value (Enum.GetName used to get the string representation). Useful for saving UI state or debugging.

Usage Example

[Preserve]
protected override void OnUpdate()
{
    // keep visibility in sync with selected entity being an owned work vehicle
    base.visible = Visible();
}

Notes and Modding Tips: - This section is specifically tailored for extractor-related vehicles. If you add new resource types or new extractor buildings/prefabs, update the mapping in OnProcess() to ensure the correct VehicleLocaleKey and VehicleStateLocaleKey are chosen. - The class depends heavily on ECS component types (Owner, Attachment, Renter, PrefabRef, IndustrialProcessData, ServiceObjectData). When creating or modifying prefabs or components, ensure these components are present and populated as expected for the UI logic to pick up correct vehicle types. - OnWriteProperties writes the vehicleKey enum name; when reading, the consuming code should expect that string form if it deserializes UI state.