RerouteRoutePanelUI

Overview

Panel used when rerouting an existing route using the Route Builder. Compares previous vs. new destination/nodes, shows the node difference, and displays the total cost (positive = pay, negative = refund). Locks the builder while shown. fileciteturn22file2

Flow

  • OpenPanel()
    • Clone RouteBuilderUI.newRouteNodes into routeNodes. If Count >= 2:
      • cost = ReroutingCost() (see below).
      • Compute nodeDifference = previousNodes - (routeNodes.Count-1) and annotate (±N).
      • Build infoText: To (prev), To (now), Nodes (prev), Nodes (now) (±N), blank lines, Total Cost (es-ES). Show panel. fileciteturn22file2
  • ReroutingCost()
    • previous = reroutingRoute.Value.NodesTraversed
    • current = routeNodes.Count - 1
    • If previous > currentrefund = -(routeCostPerNode * (previous-current)) * 0.5f
    • Else → charge = -(routeCostPerNode * (previous-current)) (positive) fileciteturn22file2
  • OnConfirmButtonPressed()
    • Remove old route without refund, add new via origin Lab, apply currentMoney -= cost, clear reroutingRoute, close panel, openRegionCanvas.Raise(false), and set currentRegion to the new destination. fileciteturn22file2

Locking

OnEnable() sets routeBuilderUI.Lock = true; OnDisable() clears it. fileciteturn22file2