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

@ -42,10 +42,14 @@ var gas: int = 0
# down and rebuilt on every trip to a planet's surface - and cargo mined ON a
# surface would otherwise be dropped the moment the player took off.
var fleet_cargo: int = 0
var fleet_gas_cargo: int = 0
func collect_cargo(amount: int = 1) -> void:
fleet_cargo += amount
func collect_gas_cargo(amount: int = 1) -> void:
fleet_gas_cargo += amount
# The batch size the transfer menu offers, next to "All". A batch rather
# than only all-or-nothing: the hold is the part that can be lost, and
@ -73,6 +77,11 @@ func building_holdings(id: int) -> int:
return rocks
return int(b.get("stock", 0))
func building_gas_holdings(id: int) -> int:
var b: Dictionary = find_building(id)
if b.is_empty(): return 0
return gas if b.type == BUILDING_MOTHERSHIP else int(b.get("gas_stock", 0))
func transfer_to_building(id: int, amount: int) -> int:
# Hold -> this building. Returns how much actually moved, which is capped
@ -108,6 +117,24 @@ func transfer_to_fleet(id: int, amount: int) -> int:
fleet_cargo += moved
return moved
func transfer_gas_to_building(id: int, amount: int) -> int:
var b: Dictionary = find_building(id)
if b.is_empty(): return 0
var moved := mini(amount, fleet_gas_cargo)
fleet_gas_cargo -= moved
if b.type == BUILDING_MOTHERSHIP: gas += moved
else: b.gas_stock = int(b.get("gas_stock", 0)) + moved
return moved
func transfer_gas_to_fleet(id: int, amount: int) -> int:
var b: Dictionary = find_building(id)
if b.is_empty(): return 0
var moved := mini(amount, building_gas_holdings(id))
if b.type == BUILDING_MOTHERSHIP: gas -= moved
else: b.gas_stock = int(b.get("gas_stock", 0)) - moved
fleet_gas_cargo += moved
return moved
const MOTHERSHIP_COST: int = 20
const SHIP_CRAFTER_COST: int = 12
const SHIP_COST: int = 6