Cap fleet cargo capacity by composition (#56)

The fleet hold was unbounded - GameState.fleet_inventory had no
total_capacity, so a lone ship could carry unlimited resources. Capacity
is now data-driven: only vessels declaring the "cargo" capability
contribute their cargo_capacity stat (interceptor: 20; shield vessel and
gas bomber: 0, unarmed transporters are never in the fleet at all).
Fleet.gd recomputes it in the one place composition can change
(spawn_ships/add_ship/store_ship/_on_ship_destroyed), which also covers
the space<->surface scene-swap restore since that goes through
spawn_ships().

Rock.gd and GasVentField.gd (the two "fly over it to collect" pickup
paths) now check what collect_cargo()/collect_gas_cargo() actually
accepted before consuming their source, instead of assuming an
unlimited hold. The HUD's FLEET HOLD caption shows the live total/cap.

Also fixes test_resource_transfer.gd, which pushed more ore through a
2-ship fleet than the new cap allows - it now spawns the largest fleet
every unlocked doctrine permits, since that test is about the transfer
UI rather than the cap itself (test_fleet_cargo_limit.gd owns that).
This commit is contained in:
Loïc Wisniewski 2026-08-16 14:53:26 +02:00
commit f040327523
11 changed files with 250 additions and 12 deletions

View file

@ -80,6 +80,7 @@ func spawn_ships(count: int, center: Vector2 = Vector2.ZERO,
ship.destroyed.connect(_on_ship_destroyed.bind(ship))
fleet_target = center
GameState.sync_fleet_cargo_capacity(vessel_types())
func vessel_types() -> PackedStringArray:
@ -138,6 +139,7 @@ func add_ship(vessel_type: String = GameState.VESSEL_INTERCEPTOR) -> bool:
if ship.has_signal("destroyed"):
ship.destroyed.connect(_on_ship_destroyed.bind(ship))
ship.set_move_target(fleet_target + offset)
GameState.sync_fleet_cargo_capacity(vessel_types())
return true
@ -155,6 +157,7 @@ func store_ship(index: int) -> String:
formation_offsets.remove_at(index)
ship.queue_free()
apply_formation()
GameState.sync_fleet_cargo_capacity(vessel_types())
return vessel_type
@ -273,6 +276,7 @@ func _on_ship_destroyed(ship: Node) -> void:
if idx != -1:
ships.remove_at(idx)
formation_offsets.remove_at(idx)
GameState.sync_fleet_cargo_capacity(vessel_types())
func get_centroid() -> Vector2: