Game.UI.InGame.WaterSection
Assembly:
Namespace: Game.UI.InGame
Type: class
Base: InfoSectionBase
Summary:
UI info section used in the in-game inspector to display Water Pumping Station related information for the currently selected entity. The section checks whether the selected entity has a WaterPumpingStation component and, if present, reads pollution, capacity and lastProduction values. It also inspects prefab upgrade data (WaterPumpingStationData) to decide whether to add a "Pumping" tooltip key, and adds a "Pollution" tooltip key when pollution is significant. Marked with [CompilerGenerated]; some members use [Preserve] to avoid Unity code stripping.
Fields
-
private float pollution { get; set; }
Holds the pollution value read from the WaterPumpingStation component of the selected entity. Reset to 0f in Reset(). -
private int capacity { get; set; }
Holds the capacity value read from the WaterPumpingStation component. Reset to 0 in Reset(). -
private int lastProduction { get; set; }
Holds the last production value read from the WaterPumpingStation component. Reset to 0 in Reset().
Properties
-
protected override string group { get; }
Returns the string "WaterSection". Used by the base InfoSection system to identify the group name for this section. -
private float pollution { get; set; }
(See Fields) Private auto-property storing the current pollution value. -
private int capacity { get; set; }
(See Fields) Private auto-property storing the current capacity value. -
private int lastProduction { get; set; }
(See Fields) Private auto-property storing the lastProduction value.
Constructors
public WaterSection()
[Preserve] Default constructor. No special initialization beyond what the base type provides.
Methods
-
protected override void Reset()
Resets the stored values used by the UI section. Sets pollution to 0f and capacity and lastProduction to 0. Called by the base lifecycle when the section needs to clear state. -
private bool Visible()
Determines whether this section should be shown. Returns true when the currently selected entity has a Game.Buildings.WaterPumpingStation component (checked via base.EntityManager.HasComponent). -
[Preserve] protected override void OnUpdate()
Called during the update phase of the section. Sets base.visible according to Visible(). Marked with [Preserve] to avoid stripping. -
protected override void OnProcess()
Called to populate internal state for the selected entity. If the selected entity has a WaterPumpingStation component, reads: - component.m_Pollution -> pollution
- component.m_Capacity -> capacity
- component.m_LastProduction -> lastProduction
Also attempts to read upgrade data for the selected prefab using TryGetComponentWithUpgrades
public override void OnWriteProperties(IJsonWriter writer)
Writes the current stored values to the provided IJsonWriter:- "pollution" : pollution
- "capacity" : capacity
- "lastProduction" : lastProduction
Useful for serializing the displayed values for UI consumption or remote inspection.
Usage Example
[Preserve]
protected override void OnUpdate()
{
// Ensure section is visible only for water pumping stations
base.visible = Visible();
}
public override void OnWriteProperties(IJsonWriter writer)
{
// Example of how the section writes its values to JSON
writer.PropertyName("pollution");
writer.Write(pollution);
writer.PropertyName("capacity");
writer.Write(capacity);
writer.PropertyName("lastProduction");
writer.Write(lastProduction);
}
Notes and implementation details:
- The class relies on the base InfoSectionBase for fields like selectedEntity, selectedPrefab, base.tooltipKeys, and base.EntityManager.
- TryGetComponentWithUpgrades