Game.UI.InGame.FireVehicleSection
Assembly:
Assembly-CSharp (game/mod user assembly)
Namespace:
Game.UI.InGame
Type:
class
Base:
VehicleSection
Summary:
UI section for vehicle details specifically for fire vehicles (fire engines and fire helicopters). Controls visibility for the section when the selected entity is a fire vehicle with an Owner component, determines the localized vehicle key (engine vs. helicopter), computes the vehicle state key via VehicleUIUtils, inspects the service dispatch buffer to determine the next stop when the vehicle is dispatched (resolving OnFire / Destroyed / direct target entities), and serializes the vehicleKey to JSON when requested. The class is marked CompilerGenerated and uses Preserve on some members to avoid stripping.
Fields
private VehicleLocaleKey vehicleKey { get; set; }
Holds which localized vehicle key is used for UI labels (VehicleLocaleKey.FireEngine or VehicleLocaleKey.FireHelicopter). It is a private auto-property used by OnProcess and OnWriteProperties to pick and serialize the proper label key.
Properties
-
protected override string group => "FireVehicleSection"
Property override that identifies the UI group name for this section. Used by the UI system to group sections. -
private VehicleLocaleKey vehicleKey { get; set; }
(Repeated here as a private auto-property; logically a backing field/property pair) Stores the selected VehicleLocaleKey for the current selected entity — chosen in OnProcess based on whether the selected prefab has a HelicopterData component.
Constructors
public FireVehicleSection()
Default constructor. Marked with Preserve attribute in source. No custom initialization logic in the constructor.
Methods
-
private bool Visible()
Determines whether this section should be visible for the current selectedEntity. Returns true only if the selected entity has both the Vehicle and Game.Vehicles.FireEngine components and also has an Owner component. Used by OnUpdate to set base.visible. -
[Preserve] protected override void OnUpdate()
Called each UI update tick. This override sets base.visible by calling Visible() to show/hide the section based on the currently selected entity. -
protected override void OnProcess()
Main processing method that: - Reads the FireEngine component data for the selected entity.
- Reads the ServiceDispatch dynamic buffer (if present, read-only).
- Sets vehicleKey to FireHelicopter if the selectedPrefab has HelicopterData; otherwise FireEngine.
- Computes base.stateKey via VehicleUIUtils.GetStateKey using the entity, component data and buffer.
- If the stateKey indicates VehicleStateLocaleKey.Dispatched, inspects the service dispatch buffer (first entry) to resolve the dispatch request (FireRescueRequest) and attempts to determine the next stop:
- If the request target has an OnFire component with a non-null event, nextStop is set to that event entity.
- Else if the target has a Destroyed component with a non-null event, nextStop is set to that event entity.
- Else if the request target is a non-null entity, nextStop is set to that target entity.
-
Adds the vehicleKey string to base.tooltipKeys and calls base.OnProcess() for further shared processing.
-
public override void OnWriteProperties(IJsonWriter writer)
Serializes UI-related properties to JSON. Writes the vehicleKey property name and its enum name (via Enum.GetName) to the provided writer, after calling base.OnWriteProperties(writer). Useful for debugging or UI state persistence.
Usage Example
// This shows the same update behavior as implemented in the class:
// ensure visibility only when the selected entity is a fire vehicle with an owner.
[Preserve]
protected override void OnUpdate()
{
base.visible = Visible();
}
// The section's OnProcess handles selecting the proper vehicle key
// and resolving a dispatched vehicle's next stop, then adds the key to tooltips.
// When serializing this section to JSON the vehicleKey is written:
public override void OnWriteProperties(IJsonWriter writer)
{
base.OnWriteProperties(writer);
writer.PropertyName("vehicleKey");
writer.Write(Enum.GetName(typeof(VehicleLocaleKey), vehicleKey));
}