107 lines
2.6 KiB
GDScript
107 lines
2.6 KiB
GDScript
class_name YouthRoom
|
|
extends RoomTemplate
|
|
|
|
## Used by the room system when this room becomes active
|
|
# var is_active: bool = false # Reminder, do not uncomment, this field is inherited from RoomTemplate!
|
|
|
|
@onready var board_trigger: InteractiveSprite = %MindBoard
|
|
@onready var door_trigger: InteractiveSprite = %Door
|
|
@onready var card_picker: CardPicker = %Picker
|
|
@onready var ui: Control = %UI
|
|
|
|
# Is populated by child cardboard instead of onready.
|
|
var card_board: CardBoard
|
|
|
|
func start_room():
|
|
%UI.show()
|
|
$logic/PlayerController.process_mode = Node.PROCESS_MODE_INHERIT
|
|
|
|
if not Scenes.is_sequence_repeating(Scenes.id.YOUTH_DRAVEN):
|
|
# Play intro scene directly (not triggered by CollectableUi)
|
|
await _play_intro_scene()
|
|
else:
|
|
%LightAnimation.lights_on()
|
|
|
|
# Give player control after intro (or immediately if repeating)
|
|
Scenes.player_enable.emit(true)
|
|
|
|
|
|
func _play_intro_scene() -> void:
|
|
# FIXME: Must instead use the actual interactable
|
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
|
|
|
|
# The intro scene is auto-played, not triggered by CollectableUi
|
|
var intro: InteractiveSprite = $logic/CeilingMemento
|
|
|
|
# Play the story (StoryPlayable handles its own visibility via animations)
|
|
await intro.play_story()
|
|
|
|
Scenes.end_sequence(Scenes.id.YOUTH_DRAVEN)
|
|
|
|
|
|
|
|
func get_ready():
|
|
await get_tree().process_frame
|
|
|
|
pull_save_state(State.save_game)
|
|
|
|
card_board.board_completed.connect(func():
|
|
save_game.is_childhood_board_complete = true
|
|
save_room())
|
|
|
|
card_picker.cards_picked.connect(card_board.populate_board)
|
|
|
|
ui.hide()
|
|
$sfx/distant_rain.play()
|
|
$"sfx/rain on window".play()
|
|
|
|
await get_tree().process_frame
|
|
|
|
|
|
func _ready():
|
|
printt(_ready, name)
|
|
super._ready()
|
|
id = State.rooms.YOUTH
|
|
Scenes.scene_finished.connect(_on_scene_finished)
|
|
|
|
|
|
|
|
func pull_save_state(save: SaveGame) -> void:
|
|
save_game = save
|
|
save_game.current_room = id
|
|
save_game.board_state = card_board.get_save_dict()
|
|
card_board.initialise_from_save(save_game)
|
|
|
|
Scenes.started_sequences = save_game.mementos_complete
|
|
Scenes.completed_sequences = save_game.mementos_complete
|
|
|
|
|
|
func _on_scene_finished(_id: int, _repeat:bool):
|
|
await get_tree().create_timer(3).timeout
|
|
save_room()
|
|
|
|
|
|
func prepare_transition():
|
|
save_room()
|
|
$visuals/AnimationPlayer.play("conserve_performance")
|
|
await $visuals/AnimationPlayer.animation_finished
|
|
unload()
|
|
|
|
|
|
# Called by youth_room_scene_player when voice training scene starts
|
|
func play_chest_reveal() -> void:
|
|
$AnimationPlayer.play("chest_reveal")
|
|
$visuals/SecondaryAnimation.play("chest_reveal")
|
|
|
|
|
|
func unload():
|
|
$visuals.queue_free()
|
|
|
|
|
|
func play_chest_animation(_id):
|
|
$AnimationPlayer.play("intro")
|
|
await $AnimationPlayer.animation_finished
|