Files
Diabolo/Demon_v0.19/intro_tests.gd
T

46 lines
1.9 KiB
GDScript
Raw 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)
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()