AddLabPanelUI

Overview

Confirmation panel for building a new Laboratory in the current region. Shows the region name, base lab cost, current lab count and next count, a multiplicative cost breakdown, and the final Total Cost — all formatted with the Spanish locale. Pauses gameplay while open and disables time controls.

Serialized Atoms

  • RegionVariable currentRegion
  • FloatVariable currentMoney
  • FloatVariable labCost — dynamic, scales with lab count.
  • FloatVariable buildingCostMult — global multiplier.
  • IntVariable labCount, IntVariable totalLabCount
  • BoolVariable paused
  • VoidEvent enableTimeControls, disableTimeControls, forcePlay

UI

  • TextMeshProUGUI infoText

Behavior

  • OnEnable()
    • Sets paused = true, raises disableTimeControls.
    • Composes infoText with:
      • Region name
      • Base Cost (labCost.InitialValue)
      • Lab Count (labCount → shows "(+1)")
      • Build Cost ((labCount+1) × labCost.InitialValue)
      • Cost Multiplier (buildingCostMult)
      • Total Cost (labCost.Value * buildingCostMult.Value)
  • OnConfirmButtonPressed()
    • If building the first lab (labCount <= 0) → raises forcePlay to resume time immediately after.
    • Else unpauses and re-enables time controls.
    • Calls ClearIncomingRoutes() to remove any routes whose destination equals the current region.
    • Deducts money: currentMoney -= labCost * buildingCostMult.
    • Increments labCount and totalLabCount.
    • Recomputes next labCost as InitialValue * (labCount + 1).
    • Calls currentRegion.Value.AddLaboratory() and hides the panel.
  • OnDenyButtonPressed() unpauses, re-enables controls, and hides.

Helper: ClearIncomingRoutes()

Iterates all labs, finds routes with route.Destination == currentRegion, removes them (without refund), and exits early once a match is removed per lab.

Notes

  • All currency is formatted using "es-ES" culture and appended with a $ sign.