Build the logistics crews, and let them burn energy

#216: transport hubs and spacial workshops no longer conjure their crews.
Transporters and repair drones are ordered at a ship crafter, assigned per
building through a new Station menu, flown out from the mothership hangar,
and spent by the work they do - 20 runs, 12 repairs, counted where the run
ENDS so nothing retires with cargo in the air or a building half repaired.
A spent vessel is gone, so the structure is short again and the player has
to build another. The menu shows what each one has left, worst first.

Craftability needed its own flag: "the crafter can make it" and "it can take
a berth in the fleet" stopped being the same question.

#217: transporters crawl at 120 rather than 150, and a Burn Drive lets them
carry energy and spend it to travel far faster. Fetching it is a leg of its
own, to the nearest store that has any - so a refuelling transporter cannot
be dispatched mid-errand - and the leg flown to COLLECT fuel is not charged
for it. Unresearched, nothing detours and nothing changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
Loïc Wisniewski 2026-09-05 19:09:35 +02:00
commit 265e121cb0
31 changed files with 1180 additions and 141 deletions

View file

@ -21,10 +21,15 @@ const PRICE_OFFSET := 154.0
@onready var status: Label = $StatusLabel
@onready var queue_detail: Label = $QueueDetail
@onready var resource_bar: Control = $Bar
# #216 added the two support craft at the end, in the order
# VESSEL_DEFINITIONS.craftable() returns them - fleet hulls first, so none of
# the rows above moved.
@onready var vessel_buttons: Array = [$InterceptorButton, $ShieldButton,
$GasBomberButton, $CarrierButton, $LaserButton, $DistorderButton]
$GasBomberButton, $CarrierButton, $LaserButton, $DistorderButton,
$TransporterButton, $RepairDroneButton]
@onready var vessel_labels: Array = [$InterceptorLabel, $ShieldLabel,
$GasBomberLabel, $CarrierLabel, $LaserLabel, $DistorderLabel]
$GasBomberLabel, $CarrierLabel, $LaserLabel, $DistorderLabel,
$TransporterLabel, $RepairDroneLabel]
@onready var queue_slots: Array = [$QueueSlot0, $QueueSlot1, $QueueSlot2, $QueueSlot3]
var building_id: int = 0
@ -36,8 +41,8 @@ var price_tags: Array = []
func _ready() -> void:
super._ready()
_build_price_tags()
for i in range(mini(vessel_buttons.size(), VESSEL_DEFINITIONS.fleet().size())):
var definition: Resource = VESSEL_DEFINITIONS.fleet()[i]
for i in range(mini(vessel_buttons.size(), VESSEL_DEFINITIONS.craftable().size())):
var definition: Resource = VESSEL_DEFINITIONS.craftable()[i]
vessel_buttons[i].pressed.connect(
func(): craft_requested.emit(String(definition.definition_id)))
for i in range(queue_slots.size()):
@ -65,7 +70,7 @@ func say(next_message: String) -> void:
func refresh() -> void:
status.text = ""
var definitions: Array = VESSEL_DEFINITIONS.fleet()
var definitions: Array = VESSEL_DEFINITIONS.craftable()
for i in range(mini(definitions.size(), vessel_buttons.size())):
var definition: Resource = definitions[i]
var button: Control = vessel_buttons[i]

View file

@ -212,6 +212,62 @@ autowrap_mode = 2
text = "Distorder"
horizontal_alignment = 1
[node name="TransporterButton" type="Control" parent="."]
anchor_left = 0.5
anchor_right = 0.5
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 215
offset_right = 280
offset_top = -100
offset_bottom = 48
script = ExtResource("10")
icon = 12
glow_color = Color(0.95, 0.55, 0.85, 1)
[node name="TransporterLabel" type="Label" parent="."]
mouse_filter = 2
anchor_left = 0.5
anchor_right = 0.5
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 195
offset_right = 300
offset_top = 56
offset_bottom = 136
theme_override_font_sizes/font_size = 24
autowrap_mode = 2
text = "Transporter"
horizontal_alignment = 1
[node name="RepairDroneButton" type="Control" parent="."]
anchor_left = 0.5
anchor_right = 0.5
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 295
offset_right = 360
offset_top = -100
offset_bottom = 48
script = ExtResource("10")
icon = 43
glow_color = Color(0.5, 0.95, 0.8, 1)
[node name="RepairDroneLabel" type="Label" parent="."]
mouse_filter = 2
anchor_left = 0.5
anchor_right = 0.5
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 275
offset_right = 380
offset_top = 56
offset_bottom = 136
theme_override_font_sizes/font_size = 24
autowrap_mode = 2
text = "Repair Drone"
horizontal_alignment = 1
[node name="QueueLabel" type="Label" parent="."]
mouse_filter = 2
anchor_left = 1.0

110
ui/menus/StationMenu.gd Normal file
View file

@ -0,0 +1,110 @@
extends "res://ui/menus/ModalMenu.gd"
# Forgejo #216: transport hubs and spacial workshops used to conjure their own
# crews, free and permanent. The player orders them at a ship crafter now, and
# this is where they say how many they want standing HERE.
#
# The menu edits the ORDER, not the crew - the same split GarrisonPanel makes
# for outposts, and for the same reason: a hub that has asked for three and
# been sent one is waiting, not broken, and has to read that way.
#
# It also answers "how long will these last". Each vessel is spent by the work
# it does, so the bar row below shows what each of them has left, worst first,
# which is the number that decides whether another needs building.
const BAR_WIDTH: float = 54.0
const BAR_HEIGHT: float = 18.0
const BAR_GAP: float = 10.0
const BAR_TOP: float = 470.0
const WORN_COLOR: Color = Color(1.0, 0.35, 0.25)
const FRESH_COLOR: Color = Color(0.5, 1.0, 0.55)
const PLATE_COLOR: Color = Color(0.02, 0.02, 0.06, 0.9)
const FRAME_COLOR: Color = Color(0.85, 0.96, 1.0, 0.85)
@onready var title: Label = $TitleLabel
@onready var assigned_label: Label = $AssignedLabel
@onready var status: Label = $StatusLabel
@onready var condition_label: Label = $ConditionLabel
@onready var less_button: IconButton = $LessButton
@onready var more_button: IconButton = $MoreButton
var building_id: int = 0
func _ready() -> void:
super._ready()
# ModalMenu already owns $CloseButton and wires it.
less_button.pressed.connect(func(): _step(-1))
more_button.pressed.connect(func(): _step(1))
func open_for(next_building_id: int) -> void:
building_id = next_building_id
open_menu()
refresh()
func close_menu() -> void:
super.close_menu()
building_id = 0
func _step(delta: int) -> void:
if building_id == 0:
return
GameState.set_station_desired(building_id,
GameState.station_desired(building_id) + delta)
refresh()
func refresh() -> void:
if building_id == 0:
return
var building: Dictionary = GameState.find_building(building_id)
if building.is_empty():
close_menu()
return
var vessel_type: String = GameState.station_vessel_type(building)
var wanted: int = GameState.station_desired(building_id)
var here: int = GameState.station_crew(building_id)
var capacity: int = GameState.station_capacity(building)
title.text = String(building.get("type", "")).to_upper().replace("_", " ")
assigned_label.text = "%d / %d ASSIGNED (room for %d)" % [here, wanted, capacity]
less_button.enabled = wanted > 0
more_button.enabled = wanted < capacity
var name: String = GameState.vessel_name(vessel_type)
if wanted == 0:
status.text = "None assigned. Build %s at a ship crafter, then ask for them here." % name.to_lower()
elif here >= wanted:
status.text = "Fully crewed. Each one wears out with use and is not replaced by itself."
else:
status.text = "%d on order - sent from the mothership hangar as they are built." % (wanted - here)
var left: Array = GameState.station_condition(building_id)
condition_label.text = "CONDITION" if not left.is_empty() else ""
queue_redraw()
func _draw() -> void:
if building_id == 0:
return
# One bar per vessel standing here, worst first: what is left of the work
# it was built to do. Drawn rather than built from nodes because the count
# changes as vessels arrive and wear out, and a row of bars is cheaper to
# draw than to keep a pool of Controls in step with.
var left: Array = GameState.station_condition(building_id)
if left.is_empty():
return
var full: int = maxi(GameState.station_work_capacity(building_id), 1)
var total: float = float(left.size()) * BAR_WIDTH + float(left.size() - 1) * BAR_GAP
var x: float = (size.x - total) * 0.5
for remaining in left:
var fraction: float = clampf(float(remaining) / float(full), 0.0, 1.0)
draw_rect(Rect2(x - 2.0, BAR_TOP - 2.0, BAR_WIDTH + 4.0, BAR_HEIGHT + 4.0),
PLATE_COLOR)
draw_rect(Rect2(x, BAR_TOP, BAR_WIDTH * fraction, BAR_HEIGHT),
WORN_COLOR.lerp(FRESH_COLOR, fraction))
draw_rect(Rect2(x, BAR_TOP, BAR_WIDTH, BAR_HEIGHT), FRAME_COLOR, false, 1.5)
x += BAR_WIDTH + BAR_GAP

99
ui/menus/StationMenu.tscn Normal file
View file

@ -0,0 +1,99 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Script" path="res://ui/IconButton.gd" id="icon"]
[ext_resource type="Script" path="res://ui/menus/StationMenu.gd" id="menu"]
[node name="StationMenu" type="Control" groups=["modal_menus"]]
visible = false
mouse_filter = 2
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource("menu")
[node name="Backdrop" type="ColorRect" parent="."]
mouse_filter = 2
anchor_right = 1.0
anchor_bottom = 1.0
color = Color(0.03, 0.03, 0.08, 0.96)
[node name="TitleLabel" type="Label" parent="."]
mouse_filter = 2
anchor_right = 1.0
offset_left = 24.0
offset_top = 24.0
offset_right = -180.0
offset_bottom = 100.0
theme_override_font_sizes/font_size = 40
text = "TRANSPORT HUB"
horizontal_alignment = 1
[node name="CloseButton" type="Control" parent="."]
anchor_left = 1.0
anchor_right = 1.0
offset_left = -140.0
offset_top = 24.0
offset_right = -24.0
offset_bottom = 140.0
script = ExtResource("icon")
icon = 1
glow_color = Color(0.55, 0.6, 1, 1)
[node name="AssignedLabel" type="Label" parent="."]
mouse_filter = 2
anchor_right = 1.0
offset_left = 36.0
offset_top = 190.0
offset_right = -36.0
offset_bottom = 250.0
theme_override_font_sizes/font_size = 30
text = "0 / 0 ASSIGNED"
horizontal_alignment = 1
[node name="LessButton" type="Control" parent="."]
anchor_left = 0.5
anchor_right = 0.5
offset_left = -180.0
offset_top = 280.0
offset_right = -64.0
offset_bottom = 396.0
script = ExtResource("icon")
icon = 28
glow_color = Color(0.95, 0.55, 0.85, 1)
[node name="MoreButton" type="Control" parent="."]
anchor_left = 0.5
anchor_right = 0.5
offset_left = 64.0
offset_top = 280.0
offset_right = 180.0
offset_bottom = 396.0
script = ExtResource("icon")
icon = 29
glow_color = Color(0.95, 0.55, 0.85, 1)
[node name="ConditionLabel" type="Label" parent="."]
mouse_filter = 2
anchor_right = 1.0
offset_left = 36.0
offset_top = 420.0
offset_right = -36.0
offset_bottom = 462.0
theme_override_font_sizes/font_size = 22
theme_override_colors/font_color = Color(0.55, 0.78, 0.86, 1)
text = ""
horizontal_alignment = 1
[node name="StatusLabel" type="Label" parent="."]
mouse_filter = 2
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 40.0
offset_top = -300.0
offset_right = -40.0
offset_bottom = -160.0
theme_override_font_sizes/font_size = 24
theme_override_colors/font_color = Color(0.55, 0.9, 1, 1)
text = ""
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2