Files

61 lines
2.8 KiB
GDScript
Raw Permalink Normal View History

extends RefCounted
func run(g):
AudioServer.set_bus_mute(0,true)
g.start_game()
g.intro.begin()
var start=Time.get_ticks_msec()
var position=g.player.position
var coins=g.coins
var camera_position=g.camera.position
assert(g.paused and not g.hud.visible)
await g.get_tree().create_timer(1.5).timeout
assert(not g.intro.voice_started)
assert(camera_position.distance_to(g.camera.position)>1)
g.intro.suspend(true)
var elapsed=g.intro.elapsed
await g.get_tree().create_timer(.2).timeout
assert(g.intro.elapsed==elapsed)
g.intro.suspend(false)
await g.get_tree().create_timer(.8).timeout
assert(g.intro.voice_started and g.intro.voice.playing)
await g.get_tree().process_frame
g.get_viewport().get_texture().get_image().save_png("res://captures/intro-camera.png")
for key in [KEY_F5,KEY_B,KEY_T,KEY_ESCAPE]:
var event=InputEventKey.new();event.keycode=key;event.physical_keycode=key;event.pressed=true
g._input(event);g._unhandled_input(event)
assert(g.coins==coins and g.player.position==position)
assert(not g.workshop.build_mode and not g.development.tree_panel.visible)
while g.intro.tail_elapsed<0:
assert(Time.get_ticks_msec()-start<22000)
await g.get_tree().process_frame
var end_of_voice=Time.get_ticks_msec()
assert(g.intro.active and g.paused)
await g.get_tree().create_timer(1.5).timeout
assert(g.intro.active and g.paused)
while g.intro.active:await g.get_tree().process_frame
assert(Time.get_ticks_msec()-end_of_voice>=1950)
assert(not g.paused and g.hud.visible and is_equal_approx(g.camera.size,20))
assert(g.coins==coins and g.player.position==position)
g.set_pause(true);g.start_game()
assert(not g.intro.active)
g.intro.begin();g.reset_shift()
assert(not g.intro.active and not g.intro.voice.playing and not g.avatar.cinematic_idle)
# Space skips during lead, speech and camera return without leaking gameplay input.
for phase in ["lead","voice","tail"]:
g.intro.begin()
if phase!="lead":g.intro.update(2.1)
if phase=="tail":g.intro._voice_finished();g.intro.update(.3)
var before_coins=g.coins;var before_position=g.player.position
var release=InputEventKey.new();release.keycode=KEY_SPACE;release.pressed=false
g._input(release);assert(g.intro.active)
var echo=InputEventKey.new();echo.keycode=KEY_SPACE;echo.pressed=true;echo.echo=true
g._input(echo);assert(g.intro.active)
var skip=InputEventKey.new();skip.keycode=KEY_SPACE;skip.physical_keycode=KEY_SPACE;skip.pressed=true
g._input(skip)
assert(not g.intro.active and not g.intro.voice.playing and not g.paused and g.hud.visible)
assert(not g.avatar.cinematic_idle and is_equal_approx(g.camera.size,20))
assert(g.coins==before_coins and g.player.position==before_position and g.orbit.keys.is_empty())
print("PASS: intro full recording, 2s lead/tail, input lock, camera restore, suspend, resume and reset (%d ms)" % (Time.get_ticks_msec()-start))
g.get_tree().quit()