Add opening heroine orbit with Serafina voice and delayed controls
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://bamstjlukbfa1"
|
||||
path="res://.godot/imported/intro_serafina.mp3-a51bcbb5fc574e842310b314086bb95b.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://audio/intro_serafina.mp3"
|
||||
dest_files=["res://.godot/imported/intro_serafina.mp3-a51bcbb5fc574e842310b314086bb95b.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -0,0 +1,91 @@
|
||||
extends Node
|
||||
|
||||
const RECORDING = preload("res://audio/intro_serafina.mp3")
|
||||
const LEAD = 2.0
|
||||
const TAIL = 2.0
|
||||
var g
|
||||
var voice: AudioStreamPlayer
|
||||
var active = false
|
||||
var suspended = false
|
||||
var elapsed = 0.0
|
||||
var tail_elapsed = -1.0
|
||||
var voice_started = false
|
||||
var saved_size = 20.0
|
||||
var saved_pan = Vector3.ZERO
|
||||
var tail_transform = Transform3D.IDENTITY
|
||||
|
||||
func setup(game):
|
||||
g=game
|
||||
voice=AudioStreamPlayer.new()
|
||||
add_child(voice)
|
||||
voice.stream=RECORDING
|
||||
voice.finished.connect(_voice_finished)
|
||||
|
||||
func begin():
|
||||
cancel()
|
||||
saved_size=g.camera.size
|
||||
saved_pan=g.orbit.pan
|
||||
g.orbit.stop();g.orbit.keys.clear()
|
||||
g.dialogue.stop();g.voice_player.stop()
|
||||
if is_instance_valid(g.life.hero_bubble):
|
||||
g.life.hero_bubble.queue_free();g.life.hero_bubble=null
|
||||
g.avatar.set_walking(false)
|
||||
g.avatar.cinematic_idle=true
|
||||
g.paused=true
|
||||
g.hud.hide()
|
||||
active=true;suspended=false;elapsed=0;tail_elapsed=-1;voice_started=false
|
||||
update(0)
|
||||
|
||||
func update(delta):
|
||||
if not active or suspended:return
|
||||
voice.volume_db=linear_to_db(maxf(g.voice_volume,.0001))
|
||||
elapsed+=delta
|
||||
if not voice_started and elapsed>=LEAD:
|
||||
voice_started=true
|
||||
voice.play()
|
||||
if tail_elapsed>=0:
|
||||
tail_elapsed+=delta
|
||||
var blend=smoothstep(0.0,1.0,minf(tail_elapsed/TAIL,1.0))
|
||||
var focus=g.orbit.base_focus()+saved_pan
|
||||
var offset=Vector3(sin(g.orbit.yaw)*cos(g.orbit.pitch),sin(g.orbit.pitch),cos(g.orbit.yaw)*cos(g.orbit.pitch))*30.0
|
||||
var destination=Transform3D(Basis.looking_at(-offset.normalized()),focus+offset)
|
||||
g.camera.global_transform=tail_transform.interpolate_with(destination,blend)
|
||||
g.camera.size=lerpf(4.6,saved_size,blend)
|
||||
if tail_elapsed>=TAIL:finish()
|
||||
else:
|
||||
var angle=g.orbit.yaw+TAU*minf(elapsed/(LEAD+RECORDING.get_length()),1.0)
|
||||
var target=g.player.global_position+Vector3(0,1.2,0)
|
||||
g.camera.global_position=target+Vector3(sin(angle)*3.5,1.0,cos(angle)*3.5)
|
||||
g.camera.look_at(target)
|
||||
g.camera.size=4.6
|
||||
g.architecture.update(g.camera)
|
||||
|
||||
func _voice_finished():
|
||||
if active and voice_started:
|
||||
tail_elapsed=0
|
||||
tail_transform=g.camera.global_transform
|
||||
|
||||
func suspend(value):
|
||||
suspended=value
|
||||
voice.stream_paused=value
|
||||
g.avatar.cinematic_idle=not value
|
||||
|
||||
func finish():
|
||||
_restore()
|
||||
g.paused=false
|
||||
g.hud.show()
|
||||
g.talk_clock=0
|
||||
|
||||
func cancel():
|
||||
if not active:return
|
||||
_restore()
|
||||
|
||||
func _restore():
|
||||
voice.stop();voice.stream_paused=false
|
||||
active=false;suspended=false
|
||||
g.avatar.cinematic_idle=false
|
||||
g.orbit.keys.clear()
|
||||
g.orbit.pan=saved_pan
|
||||
g.orbit.focus=g.orbit.base_focus()+saved_pan
|
||||
g.camera.size=saved_size
|
||||
g.orbit.update(0)
|
||||
@@ -0,0 +1,45 @@
|
||||
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()
|
||||
+25
-4
@@ -49,6 +49,7 @@ var flames: Array = []
|
||||
var moving_gears: Array = []
|
||||
var wisps: Array = []
|
||||
var architecture = preload("res://endless.gd").new()
|
||||
var intro = preload("res://intro_cinematic.gd").new()
|
||||
var orbit = preload("res://orbit.gd").new()
|
||||
var dungeon = preload("res://dungeon.gd").new()
|
||||
var audio_player: AudioStreamPlayer
|
||||
@@ -85,7 +86,7 @@ var quips = ["Ещё один. Наверху сегодня скидки на
|
||||
|
||||
func _ready():
|
||||
var args=OS.get_cmdline_user_args()
|
||||
test_mode="--test-room-decor" in args or "--test-camera-controls" in args or "--test-rubies" in args or "--test-runtime-burn" in args or "--test-single-punishment" in args or "--test-expansion" in args or "--test-imps" in args or "--test-flight-camera" in args or "--test-maintenance" in args or "--test-castle" in args or "--test-building" in args or "--test-workflow" in args or "--test-roster" in args or "--test-priority" in args or "--test-mesh" in args or "--test-economy" in args or "--test-posture" in args or "--test-gait" in args or "--test-visuals" in args or "--test-mode" in args or "--test-exit" in args or "--test-ui" in args or "--test-audio" in args or "--test-sentences" in args or "--test-hud" in args
|
||||
test_mode="--test-intro" in args or "--test-room-decor" in args or "--test-camera-controls" in args or "--test-rubies" in args or "--test-runtime-burn" in args or "--test-single-punishment" in args or "--test-expansion" in args or "--test-imps" in args or "--test-flight-camera" in args or "--test-maintenance" in args or "--test-castle" in args or "--test-building" in args or "--test-workflow" in args or "--test-roster" in args or "--test-priority" in args or "--test-mesh" in args or "--test-economy" in args or "--test-posture" in args or "--test-gait" in args or "--test-visuals" in args or "--test-mode" in args or "--test-exit" in args or "--test-ui" in args or "--test-audio" in args or "--test-sentences" in args or "--test-hud" in args
|
||||
capture_mode="--capture-workflow" in args or "--capture-roster" in args or "--capture-economy" in args or "--capture-posture" in args or "--capture-gait" in args or "--capture" in args or "--capture-workshop" in args
|
||||
if FileAccess.file_exists("res://build_info.json"):
|
||||
var stamp=JSON.parse_string(FileAccess.get_file_as_string("res://build_info.json"))
|
||||
@@ -135,13 +136,16 @@ func _ready():
|
||||
workshop=preload("res://workshop.gd").new()
|
||||
add_child(workshop)
|
||||
workshop.setup(self)
|
||||
add_child(intro)
|
||||
intro.setup(self)
|
||||
if not test_mode and not capture_mode: ambience_player.play()
|
||||
paused=true
|
||||
hud.visible=false
|
||||
say("Первый день. Последняя надежда на отпуск.")
|
||||
refresh_ui()
|
||||
if automatic: build_auto_arm()
|
||||
if "--test-exit" in args: call_deferred("test_exit")
|
||||
if "--test-intro" in args:call_deferred("run_intro_tests")
|
||||
elif "--test-exit" in args: call_deferred("test_exit")
|
||||
elif "--test-audio" in args: call_deferred("run_audio_tests")
|
||||
elif "--test-ui" in args: call_deferred("run_ui_tests")
|
||||
elif "--test-room-decor" in args:call_deferred("run_room_decor_tests")
|
||||
@@ -304,6 +308,7 @@ func set_pause(value: bool):
|
||||
else: menu.show_page("")
|
||||
|
||||
func start_game():
|
||||
var new_shift=menu.current_page=="main" or not game_started
|
||||
if menu.current_page=="main":reset_shift()
|
||||
if not game_started:
|
||||
game_started=true
|
||||
@@ -313,9 +318,11 @@ func start_game():
|
||||
hud.visible=true
|
||||
set_pause(false)
|
||||
if workshop:workshop.message("240 золота на обустройство. [B] — строительство, [T] — развитие.");workshop.refresh()
|
||||
say("Новая смена. Обустрой свой цех.")
|
||||
if new_shift and not test_mode and not capture_mode:intro.begin()
|
||||
else:say("Новая смена. Обустрой свой цех.")
|
||||
|
||||
func reset_shift():
|
||||
intro.cancel()
|
||||
if workshop:workshop.reset()
|
||||
for soul in souls:
|
||||
if is_instance_valid(soul.node):soul.node.queue_free()
|
||||
@@ -341,6 +348,7 @@ func reset_shift():
|
||||
refresh_ui()
|
||||
|
||||
func return_to_main_menu():
|
||||
intro.cancel()
|
||||
set_pause(true)
|
||||
hud.visible=false
|
||||
menu.show_main()
|
||||
@@ -513,10 +521,14 @@ func floating(text: String, p: Vector3, c: Color):
|
||||
popups.append({"node":l,"ttl":1.15})
|
||||
|
||||
func _input(event):
|
||||
if intro.active:
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if workshop:workshop.track_pointer(event)
|
||||
orbit.input(event)
|
||||
|
||||
func _unhandled_input(event):
|
||||
if intro.active:return
|
||||
if workshop and workshop.input(event):return
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
if event.keycode==KEY_F5 or event.physical_keycode==KEY_F5:
|
||||
@@ -554,6 +566,9 @@ func _process(delta):
|
||||
var dt=minf(delta,0.05)
|
||||
ambience_fade=minf(1.0,ambience_fade+delta/1.5)
|
||||
update_audio_levels()
|
||||
if intro.active:
|
||||
intro.update(delta)
|
||||
return
|
||||
time+=dt
|
||||
for gear in moving_gears: gear.rotation.z+=dt*0.65
|
||||
if workshop:
|
||||
@@ -689,6 +704,9 @@ func build_auto_arm():
|
||||
cylinder(self,STATION+Vector3(1.1,0.9,-0.5),0.15,1.8,Color("8c7186"))
|
||||
|
||||
func _notification(what):
|
||||
if is_instance_valid(intro) and intro.active and not test_mode and not capture_mode:
|
||||
if what==NOTIFICATION_APPLICATION_FOCUS_OUT:intro.suspend(true)
|
||||
elif what==NOTIFICATION_APPLICATION_FOCUS_IN:intro.suspend(false)
|
||||
if what==NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
orbit.stop();orbit.keys.clear()
|
||||
if workshop and workshop.build_mode and (workshop.drag.active or workshop.drag.index>=0):workshop.cancel_placement()
|
||||
@@ -742,7 +760,7 @@ func update_audio_levels():
|
||||
if dialogue:dialogue.update()
|
||||
if voice_player:voice_player.volume_db=linear_to_db(maxf(voice_volume,0.0001))
|
||||
if audio_player: audio_player.volume_db=-3.0+linear_to_db(maxf(whip_volume,0.0001))
|
||||
if ambience_player: ambience_player.volume_db=linear_to_db(maxf(ambience_volume*ambience_fade,0.0001))
|
||||
if ambience_player: ambience_player.volume_db=linear_to_db(maxf(ambience_volume*ambience_fade*(.25 if intro.active else 1.0),0.0001))
|
||||
|
||||
func save_settings():
|
||||
if test_mode or capture_mode: return
|
||||
@@ -990,3 +1008,6 @@ func run_camera_controls_tests():
|
||||
|
||||
func run_room_decor_tests():
|
||||
await preload("res://room_decor_tests.gd").new().run(self)
|
||||
|
||||
func run_intro_tests():
|
||||
await preload("res://intro_tests.gd").new().run(self)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
extends Node3D
|
||||
var game
|
||||
var animator: AnimationPlayer
|
||||
var cinematic_idle=false
|
||||
var walking=false
|
||||
var striking=false
|
||||
var clips={}
|
||||
@@ -64,7 +65,7 @@ func reset_gait():
|
||||
if gait.initialized:gait.reset()
|
||||
|
||||
func _process(delta):
|
||||
if game and game.paused:return
|
||||
if game and game.paused and not cinematic_idle:return
|
||||
var dt=minf(delta,.05)
|
||||
restore_animation_pose()
|
||||
animator.advance(dt)
|
||||
|
||||
Reference in New Issue
Block a user