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:
parent
cbe07bbb55
commit
f040327523
11 changed files with 250 additions and 12 deletions
|
|
@ -30,9 +30,19 @@ const GLYPH_GAP: float = 8.0
|
|||
var _banked_numbers: Dictionary = {}
|
||||
var _fleet_numbers: Dictionary = {}
|
||||
|
||||
# #56: the fleet hold now has a finite total capacity. Rather than a new
|
||||
# node, this reuses the existing "FLEET HOLD" caption Label that both Main
|
||||
# and PlanetSurface already place as a sibling - get_node_or_null so a
|
||||
# scene that happens to embed ResourceReadout without that sibling (none
|
||||
# does today) degrades to just not showing a limit, instead of erroring.
|
||||
@onready var _fleet_caption: Label = get_node_or_null("../FleetCaption")
|
||||
var _fleet_caption_base_text: String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
if _fleet_caption != null:
|
||||
_fleet_caption_base_text = _fleet_caption.text
|
||||
var y: float = 0.0
|
||||
for resource_type in GameState.resource_types():
|
||||
var banked_color: Color = GameState.resource_color(resource_type)
|
||||
|
|
@ -81,6 +91,11 @@ func fleet_number(resource_type: String) -> NeonNumber:
|
|||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if _fleet_caption != null:
|
||||
var capacity: int = GameState.fleet_cargo_total_capacity()
|
||||
_fleet_caption.text = "%s %d/%d" % [_fleet_caption_base_text, GameState.fleet_cargo_used(), capacity] \
|
||||
if capacity >= 0 else _fleet_caption_base_text
|
||||
|
||||
for resource_type in GameState.resource_types():
|
||||
var banked: NeonNumber = _banked_numbers.get(resource_type)
|
||||
if banked != null:
|
||||
|
|
|
|||
Loading…
Reference in a new issue