Support gas cargo transfers

This commit is contained in:
Loïc Wisniewski 2026-08-13 22:17:24 +02:00
commit 4c82155cf3
7 changed files with 91 additions and 2 deletions

View file

@ -133,6 +133,8 @@ var lab_building_id: int = 0
@onready var to_fleet_batch_button: IconButton = get_node("../UI/TransferMenu/ToFleetBatchButton")
@onready var to_fleet_batch_label: Label = get_node("../UI/TransferMenu/ToFleetBatchLabel")
@onready var to_fleet_all_button: IconButton = get_node("../UI/TransferMenu/ToFleetAllButton")
@onready var gas_to_building_button: IconButton = get_node("../UI/TransferMenu/GasToBuildingButton")
@onready var gas_to_fleet_button: IconButton = get_node("../UI/TransferMenu/GasToFleetButton")
# Every building menu carries the same header (#24). Held as a list because
# the only thing any of them needs is to be told which building it is
@ -253,6 +255,8 @@ func _ready() -> void:
to_building_all_button.pressed.connect(_on_transfer.bind(true, ALL))
to_fleet_batch_button.pressed.connect(_on_transfer.bind(false, GameState.CARGO_LOAD_BATCH))
to_fleet_all_button.pressed.connect(_on_transfer.bind(false, ALL))
gas_to_building_button.pressed.connect(_on_gas_transfer.bind(true))
gas_to_fleet_button.pressed.connect(_on_gas_transfer.bind(false))
formation_close_button.pressed.connect(func(): formation_menu.visible = false)
formation_reset_button.pressed.connect(_on_reset_formation)
@ -1002,6 +1006,11 @@ func _on_transfer(to_building: bool, amount: int) -> void:
transfer_status.text = "Loaded %d ore into the fleet" % moved
_refresh_transfer()
func _on_gas_transfer(to_building: bool) -> void:
var moved: int = GameState.transfer_gas_to_building(transfer_building_id, ALL) if to_building else GameState.transfer_gas_to_fleet(transfer_building_id, ALL)
transfer_status.text = "Moved %d gas" % moved if moved > 0 else "No gas available on that side"
_refresh_transfer()
func _transfer_place_name() -> String:
var b: Dictionary = GameState.find_building(transfer_building_id)
@ -1037,6 +1046,10 @@ func _refresh_transfer() -> void:
for button in [to_building_batch_button, to_building_all_button,
to_fleet_batch_button, to_fleet_all_button]:
button.queue_redraw()
gas_to_building_button.enabled = GameState.fleet_gas_cargo > 0
gas_to_fleet_button.enabled = GameState.building_gas_holdings(transfer_building_id) > 0
gas_to_building_button.queue_redraw()
gas_to_fleet_button.queue_redraw()
func _refresh_queue() -> void: