Restrict speed boost to space

This commit is contained in:
Loïc Wisniewski 2026-09-03 23:14:02 +02:00
commit 2ecd61de98
5 changed files with 24 additions and 60 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=3] [gd_scene load_steps=20 format=3]
[ext_resource type="Script" path="res://controllers/GameController.gd" id="1"] [ext_resource type="Script" path="res://controllers/GameController.gd" id="1"]
[ext_resource type="PackedScene" path="res://surface/SurfaceBackground.tscn" id="3"] [ext_resource type="PackedScene" path="res://surface/SurfaceBackground.tscn" id="3"]
@ -13,7 +13,6 @@
[ext_resource type="Script" path="res://controllers/LaserController.gd" id="16"] [ext_resource type="Script" path="res://controllers/LaserController.gd" id="16"]
[ext_resource type="Script" path="res://controllers/DashController.gd" id="dash_ctrl"] [ext_resource type="Script" path="res://controllers/DashController.gd" id="dash_ctrl"]
[ext_resource type="Script" path="res://ui/AbilityButtonLayout.gd" id="ability_layout"] [ext_resource type="Script" path="res://ui/AbilityButtonLayout.gd" id="ability_layout"]
[ext_resource type="Script" path="res://ui/SpeedFader.gd" id="17"]
[ext_resource type="Script" path="res://surface/CaptureLabel.gd" id="15"] [ext_resource type="Script" path="res://surface/CaptureLabel.gd" id="15"]
[ext_resource type="Script" path="res://ui/NarrationBanner.gd" id="banner"] [ext_resource type="Script" path="res://ui/NarrationBanner.gd" id="banner"]
[ext_resource type="Script" path="res://world/QuestDirector.gd" id="quest_dir"] [ext_resource type="Script" path="res://world/QuestDirector.gd" id="quest_dir"]
@ -173,32 +172,6 @@ offset_right = -12
offset_top = -430 offset_top = -430
offset_bottom = -80 offset_bottom = -80
[node name="SpeedFader" type="Control" parent="UI"]
visible = false
mouse_filter = 2
anchor_left = 1.0
anchor_right = 1.0
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = -94
offset_right = -24
offset_top = -720
offset_bottom = -560
script = ExtResource("17")
glow_color = Color(0.5, 0.18, 0.6, 1)
core_color = Color(0.02, 0.09, 0.15, 1)
[node name="Label" type="Label" parent="UI/SpeedFader"]
mouse_filter = 2
offset_left = -20
offset_right = 90
offset_top = -32
offset_bottom = -4
theme_override_font_sizes/font_size = 20
theme_override_colors/font_color = Color(0.7, 0.3, 1, 1)
horizontal_alignment = 1
text = "x1.0"
[node name="LaserButton" type="Control" parent="UI"] [node name="LaserButton" type="Control" parent="UI"]
visible = false visible = false
mouse_filter = 2 mouse_filter = 2

View file

@ -27,6 +27,10 @@ var transitioning: bool = false
func _ready() -> void: func _ready() -> void:
var planet_definition: Resource = PLANET_DEFINITIONS.get_definition(GameState.planet_definition_id) var planet_definition: Resource = PLANET_DEFINITIONS.get_definition(GameState.planet_definition_id)
_compose_surface(SURFACE_PROFILES.get_profile(planet_definition.surface_profile_id)) _compose_surface(SURFACE_PROFILES.get_profile(planet_definition.surface_profile_id))
# The Distorder's sustained travel boost is a space-navigation tool. A
# landing always returns the fleet to normal surface speed; the separate
# aimed dash remains available through its own ability button.
GameState.set_fleet_speed_multiplier(1.0)
fleet.spawn_ships(GameState.surviving_ship_count, Vector2.ZERO, fleet.spawn_ships(GameState.surviving_ship_count, Vector2.ZERO,
GameState.surviving_vessel_types) GameState.surviving_vessel_types)
camera.position = Vector2.ZERO camera.position = Vector2.ZERO

View file

@ -6,6 +6,7 @@ extends SceneTree
const DASH_COST: int = 15 const DASH_COST: int = 15
const DASH_DISTANCE: float = 520.0 const DASH_DISTANCE: float = 520.0
const DASH_SETTLE_TIME: float = 0.3
var state: Node var state: Node
var main: Node var main: Node
@ -71,7 +72,7 @@ func _process(delta: float) -> bool:
elapsed = 0.0 elapsed = 0.0
return false return false
1: 1:
if elapsed < 0.7: if elapsed < DASH_SETTLE_TIME:
return false return false
var moved: Vector2 = fleet.get_centroid() - first_origin var moved: Vector2 = fleet.get_centroid() - first_origin
if absf(moved.x - DASH_DISTANCE) > 8.0 or absf(moved.y) > 8.0: if absf(moved.x - DASH_DISTANCE) > 8.0 or absf(moved.y) > 8.0:
@ -92,7 +93,7 @@ func _process(delta: float) -> bool:
elapsed = 0.0 elapsed = 0.0
return false return false
2: 2:
if elapsed < 0.7: if elapsed < DASH_SETTLE_TIME:
return false return false
var moved: Vector2 = fleet.get_centroid() - second_origin var moved: Vector2 = fleet.get_centroid() - second_origin
if absf(moved.y + DASH_DISTANCE) > 8.0 or absf(moved.x) > 8.0: if absf(moved.y + DASH_DISTANCE) > 8.0 or absf(moved.x) > 8.0:
@ -104,6 +105,8 @@ func _process(delta: float) -> bool:
var surface: Node = load("res://surface/PlanetSurface.tscn").instantiate() var surface: Node = load("res://surface/PlanetSurface.tscn").instantiate()
if not surface.has_node("DashController") or not surface.has_node("UI/DashButton"): if not surface.has_node("DashController") or not surface.has_node("UI/DashButton"):
return _fail("planet surface does not carry the dash ability") return _fail("planet surface does not carry the dash ability")
if surface.has_node("UI/SpeedFader"):
return _fail("planet surface still carries the sustained speed multiplier")
surface.free() surface.free()
print("two aimed dashes moved %.0f units, preserved formation, and cooled down per Propulser" \ print("two aimed dashes moved %.0f units, preserved formation, and cooled down per Propulser" \
% DASH_DISTANCE) % DASH_DISTANCE)

View file

@ -11,9 +11,8 @@ extends SceneTree
# B. dragging it up measurably increases distance travelled per second; # B. dragging it up measurably increases distance travelled per second;
# at 1.0 the fleet moves exactly as it does today # at 1.0 the fleet moves exactly as it does today
# C. formation holds together under boost - ships stay near their slot # C. formation holds together under boost - ships stay near their slot
# D. losing the vessel resets the multiplier and hides the fader # D. losing the vessel resets the multiplier
# E. the multiplier survives the space -> surface scene swap (it lives # E. landing disables the space-only multiplier and surface fader
# in the autoload)
var game_state: Node var game_state: Node
var main: Node var main: Node
@ -192,22 +191,11 @@ func _process(delta: float) -> bool:
release.pressed = false release.pressed = false
main._handle_touch(release) main._handle_touch(release)
# --- E. survives the space -> surface scene swap ------------------- # --- E. landing disables the space-only sustained boost ------------
# Done here, with the distorder ship still crewed and the fleet # Keep the Distorder crewed and the boost active across teardown so
# still boosted: tearing this scene down while nothing else # the landed surface itself has to enforce the boundary.
# changes the fleet's own composition proves the multiplier # Check the premise before relying on it: landing should reset the
# lives in the autoload rather than being reset as a side effect # boost even though the fleet still owns the vessel that enables it.
# of the old scene's own SpeedFader still ticking once more
# during teardown (it would, correctly, self-reset the instant
# it next saw a fleet with no distorder ship - not a real
# scenario here since this fleet keeps its distorder ship the
# whole way across the swap, via GameState.surviving_vessel_types
# exactly like every other vessel type).
# Check the premise before relying on it. Everything below is about
# the multiplier surviving a scene swap, which is only meaningful
# while the fleet still crews a distorder vessel - so if the fleet
# lost one on the way here, say THAT rather than reporting a reset
# multiplier as if the swap were at fault.
if not fleet.has_capability("distorder"): if not fleet.has_capability("distorder"):
return _fail_now("the fleet lost its distorder vessel before the scene swap, so the multiplier reset is expected rather than a bug") return _fail_now("the fleet lost its distorder vessel before the scene swap, so the multiplier reset is expected rather than a bug")
game_state.surviving_ship_count = fleet.ships.size() game_state.surviving_ship_count = fleet.ships.size()
@ -225,26 +213,22 @@ func _process(delta: float) -> bool:
root.add_child(main) root.add_child(main)
current_scene = main current_scene = main
fleet = main.get_node("Fleet") fleet = main.get_node("Fleet")
fader = main.get_node("UI/SpeedFader")
elapsed = 0.0 elapsed = 0.0
stage = 6 stage = 6
return false return false
6: 6:
if elapsed < 0.3: if elapsed < 0.3:
return false return false
if not is_equal_approx(game_state.fleet_speed_multiplier, 3.0): if not is_equal_approx(game_state.fleet_speed_multiplier, 1.0):
return _fail_now("multiplier did not survive the space -> surface swap: %f" \ return _fail_now("landing did not reset the space-only multiplier: %f" \
% game_state.fleet_speed_multiplier) % game_state.fleet_speed_multiplier)
fader._process(0.0) if main.get_node_or_null("UI/SpeedFader") != null:
if not fader.visible: return _fail_now("the space-only speed fader is present on the planet")
return _fail_now("the surface scene's fader did not show the surviving distorder ship") print("landing reset the multiplier and omitted its space-only fader")
print("multiplier and fader both survived the space -> surface swap")
# --- D. losing the vessel resets the multiplier ------------------- # --- D. losing the vessel resets the multiplier -------------------
game_state.set_fleet_speed_multiplier(GameState.MAX_FLEET_SPEED_MULTIPLIER)
fleet.spawn_ships(1, fleet.get_centroid(), PackedStringArray([GameState.VESSEL_INTERCEPTOR])) fleet.spawn_ships(1, fleet.get_centroid(), PackedStringArray([GameState.VESSEL_INTERCEPTOR]))
fader._process(0.0)
if fader.visible:
return _fail_now("fader stayed visible after losing the last distorder ship")
if not is_equal_approx(game_state.fleet_speed_multiplier, 1.0): if not is_equal_approx(game_state.fleet_speed_multiplier, 1.0):
return _fail_now("multiplier was not reset after losing the distorder ship: %f" \ return _fail_now("multiplier was not reset after losing the distorder ship: %f" \
% game_state.fleet_speed_multiplier) % game_state.fleet_speed_multiplier)

View file

@ -37,7 +37,7 @@ var steer_direction: Vector2 = Vector2.ZERO
var dash_direction: Vector2 = Vector2.ZERO var dash_direction: Vector2 = Vector2.ZERO
var dash_remaining: float = 0.0 var dash_remaining: float = 0.0
const DASH_SPEED: float = 1400.0 const DASH_SPEED: float = 2800.0
func _ready() -> void: func _ready() -> void: