Smooth boosted fleet travel
This commit is contained in:
parent
e5439f7183
commit
fd792e8b63
12 changed files with 90 additions and 8 deletions
|
|
@ -113,11 +113,45 @@ func _process(delta: float) -> bool:
|
|||
root.add_child(main)
|
||||
fleet = main.get_node("Fleet")
|
||||
fader = main.get_node("UI/SpeedFader")
|
||||
fleet.spawn_ships(1, Vector2.ZERO, PackedStringArray([GameState.VESSEL_DISTORDER]))
|
||||
# A carrier supplies the hold the Propulser burns from. The previous
|
||||
# one-Propulser fixture had zero cargo capacity, so its depletion check
|
||||
# accidentally began with no energy regardless of what it deposited.
|
||||
fleet.spawn_ships(2, Vector2.ZERO, PackedStringArray([
|
||||
GameState.VESSEL_CARRIER, GameState.VESSEL_DISTORDER]))
|
||||
fader._process(0.0)
|
||||
if not fader.visible:
|
||||
return _fail_now("fader hidden with a distorder ship in the fleet")
|
||||
if not bool(ProjectSettings.get_setting(
|
||||
"physics/common/physics_interpolation", false)):
|
||||
return _fail_now("physics interpolation is disabled for boosted flight")
|
||||
if fleet.ships[0].physics_interpolation_mode \
|
||||
!= Node.PHYSICS_INTERPOLATION_MODE_ON:
|
||||
return _fail_now("the boosted vessel is not physics-interpolated")
|
||||
if main.get_node("Camera2D").physics_interpolation_mode \
|
||||
!= Node.PHYSICS_INTERPOLATION_MODE_ON:
|
||||
return _fail_now("the fleet camera is not physics-interpolated")
|
||||
|
||||
# #199: choosing a higher cruise speed is free while parked. Once a
|
||||
# heading is active, the exact same multiplier resumes its normal drain.
|
||||
game_state.deposit_fleet_resource(GameState.RESOURCE_ENERGY, 30)
|
||||
game_state.set_fleet_speed_multiplier(GameState.MAX_FLEET_SPEED_MULTIPLIER)
|
||||
var parked_energy: int = game_state.fleet_resource(GameState.RESOURCE_ENERGY)
|
||||
game_state._advance_distorder_drain(5.0,
|
||||
game_state._distorder_boost_in_use())
|
||||
if game_state.fleet_resource(GameState.RESOURCE_ENERGY) != parked_energy:
|
||||
return _fail_now("a parked fleet consumed boost energy")
|
||||
fleet.move_in_direction(Vector2.RIGHT)
|
||||
if not fleet.is_using_speed_boost():
|
||||
return _fail_now("boosted cruise did not report its energy use")
|
||||
game_state._advance_distorder_drain(1.0,
|
||||
game_state._distorder_boost_in_use())
|
||||
if game_state.fleet_resource(GameState.RESOURCE_ENERGY) >= parked_energy:
|
||||
return _fail_now("moving at boosted cruise consumed no energy")
|
||||
fleet.stop()
|
||||
print("parked boost was free; moving boost resumed drain")
|
||||
|
||||
game_state.withdraw_fleet_resource(GameState.RESOURCE_ENERGY,
|
||||
game_state.fleet_resource(GameState.RESOURCE_ENERGY))
|
||||
game_state.deposit_fleet_resource(GameState.RESOURCE_ENERGY, 4)
|
||||
game_state.set_fleet_speed_multiplier(GameState.MAX_FLEET_SPEED_MULTIPLIER)
|
||||
fader._process(0.0)
|
||||
|
|
|
|||
|
|
@ -67,14 +67,14 @@ func _process(delta: float) -> bool:
|
|||
return _fail("the Propulser that dashed did not enter cooldown")
|
||||
# The burst should cover substantially more than a linear quarter of
|
||||
# its distance at a quarter of its duration, then ease into its stop.
|
||||
fleet.set_process(false)
|
||||
fleet.set_physics_process(false)
|
||||
fleet._advance_dash(fleet.dash_duration * 0.25)
|
||||
var early_distance: float = fleet.get_centroid().distance_to(first_origin)
|
||||
if early_distance <= DASH_DISTANCE * 0.45 \
|
||||
or early_distance >= DASH_DISTANCE * 0.7:
|
||||
return _fail("dash has no useful ease-out curve (quarter-time distance %.1f)" \
|
||||
% early_distance)
|
||||
fleet.set_process(true)
|
||||
fleet.set_physics_process(true)
|
||||
dash._process(0.0)
|
||||
if not main.get_node("UI/DashButton").enabled:
|
||||
return _fail("one cooling Propulser disabled a second ready one")
|
||||
|
|
|
|||
Loading…
Reference in a new issue