Improve ship crafter and hangar controls

This commit is contained in:
Loïc Wisniewski 2026-08-12 23:08:43 +02:00
commit 06081c41b0
4 changed files with 348 additions and 56 deletions

View file

@ -92,6 +92,23 @@ func add_ship(vessel_type: String = GameState.VESSEL_INTERCEPTOR) -> bool:
return true
func store_ship(index: int) -> String:
# A fleet always keeps one ship deployed. Removing the last one would trip
# the wiped-out-fleet safety net on the next frame and immediately spawn a
# replacement, which is the opposite of storing it at the mothership.
if ships.size() <= 1 or index < 0 or index >= ships.size():
return ""
var ship: Node = ships[index]
if not is_instance_valid(ship):
return ""
var vessel_type: String = String(ship.vessel_type)
ships.remove_at(index)
formation_offsets.remove_at(index)
ship.queue_free()
apply_formation()
return vessel_type
func apply_formation() -> void:
# Re-seats the EXISTING ships into the current GameState.formation.
# Without this, editing the layout at a command centre (or pivoting it)