Provision transporters with hubs
This commit is contained in:
parent
663648d949
commit
d0a9f5b971
21 changed files with 309 additions and 588 deletions
18
Fleet.gd
18
Fleet.gd
|
|
@ -51,12 +51,21 @@ func spawn_ships(count: int, center: Vector2 = Vector2.ZERO,
|
|||
ships.clear()
|
||||
formation_offsets.clear()
|
||||
|
||||
var n: int = clamp(count, 1, GameState.max_fleet_size())
|
||||
var spawn_types: PackedStringArray = PackedStringArray()
|
||||
if vessel_types.is_empty():
|
||||
for i in range(count):
|
||||
spawn_types.append(GameState.VESSEL_INTERCEPTOR)
|
||||
else:
|
||||
for vessel_type in vessel_types:
|
||||
if GameState.vessel_is_fleet_eligible(vessel_type):
|
||||
spawn_types.append(vessel_type)
|
||||
if spawn_types.is_empty():
|
||||
spawn_types.append(GameState.VESSEL_INTERCEPTOR)
|
||||
var n: int = clamp(spawn_types.size(), 1, GameState.max_fleet_size())
|
||||
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.vessel_type = spawn_types[i]
|
||||
ship.position = center + offset
|
||||
ship.glow_color = ship_glow_color
|
||||
ship.core_color = ship_core_color
|
||||
|
|
@ -80,7 +89,8 @@ func vessel_types() -> PackedStringArray:
|
|||
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.
|
||||
if ships.size() >= GameState.max_fleet_size():
|
||||
if not GameState.vessel_is_fleet_eligible(vessel_type) \
|
||||
or ships.size() >= GameState.max_fleet_size():
|
||||
return false
|
||||
var offset: Vector2 = GameState.formation[ships.size()]
|
||||
var ship: Area2D = ship_scene.instantiate()
|
||||
|
|
|
|||
Loading…
Reference in a new issue