Transporter vessels, an explicit store button, and bottom-anchored menus

Forgejo #19, part 6 of #12. Transporters are built at the ship crafter,
fly themselves to the nearest hub and wait there. When a building is
short of what its queue needs, the nearest idle transporter runs
hub -> mothership -> building -> hub. Ore leaves the bank when it is
loaded and lands in the building's stock on arrival, so what is drawn
and what happens are the same event - the extractor hauler's rule.

Production orders are now TYPED (interceptor / transporter) rather than
a bare count, since the crafter builds two different things. One at a
time is dispatched per building: without that, every idle transporter
chases the same shortfall and they all arrive carrying ore nobody needs.

Three fixes from play-testing feedback:

- Storing ore into a building is now a deliberate button press, not a
  side effect of opening the menu.
- The mothership's load-ore controls were positioned from the TOP of the
  screen, so on any viewport shorter than ~1300px the label fell off the
  bottom. They are anchored to the bottom edge now, and the label had no
  explicit font size so it inherited the theme's 78px and wrapped off
  screen. Checked at 720x960 and 720x1280.
- The craft button looked live and did nothing. It was not the transport
  work: BASE_FLEET_SIZE is 5 and a new game starts with exactly 5 ships,
  so the fleet is at its cap from the first frame and every interceptor
  order was refused. The button is now visibly disabled and says why.
  The underlying balance (crafter useless until Wing Doctrine) is left
  alone - that is a design call, not a bug to quietly change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-11 19:14:27 +02:00
commit d41128bc43
22 changed files with 753 additions and 54 deletions

View file

@ -38,6 +38,9 @@ extends Node2D
@onready var craft_menu: Control = get_node("../UI/CraftMenu")
@onready var craft_interceptor_button: IconButton = get_node("../UI/CraftMenu/InterceptorButton")
@onready var craft_transporter_button: IconButton = get_node("../UI/CraftMenu/TransporterButton")
@onready var craft_store_button: IconButton = get_node("../UI/CraftMenu/StoreOreButton")
@onready var craft_store_label: Label = get_node("../UI/CraftMenu/StoreOreLabel")
@onready var craft_close_button: IconButton = get_node("../UI/CraftMenu/CloseButton")
@onready var craft_status: Label = get_node("../UI/CraftMenu/StatusLabel")
@onready var load_ore_button: IconButton = get_node("../UI/SkillMenu/LoadOreButton")
@ -113,6 +116,8 @@ func _ready() -> void:
craft_interceptor_button.pressed.connect(_on_craft_interceptor)
load_ore_button.pressed.connect(_on_load_ore)
craft_transporter_button.pressed.connect(_on_craft_transporter)
craft_store_button.pressed.connect(_on_store_ore)
craft_close_button.pressed.connect(func(): craft_menu.visible = false)
formation_close_button.pressed.connect(func(): formation_menu.visible = false)
@ -452,10 +457,34 @@ func _refresh_craft_status() -> void:
var queued: int = GameState.pending_orders(craft_building_id)
var stock: int = GameState.building_stock(craft_building_id)
var queue_text: String = "" if queued == 0 else " Queued %d" % queued
craft_status.text = "Interceptor %d ore Here %d%s Fleet %d/%d" % [
GameState.SHIP_COST, stock, queue_text,
fleet.ships.size(), GameState.max_fleet_size()
craft_status.text = "Interceptor %d Transporter %d Here %d%s" % [
GameState.SHIP_COST, GameState.TRANSPORTER_COST, stock, queue_text
]
# Nowhere to station one means the order would be refused, so say so
# rather than letting the button look available and do nothing.
craft_transporter_button.enabled = GameState.has_transport_hub()
craft_transporter_button.queue_redraw()
craft_store_label.text = "Store ore here\nHold %d" % GameState.fleet_cargo
craft_store_button.enabled = GameState.fleet_cargo > 0
craft_store_button.queue_redraw()
# A full fleet cannot take another vessel, so the order would be refused.
# Showing that on the button is the difference between "not available yet"
# and a button that looks live and silently does nothing when pressed.
var room: bool = fleet.ships.size() + GameState.ships_owed \
+ GameState.pending_orders_of(craft_building_id, GameState.PRODUCT_SHIP) \
< GameState.max_fleet_size()
craft_interceptor_button.enabled = room
craft_interceptor_button.queue_redraw()
# One statement of the fleet count, either way round: the capacity line
# replaces the plain readout rather than being bolted in front of it.
if room:
craft_status.text += " Fleet %d/%d" % [fleet.ships.size(), GameState.max_fleet_size()]
else:
craft_status.text = "Fleet full %d/%d - research capacity at the mothership\n%s" % [
fleet.ships.size(), GameState.max_fleet_size(), craft_status.text
]
func _on_craft_interceptor() -> void:
@ -463,7 +492,8 @@ func _on_craft_interceptor() -> void:
return
# Still refused when there is nowhere to put the vessel - queueing an
# order that can never be delivered would just bank ships_owed forever.
if fleet.ships.size() + GameState.ships_owed + GameState.pending_orders(craft_building_id) \
if fleet.ships.size() + GameState.ships_owed \
+ GameState.pending_orders_of(craft_building_id, GameState.PRODUCT_SHIP) \
>= GameState.max_fleet_size():
craft_status.text = "Fleet is full (%d slots)" % GameState.max_fleet_size()
return
@ -474,7 +504,7 @@ func _on_craft_interceptor() -> void:
func _refresh_load_ore() -> void:
load_ore_label.text = "Load ore\nBank %d Hold %d" % [GameState.rocks, GameState.fleet_cargo]
load_ore_label.text = "Load ore\nBank %d Hold %d" % [GameState.rocks, GameState.fleet_cargo]
load_ore_button.enabled = GameState.rocks > 0
load_ore_button.queue_redraw()
@ -484,6 +514,24 @@ func _on_load_ore() -> void:
_refresh_load_ore()
func _on_store_ore() -> void:
if craft_building_id == 0:
return
var moved: int = GameState.unload_into_building(craft_building_id)
_refresh_craft_status()
if moved > 0:
craft_status.text = "Stored %d ore here %s" % [moved, craft_status.text]
func _on_craft_transporter() -> void:
if craft_building_id == 0:
return
if not GameState.queue_order(craft_building_id, GameState.PRODUCT_TRANSPORTER):
craft_status.text = "Build a Transport Hub first - a transporter needs somewhere to be stationed"
return
_refresh_craft_status()
func _on_formation_changed() -> void:
fleet.apply_formation()