frame-of-mind/src/base-environments/transition/code/dolly.gd

61 lines
1.8 KiB
GDScript3
Raw Normal View History

2026-01-20 11:37:17 +00:00
## A dolly tweens all contents to and from two destination points, and to its origin.
class_name Dolly
extends Node3D
2026-01-20 17:35:37 +00:00
@export var pre_arrival_time : float = 17.0
2026-01-20 16:23:11 +00:00
@export var arrival_time : float = 15.0
2026-01-20 17:18:10 +00:00
@export var pre_leave_time : float = 20.0
2026-01-20 17:35:37 +00:00
@export var door_close_time : float = 1.0
2026-01-20 16:23:11 +00:00
@export var leave_time : float = 16.0
@export var post_leave_time : float = 5.0
2026-01-20 11:37:17 +00:00
@onready var origination : Node3D = $Origination
@onready var destination : Node3D = $Destination
2026-01-20 16:23:11 +00:00
@onready var subway : SubwayTrain = %Subway
2026-01-20 11:37:17 +00:00
var tween : Tween = null
func _ready() -> void:
2026-01-20 17:35:37 +00:00
for child in get_children(true):
if not child.visible: continue
child.global_position = origination.global_position
2026-01-20 11:37:17 +00:00
2026-01-20 17:18:10 +00:00
## One arrival and departure
func cycle() -> void:
await arrive()
await leave()
2026-01-20 11:37:17 +00:00
func arrive() -> void:
2026-01-20 16:23:11 +00:00
%SubwayTrainAudio.play(0)
2026-01-20 19:01:59 +00:00
%SubwayTrainAudioIntense.play(0)
2026-01-20 17:35:37 +00:00
await get_tree().create_timer(pre_arrival_time).timeout
2026-01-20 11:37:17 +00:00
if tween: tween.kill()
tween = create_tween().set_trans(Tween.TRANS_CIRC).set_ease(Tween.EASE_OUT)
for child in get_children(true):
if not child.visible: continue
tween.parallel().tween_property(child, "global_position", self.global_position, arrival_time)
2026-01-20 16:23:11 +00:00
await tween.finished
subway.door_open = true
2026-01-20 11:37:17 +00:00
func leave() -> void:
2026-01-20 16:23:11 +00:00
await get_tree().create_timer(pre_leave_time).timeout
2026-01-20 17:18:10 +00:00
subway.door_open = false
2026-01-20 17:35:37 +00:00
await get_tree().create_timer(door_close_time).timeout
2026-01-20 17:18:10 +00:00
if tween: tween.kill()
2026-01-20 11:37:17 +00:00
tween = create_tween().set_trans(Tween.TRANS_QUART).set_ease(Tween.EASE_IN)
for child in get_children(true):
if not child.visible: continue
tween.parallel().tween_property(child, "global_position", destination.global_position, leave_time)
2026-01-20 16:23:11 +00:00
await tween.finished
await %SubwayTrainAudio.finished
for child in get_children(true):
if not child.visible: continue
# Warp back
child.global_position = origination.global_position