Refine context actions and preserve fleet landings
This commit is contained in:
parent
18a7d44db4
commit
663648d949
20 changed files with 197 additions and 103 deletions
20
Fleet.gd
20
Fleet.gd
|
|
@ -4,10 +4,9 @@ extends Node2D
|
|||
# centre) rather than being fixed here, so a layout the player arranged
|
||||
# survives scene swaps and fleet rebuilds. Ships are always
|
||||
# spawned programmatically (spawn_ships), using however many of these
|
||||
# offsets are needed - both for a fresh start (5 ships) and for restoring
|
||||
# a possibly-smaller surviving fleet after returning from a planet's
|
||||
# surface, so both cases share one code path instead of two that could
|
||||
# drift out of sync.
|
||||
# offsets are needed. The optional vessel-type list preserves the exact
|
||||
# mixed fleet through scene swaps; a fresh start still defaults each slot
|
||||
# to an interceptor.
|
||||
# The fleet's cruise speed. This is the speed of the FLEET as a whole: the
|
||||
# anchor below advances at exactly this rate, and individual ships are
|
||||
# allowed to fly faster than it (Ship.max_speed) so they can close on their
|
||||
|
|
@ -44,7 +43,8 @@ func _on_vessel_upgraded(_id: String) -> void:
|
|||
ship.apply_vessel_stats()
|
||||
|
||||
|
||||
func spawn_ships(count: int, center: Vector2 = Vector2.ZERO) -> void:
|
||||
func spawn_ships(count: int, center: Vector2 = Vector2.ZERO,
|
||||
vessel_types: PackedStringArray = PackedStringArray()) -> void:
|
||||
for ship in ships:
|
||||
if is_instance_valid(ship):
|
||||
ship.queue_free()
|
||||
|
|
@ -55,6 +55,8 @@ func spawn_ships(count: int, center: Vector2 = Vector2.ZERO) -> void:
|
|||
for i in range(n):
|
||||
var offset: Vector2 = GameState.formation[i]
|
||||
var ship: Area2D = ship_scene.instantiate()
|
||||
if i < vessel_types.size():
|
||||
ship.vessel_type = vessel_types[i]
|
||||
ship.position = center + offset
|
||||
ship.glow_color = ship_glow_color
|
||||
ship.core_color = ship_core_color
|
||||
|
|
@ -67,6 +69,14 @@ func spawn_ships(count: int, center: Vector2 = Vector2.ZERO) -> void:
|
|||
fleet_target = center
|
||||
|
||||
|
||||
func vessel_types() -> PackedStringArray:
|
||||
var result: PackedStringArray = PackedStringArray()
|
||||
for ship in ships:
|
||||
if is_instance_valid(ship):
|
||||
result.append(String(ship.vessel_type))
|
||||
return result
|
||||
|
||||
|
||||
func add_ship(vessel_type: String = GameState.VESSEL_INTERCEPTOR) -> bool:
|
||||
# Adds one vessel in the next free formation slot (bought from a ship
|
||||
# crafter). Returns false when the wedge is already full.
|
||||
|
|
|
|||
Loading…
Reference in a new issue