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
|
|
@ -24,7 +24,13 @@ var target_chunk: Vector2i
|
|||
var position_before_leaving: Vector2
|
||||
var cached_fade_duration: float = 0.4
|
||||
var returned_ship_count: int = -1
|
||||
var returned_vessel_types: PackedStringArray = PackedStringArray()
|
||||
var game_state: Node
|
||||
var expected_vessel_types: PackedStringArray = PackedStringArray([
|
||||
GameState.VESSEL_INTERCEPTOR, GameState.VESSEL_SHIELD,
|
||||
GameState.VESSEL_TRANSPORTER, GameState.VESSEL_SHIELD,
|
||||
GameState.VESSEL_INTERCEPTOR,
|
||||
])
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
|
|
@ -58,7 +64,7 @@ func _initialize() -> void:
|
|||
landing_controller = main_scene.get_node("LandingController")
|
||||
asteroid_field_ref = main_scene.get_node("AsteroidField")
|
||||
planet_name_label = main_scene.get_node("UI/PlanetNameLabel")
|
||||
enter_button = main_scene.get_node("UI/EnterAtmosphereButton")
|
||||
enter_button = main_scene.get_node("UI/BuildActionButton")
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
|
|
@ -85,6 +91,10 @@ func _process(delta: float) -> bool:
|
|||
# collide with a ship mid-test. Clear the existing ones too.
|
||||
for a in get_nodes_in_group("asteroids"):
|
||||
a.queue_free()
|
||||
# A mixed fleet proves the handoff preserves composition rather
|
||||
# than merely reconstructing the same number of interceptors.
|
||||
fleet.spawn_ships(expected_vessel_types.size(), fleet.get_centroid(),
|
||||
expected_vessel_types)
|
||||
|
||||
# Get the fleet into the target chunk's vicinity first so
|
||||
# PlanetField's spawn radius covers it - the planet's own exact
|
||||
|
|
@ -151,12 +161,13 @@ func _process(delta: float) -> bool:
|
|||
|
||||
var surface_fleet: Node = current_scene.get_node("Fleet")
|
||||
var ship_count_ok: bool = surface_fleet.ships.size() == 5
|
||||
var composition_ok: bool = surface_fleet.vessel_types() == expected_vessel_types
|
||||
var no_asteroids: bool = get_nodes_in_group("asteroids").is_empty()
|
||||
var no_enemies: bool = get_nodes_in_group("enemies").is_empty()
|
||||
print("ship_count_ok=%s (count=%d) no_asteroids=%s no_enemies=%s" % [
|
||||
ship_count_ok, surface_fleet.ships.size(), no_asteroids, no_enemies
|
||||
])
|
||||
if not (ship_count_ok and no_asteroids and no_enemies):
|
||||
if not (ship_count_ok and composition_ok and no_asteroids and no_enemies):
|
||||
print("TEST_PLANET_ATMOSPHERE_TRANSITION: FAIL (surface scene contents wrong)")
|
||||
quit(1)
|
||||
return true
|
||||
|
|
@ -217,6 +228,7 @@ func _process(delta: float) -> bool:
|
|||
for a in get_nodes_in_group("asteroids"):
|
||||
a.queue_free()
|
||||
returned_ship_count = space_fleet.ships.size()
|
||||
returned_vessel_types = space_fleet.vessel_types()
|
||||
|
||||
# Ships respawn in a wedge and then steer into formation, so the
|
||||
# centroid only means anything once they have actually stopped.
|
||||
|
|
@ -236,12 +248,13 @@ func _process(delta: float) -> bool:
|
|||
# across correctly and a fleet came back.
|
||||
var handoff_ok: bool = game_state.surviving_ship_count == 5
|
||||
var ship_count_ok: bool = handoff_ok and returned_ship_count >= 1
|
||||
var composition_ok: bool = returned_vessel_types == expected_vessel_types
|
||||
var position_ok: bool = space_fleet.get_centroid().distance_to(position_before_leaving) < 50.0
|
||||
print("handoff=%d returned_ships=%d ship_count_ok=%s position_ok=%s centroid=%s expected=%s" % [
|
||||
game_state.surviving_ship_count, returned_ship_count,
|
||||
ship_count_ok, position_ok, space_fleet.get_centroid(), position_before_leaving
|
||||
])
|
||||
if ship_count_ok and position_ok:
|
||||
if ship_count_ok and composition_ok and position_ok:
|
||||
print("TEST_PLANET_ATMOSPHERE_TRANSITION: PASS")
|
||||
quit(0)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue