Skip to content

Game.UI.InGame.WaterInfoviewUISystem

Assembly:
(assembly not specified in source — typically found in the game's main mod assembly, e.g. Assembly-CSharp)
Namespace: Game.UI.InGame

Type: class

Base: InfoviewUISystemBase

Summary:
Provides the UI bindings and update logic for the water-related infoview (water capacity, consumption, sewage, and water trade) in the in-game UI. The system queries the game's water statistics and trade systems, creates GetterValueBinding entries for the "waterInfo" UI group, and updates those bindings each frame so the infoview widgets show current values and indicator states (availability/trade).


Fields

  • private const string kGroup = "waterInfo"
    Group name used for all UI bindings created by this system.

  • private WaterStatisticsSystem m_WaterStatisticsSystem
    Reference to the WaterStatisticsSystem used to read water and sewage capacity/consumption values.

  • private GetterValueBinding<int> m_WaterCapacity
    Binding for fresh water capacity (int) exposed to the "waterInfo" UI.

  • private WaterTradeSystem m_WaterTradeSystem
    Reference to the WaterTradeSystem used to read water import/export and sewage export values.

  • private EntityQuery m_OutsideTradeParameterGroup
    EntityQuery used to read OutsideTradeParameterData (prices used to compute trade indicator).

  • private GetterValueBinding<int> m_WaterConsumption
    Binding for fresh water consumption (int) exposed to the "waterInfo" UI.

  • private GetterValueBinding<int> m_SewageCapacity
    Binding for sewage capacity (int) exposed to the "waterInfo" UI.

  • private GetterValueBinding<int> m_SewageConsumption
    Binding for sewage consumption (int) exposed to the "waterInfo" UI.

  • private GetterValueBinding<int> m_WaterExport
    Binding for fresh water export (int) exposed to the "waterInfo" UI.

  • private GetterValueBinding<IndicatorValue> m_WaterAvailability
    Binding for the water availability indicator (IndicatorValue) exposed to the "waterInfo" UI. Value computed by GetWaterAvailability().

  • private GetterValueBinding<int> m_WaterImport
    Binding for fresh water import (int) exposed to the "waterInfo" UI.

  • private GetterValueBinding<IndicatorValue> m_SewageAvailability
    Binding for the sewage availability indicator (IndicatorValue) exposed to the "waterInfo" UI. Value computed by GetSewageAvailability().

  • private GetterValueBinding<int> m_SewageExport
    Binding for sewage export (int) exposed to the "waterInfo" UI.

  • private GetterValueBinding<IndicatorValue> m_WaterTrade
    Binding for the water trade indicator (IndicatorValue) exposed to the "waterInfo" UI. Value computed by GetWaterTrade().

Properties

  • protected override bool Active { get; }
    Determines whether the UI system should be considered active. Returns true if the base Active is true or if any of the created GetterValueBinding instances are active. Concretely, it checks the active flag on all bindings (water capacity/consumption, sewage capacity/consumption, exports/imports, availability and trade indicators) and returns true if any of them are active.

Constructors

  • public WaterInfoviewUISystem()
    Default public constructor. Marked with [Preserve] in source (attribute applied to the OnCreate and constructor in the actual class), but the constructor itself contains no custom initialization — the real setup happens in OnCreate().

Methods

  • protected override void OnCreate()
    Initializes the system: obtains references to WaterStatisticsSystem and WaterTradeSystem via base.World.GetOrCreateSystemManaged<...>(), creates an EntityQuery for OutsideTradeParameterData, and creates and registers GetterValueBinding instances for all UI fields under the "waterInfo" group. Bindings either use simple lambda getters for integer values (e.g. freshCapacity) or method callbacks that return IndicatorValue (for availability and trade indicators). Each binding is added through AddBinding(...).

  • protected override void PerformUpdate()
    Called each update tick to refresh the UI bindings. The method calls Update() on every GetterValueBinding created in OnCreate so the UI receives current values.

  • private IndicatorValue GetWaterTrade()
    Computes an IndicatorValue representing the net water trade position, normalized/clamped to [-1, 1]. If OutsideTradeParameterData is available, it computes:

  • value = freshExport * WaterExportPrice - freshImport * WaterImportPrice
  • normalize by max(0.01f, freshConsumption * WaterExportPrice)
  • clamp result to [-1, 1] and create an IndicatorValue with range [-1,1]. If no OutsideTradeParameterData entity exists, returns an IndicatorValue with value 0.

  • private IndicatorValue GetWaterAvailability()
    Returns IndicatorValue.Calculate(freshCapacity, freshConsumption) using current fresh water capacity and consumption from WaterStatisticsSystem.

  • private IndicatorValue GetSewageAvailability()
    Returns IndicatorValue.Calculate(sewageCapacity, sewageConsumption) using current sewage capacity and consumption from WaterStatisticsSystem.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();

    // The real implementation (in this system) does:
    // m_WaterStatisticsSystem = base.World.GetOrCreateSystemManaged<WaterStatisticsSystem>();
    // m_WaterTradeSystem = base.World.GetOrCreateSystemManaged<WaterTradeSystem>();
    // m_OutsideTradeParameterGroup = GetEntityQuery(ComponentType.ReadOnly<OutsideTradeParameterData>());
    //
    // And it registers GetterValueBinding instances for the "waterInfo" UI group that read from those systems.

    // Example: If you were extending this system, call base.OnCreate() then add your own bindings:
    // AddBinding(new GetterValueBinding<int>("waterInfo", "customValue", () => myValue));
}

Notes: - IndicatorValue is used for UI indicators and is typically normalized between the provided min/max (here [-1,1]) to drive UI visuals (colors, icons, gauges). - GetterValueBinding.Update() pushes the current value to the UI; PerformUpdate ensures bindings are refreshed every frame/tick.