Skip to content

Game.UI.Tooltip.RaycastWaterTooltipSystem

Assembly:
Namespace: Game.UI.Tooltip

Type: class

Base: TooltipSystemBase

Summary:
RaycastWaterTooltipSystem is an ECS system that provides mouse-over tooltips for water and sewage flows when the player hovers network lanes, nodes, or related buildings while the Net Status (PipeWaterFlow / PipeSewageFlow) infomode is active. It listens to the tool raycast results (DefaultTool + ToolRaycastSystem) and reads low-level ECS components (water pipe graph, edges, connected buildings, consumers, pumps, sewage outlets) to compute and add Int/Progress tooltips describing capacity, usage and actual flow at the hovered location. The system caches various tooltip templates and depends on several other systems (ToolSystem, DefaultToolSystem, ToolRaycastSystem, WaterPipeFlowSystem).


Fields

  • private ToolSystem m_ToolSystem
    Used to check active tools and interact with the tool layer. Obtained from the world in OnCreate.

  • private DefaultToolSystem m_DefaultTool
    Reference to the DefaultTool system used to verify the current active tool is the default tool.

  • private ToolRaycastSystem m_ToolRaycastSystem
    Used to get the current raycast result (what the mouse is over) so tooltips can be shown for that entity.

  • private WaterPipeFlowSystem m_WaterPipeFlowSystem
    Used to access sink node and flow data for water/sewage graph queries.

  • private EntityQuery m_InfomodeQuery
    Query used to detect whether the PipeWaterFlow or PipeSewageFlow infomode is active. Required for system update.

  • private IntTooltip m_WaterCapacity
    Template for an integer tooltip that shows water output/capacity (volume unit).

  • private IntTooltip m_WaterUsage
    Template for an integer tooltip that shows water pump usage as a percentage.

  • private IntTooltip m_SewageCapacity
    Template for an integer tooltip that shows sewage processing capacity (volume unit).

  • private IntTooltip m_SewageUsage
    Template for an integer tooltip that shows sewage outlet usage as a percentage.

  • private ProgressTooltip m_WaterConsumption
    Template for a progress tooltip showing water consumption fulfillment (volume). Color and max handling set by the system.

  • private ProgressTooltip m_SewageConsumption
    Template for a progress tooltip showing sewage consumption fulfillment (volume).

  • private IntTooltip m_WaterFlow
    Template for an integer tooltip that shows computed water flow (volume).

  • private IntTooltip m_SewageFlow
    Template for an integer tooltip that shows computed sewage flow (volume).

  • private TypeHandle __TypeHandle
    Internal struct instance that stores ComponentLookup/BufferLookup handles required for read-only access to several ECS components (WaterPipeNodeConnection, ConnectedFlowEdge buffer, WaterPipeEdge, WaterConsumer, Building, WaterPipeBuildingConnection). Populated via __AssignHandles and used by methods that use InternalCompilerInterface to obtain lookups.

Properties

  • None (this system exposes no public properties)

Constructors

  • public RaycastWaterTooltipSystem()
    Default constructor. Marked with [Preserve] attribute in the source. Actual initialization and system dependencies are set up in OnCreate.

Methods

  • protected override void OnCreate()
    Initial setup executed when the system is created. Acquires or creates the dependent systems (ToolSystem, DefaultToolSystem, ToolRaycastSystem, WaterPipeFlowSystem), builds the EntityQuery used to detect the infomode (InfomodeActive + InfoviewNetStatusData) and calls RequireForUpdate(m_InfomodeQuery). Initializes tooltip templates (m_WaterCapacity, m_WaterUsage, m_SewageCapacity, m_SewageUsage, m_WaterConsumption, m_SewageConsumption, m_WaterFlow, m_SewageFlow) including label ids, units, colors and omitMax flags.

  • protected override void OnUpdate()
    Main runtime logic executed each frame when the infomode query allows updates. Sequence:

  • Completes outstanding dependencies.
  • Checks that infomode is active, the active tool is DefaultTool, and a valid raycast result exists (and the target owner is not destroyed).
  • If the raycast target is a utility lane with water/sewage utilities, the method inspects the lane's EdgeMapping to determine whether the raycast hit corresponds to an edge segment or node and calls AddEdgeFlow or AddNodeFlow accordingly (handles curve positions and secondary lanes).
  • Adds tooltips for SewageOutlet (capacity + usage) and WaterPumpingStation (capacity + usage) if the raycast hits those building types.
  • Adds progress tooltips for WaterConsumer (fulfilledFresh vs wanted consumption, and fulfilledSewage if necessary), with color indicating under-supply (Warning) or full (Info).

  • private void AddEdgeFlow(Entity edge, float curvePosition)
    Computes and adds flow tooltips for a specific edge at the given curve position. Steps:

  • Obtains ComponentLookup/BufferLookup instances via InternalCompilerInterface and __TypeHandle.
  • Verifies edge and node connections, resolves flow edge via WaterPipeGraphUtils.
  • Aggregates flow from connected nodes that lie before the curve position.
  • Considers flows toward the sink node and accounts for consumption by connected buildings (consuming flow according to wanted consumption and whether a building is connected via a water-pipe-building connection).
  • Computes final water and sewage flow values (per-component int2) and adds m_WaterFlow and/or m_SewageFlow tooltips if capacity > 0. Values are absolute flow magnitudes.

  • private void AddNodeFlow(Entity node, Entity edge)
    Computes and displays the maximum flow/capacity crossing a node relative to a particular adjacent edge. It:

  • Ensures both node and edge have WaterPipeNodeConnection components and reads the list of connected flow edges.
  • Iterates connected flow edges and finds the ones matching the provided adjacent edge node, taking the max absolute flow and capacity across matches.
  • Shows m_WaterFlow and/or m_SewageFlow tooltips when capacities are positive.

  • private bool IsInfomodeActivated()
    Checks m_InfomodeQuery for InfoviewNetStatusData values to determine whether either NetStatusType.PipeWaterFlow or NetStatusType.PipeSewageFlow is currently active. Uses a temporary NativeArray to iterate the query results and disposes it afterwards.

  • private void __AssignQueries(ref SystemState state)
    Compiler helper called in OnCreateForCompiler. In the current implementation it creates and disposes an EntityQueryBuilder and otherwise is a no-op.

  • protected override void OnCreateForCompiler()
    Called by the generated/compiled code path to allow assignment of queries and to populate __TypeHandle lookups via __AssignHandles. Ensures the TypeHandle has its Component/Buffer lookups assigned against the CheckedStateRef.

  • TypeHandle.__AssignHandles(ref SystemState state)
    Assigns the ComponentLookup and BufferLookup handles for all used components/buffers (WaterPipeNodeConnection, ConnectedFlowEdge, WaterPipeEdge, WaterConsumer, Building, WaterPipeBuildingConnection) as ReadOnly lookups using state.GetComponentLookup / state.GetBufferLookup. This is used so the system methods can obtain those lookups via InternalCompilerInterface at runtime.

Usage Example

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

    // Typical initialization: get dependent systems and initialize a tooltip template.
    m_ToolSystem = base.World.GetOrCreateSystemManaged<ToolSystem>();
    m_DefaultTool = base.World.GetOrCreateSystemManaged<DefaultToolSystem>();
    m_ToolRaycastSystem = base.World.GetOrCreateSystemManaged<ToolRaycastSystem>();

    m_WaterFlow = new IntTooltip {
        path = "waterFlow",
        label = LocalizedString.Id("Tools.WATER_FLOW_LABEL"),
        unit = "volume"
    };
}

Notes / Implementation tips: - The system expects to run only when the PipeWaterFlow or PipeSewageFlow infoview is active — disabling or enabling that infomode affects whether the system updates at all. - The system uses low-level ECS patterns (ComponentLookup, BufferLookup, DynamicBuffer access and manual flow aggregation). When modifying, be careful to preserve read-only lookup usage and to call CompleteDependency() where appropriate. - The computations use int2 (x: water, y: sewage) and FlowUtils helper functions for consumption logic; inspect those helpers when changing consumption/flow math.