Game.UI.InGame.FireSection
Assembly: Assembly-CSharp (inferred)
Namespace: Game.UI.InGame
Type: class
Base: InfoSectionBase
Summary:
UI info section for Fire Stations. Detects whether the currently selected entity is a Fire Station and exposes runtime values used by the UI: the effective vehicle efficiency (percent) and whether the building can respond to disasters. It reads building data and efficiency buffer information from the ECS world and writes those values into a JSON writer for UI consumption.
Fields
- This class declares no explicit private or public fields.
(It uses auto-properties and functionality inherited from InfoSectionBase and the ECS EntityManager.)
Properties
-
protected override string group => "FireSection"
The UI group identifier for the section. Used by the base UI system to categorize this info section. -
private float vehicleEfficiency { get; set; }
Stores the computed vehicle efficiency for the selected fire station. It's computed in OnProcess and expressed as a percentage (data.m_VehicleEfficiency adjusted by building efficiency and scaled to 0–100). -
private bool disasterResponder { get; set; }
True when the selected fire station has disaster response capacity (data.m_DisasterResponseCapacity > 0). Set in OnProcess.
Constructors
public FireSection()
Default constructor. Marked with [Preserve] attribute in the source to avoid stripping during build/IL2CPP optimization. No special initialization logic in the constructor; state is reset in Reset().
Methods
-
protected override void Reset()
Resets internal state for reuse: sets vehicleEfficiency to 0 and disasterResponder to false. Called by the base lifecycle when the section is being reset. -
private bool Visible()
Returns true if the currently selected entity has a Game.Buildings.FireStation component in the ECS world: - Uses base.EntityManager.HasComponent
(selectedEntity) -
Controls whether this info section should be visible for the current selection.
-
[Preserve] protected override void OnUpdate()
Updates the section's visibility each frame by setting base.visible = Visible(). Marked [Preserve] to avoid stripping. -
protected override void OnProcess()
Gathers data when the section is processed: - Calls TryGetComponentWithUpgrades
(selectedEntity, selectedPrefab, out var data) to retrieve building-specific data (including upgrades). - Reads DynamicBuffer
buffer from the entity (read-only). - Sets disasterResponder = data.m_DisasterResponseCapacity > 0.
-
Computes the vehicle efficiency:
- float efficiency = BuildingUtils.GetEfficiency(buffer);
- vehicleEfficiency = data.m_VehicleEfficiency * (0.5f + efficiency * 0.5f) * 100f; This produces a percentage value where base vehicle efficiency is modulated by building efficiency.
-
public override void OnWriteProperties(IJsonWriter writer)
Writes the computed properties into a JSON writer for the UI: - Writes "vehicleEfficiency" followed by the vehicleEfficiency float.
- Writes "disasterResponder" followed by the disasterResponder bool. This is how the UI layer reads the values to present to the player.
Usage Example
// The FireSection is driven by the base info-section lifecycle.
// Example showing the expected behaviour during processing:
[Preserve]
protected override void OnProcess()
{
// base class provides selectedEntity and selectedPrefab + EntityManager
if (TryGetComponentWithUpgrades<FireStationData>(selectedEntity, selectedPrefab, out var data)
&& base.EntityManager.TryGetBuffer(selectedEntity, isReadOnly: true, out DynamicBuffer<Efficiency> buffer))
{
// set whether this station can respond to disasters
disasterResponder = data.m_DisasterResponseCapacity > 0;
// compute effective vehicle efficiency as a percent
float efficiency = BuildingUtils.GetEfficiency(buffer);
vehicleEfficiency = data.m_VehicleEfficiency * (0.5f + efficiency * 0.5f) * 100f;
}
}
// Later the UI reads the values via OnWriteProperties:
public override void OnWriteProperties(IJsonWriter writer)
{
writer.PropertyName("vehicleEfficiency");
writer.Write(vehicleEfficiency);
writer.PropertyName("disasterResponder");
writer.Write(disasterResponder);
}