AddRoutePanelUI

Overview

Confirmation panel shown after selecting an origin and destination in the route builder. Computes and displays a cost breakdown (base, per-node, multiplier, total) using es-ES number formatting. On confirm it creates the route, deducts money, bumps the global route count, and opens the region canvas. Supports reroute flow via a companion panel. fileciteturn18file3

Serialized Atoms & UI

  • RegionVariable currentRegion
  • IntVariable totalRoutesCount
  • FloatVariable currentMoney, routeBaseCost, routeCostPerNode, routeCostMultiplier
  • RouteVariable reroutingRoute
  • BoolEvent openRegionCanvas
  • VoidEvent openRegionInfoPanel, closeRegionInfoPanel
  • TextMeshProUGUI infoText
  • RouteBuilderUI routeBuilderUI
  • RerouteRoutePanelUI rerouteUI (used when rerouting). fileciteturn18file3

Flow

  • OpenPanel()
    • Clones RouteBuilderUI.newRouteNodes.
    • If there are 2+ nodes:
      • origin = first.Region, dest = last.Region.
      • If not rerouting:
        • cost = (routeBaseCost + routeCostPerNode*(nodes-1)) * routeCostMultiplier
        • Build multi-line infoText with From/To, base cost, nodes-1 × per-node, multiplier xM, and Total; all formatted with es-ES and a $ suffix.
        • gameObject.SetActive(true)
      • Else open rerouteUI and hide this panel.
      • Set currentRegion = dest and openRegionInfoPanel.Raise().
  • OnConfirmButtonPressed()
    • origin.AddRoute(routeNodes) → new Route
    • currentMoney -= cost
    • totalRoutesCount++
    • Hide and openRegionCanvas.Raise(true)
  • OnDenyButtonPressed() — hide and closeRegionInfoPanel.Raise()
  • OnEnable/OnDisable — set routeBuilderUI.Lock to block UI while the panel is shown. fileciteturn18file3