Game.UI.InGame.SewageSection
Assembly:
Assembly-CSharp
Namespace:
Game.UI.InGame
Type:
Class
Base:
InfoSectionBase
Summary:
SewageSection is an in-game UI info section for sewage outlets and treatment buildings. It gathers runtime data from the entity system (capacity, last processed/purified amounts and purification rate), determines whether the selected building is an outlet or a treatment facility, and populates tooltip keys accordingly. It also exposes those values for JSON serialization via OnWriteProperties. The class relies on ECS component types such as Game.Buildings.SewageOutlet, optional SewageOutletData (upgrades/prefab data), and checks sub-objects for WaterSourceData to classify an outlet vs treatment.
Fields
-
private float capacity
Private storage for the outlet/treatment capacity. Implemented as a private auto-property in the source; reset to 0 by Reset() and populated from the SewageOutlet component in OnProcess(). -
private float lastProcessed
Private storage for the last processed amount read from the SewageOutlet component. -
private float lastPurified
Private storage for the last purified amount read from the SewageOutlet component. -
private float purification
Private storage for the purification rate or amount (from SewageOutletData upgrades/prefab when available).
Properties
-
protected override string group { get }
Returns the UI group key for this section. In the implementation it returns the literal "SewageSection". -
private float capacity { get; set; }
Auto-property backing the capacity value. Set by OnProcess(). -
private float lastProcessed { get; set; }
Auto-property backing the last processed value. Set by OnProcess(). -
private float lastPurified { get; set; }
Auto-property backing the last purified value. Set by OnProcess(). -
private float purification { get; set; }
Auto-property backing the purification value. Attempted to be filled from SewageOutletData when upgrades/prefab data is available.
Constructors
public SewageSection()
Parameterless constructor. Marked with [Preserve] in source to avoid stripping; no custom initialization beyond base constructor — state is initialized/reset by Reset().
Methods
-
protected override void Reset()
Resets all tracked numeric values (capacity, lastProcessed, lastPurified, purification) to 0. Called to reinitialize the section state. -
private bool Visible()
Returns true when the currently selected entity has the Game.Buildings.SewageOutlet component. Used to determine visibility of this info section. -
[Preserve] protected override void OnUpdate()
Updates the section's visible flag each frame by calling Visible() and assigning it to base.visible. Simple per-frame visibility refresh. -
protected override void OnProcess()
Core data-collection routine. Steps: - Reads Game.Buildings.SewageOutlet component data for the selected entity and stores capacity, lastProcessed and lastPurified.
- Attempts to get SewageOutletData (via TryGetComponentWithUpgrades) to fill the purification value.
- Adds tooltip keys based on whether the outlet has an associated water source (HasWaterSource()). Adds "Outlet" when water source exists, otherwise "Treatment".
-
If purification > 0, adds either "TreatmentPurification" (if the entity has a WaterPumpingStation component) or "OutletPurification".
-
private bool HasWaterSource()
Inspects the selected entity's sub-objects buffer (DynamicBuffer) and checks each sub-object entity for the Game.Simulation.WaterSourceData component. Returns true if any sub-object is a water source. Used to distinguish sewage outlet vs treatment facility. -
public override void OnWriteProperties(IJsonWriter writer)
Serializes current numeric properties to the provided JSON writer with property names: - "capacity"
- "lastProcessed"
- "lastPurified"
- "purification"
This enables the UI system or debugging/serialization tools to export the section state.
Usage Example
[Preserve]
protected override void OnUpdate()
{
// keep visibility in sync with whether the selected entity is a sewage outlet/treatment
base.visible = Visible();
}
protected override void OnProcess()
{
// typical call pattern (simplified): read component data and update tooltip keys
var outlet = base.EntityManager.GetComponentData<Game.Buildings.SewageOutlet>(selectedEntity);
capacity = outlet.m_Capacity;
lastProcessed = outlet.m_LastProcessed;
lastPurified = outlet.m_LastPurified;
if (TryGetComponentWithUpgrades<SewageOutletData>(selectedEntity, selectedPrefab, out var data))
{
purification = data.m_Purification;
}
base.tooltipKeys.Add(HasWaterSource() ? "Outlet" : "Treatment");
if (purification > 0f)
base.tooltipKeys.Add(base.EntityManager.HasComponent<Game.Buildings.WaterPumpingStation>(selectedEntity)
? "TreatmentPurification"
: "OutletPurification");
}
Notes: - The class is marked with [CompilerGenerated] in the original source; methods also use [Preserve] where necessary to prevent stripping. - It interacts with the ECS EntityManager and DynamicBuffer APIs to read components and sub-objects. Ensure the selectedEntity and selectedPrefab context provided by the InfoSectionBase is valid when these methods run.