2025-12-12 23:22:21 +00:00
|
|
|
class_name YouthRoom
|
2024-10-06 09:38:15 +00:00
|
|
|
extends RoomTemplate
|
2023-03-26 22:29:25 +00:00
|
|
|
|
2026-01-12 17:39:34 +00:00
|
|
|
## 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!
|
2026-01-05 15:04:59 +00:00
|
|
|
|
2024-10-06 09:38:15 +00:00
|
|
|
@onready var card_picker: CardPicker = %Picker
|
2025-12-16 22:21:54 +00:00
|
|
|
@onready var ui: Control = %UI
|
|
|
|
|
|
2024-10-18 16:10:51 +00:00
|
|
|
func start_room():
|
2025-12-15 22:13:40 +00:00
|
|
|
%UI.show()
|
2024-10-06 09:38:15 +00:00
|
|
|
$logic/PlayerController.process_mode = Node.PROCESS_MODE_INHERIT
|
2026-01-05 20:39:16 +00:00
|
|
|
|
2026-01-18 20:53:19 +00:00
|
|
|
await Main.curtain.open()
|
|
|
|
|
|
2026-01-11 21:09:19 +00:00
|
|
|
if not Scenes.is_sequence_repeating(Scenes.id.YOUTH_DRAVEN):
|
2026-01-05 15:04:59 +00:00
|
|
|
# Play intro scene directly (not triggered by CollectableUi)
|
|
|
|
|
await _play_intro_scene()
|
2025-03-25 21:34:13 +00:00
|
|
|
else:
|
2025-10-29 21:48:41 +00:00
|
|
|
%LightAnimation.lights_on()
|
2026-01-05 20:39:16 +00:00
|
|
|
|
2026-01-05 15:28:45 +00:00
|
|
|
# Give player control after intro (or immediately if repeating)
|
2026-01-12 17:39:34 +00:00
|
|
|
Scenes.player_enable.emit(true)
|
2023-07-19 20:43:00 +00:00
|
|
|
|
2026-01-05 15:04:59 +00:00
|
|
|
|
|
|
|
|
func _play_intro_scene() -> void:
|
2026-01-10 11:33:27 +00:00
|
|
|
# The intro scene is auto-played, not triggered by CollectableUi
|
2026-01-16 15:30:58 +00:00
|
|
|
var intro: Interactable = $logic/CeilingInteractable
|
2026-01-10 11:33:27 +00:00
|
|
|
await intro.play_story()
|
2026-01-05 20:39:16 +00:00
|
|
|
|
2026-01-11 21:09:19 +00:00
|
|
|
Scenes.end_sequence(Scenes.id.YOUTH_DRAVEN)
|
2025-12-19 15:00:49 +00:00
|
|
|
|
|
|
|
|
|
2025-12-16 22:21:54 +00:00
|
|
|
|
2023-07-19 20:43:00 +00:00
|
|
|
func get_ready():
|
2026-01-12 21:35:12 +00:00
|
|
|
await get_tree().process_frame
|
|
|
|
|
|
2025-12-16 22:21:54 +00:00
|
|
|
pull_save_state(State.save_game)
|
2025-12-19 14:11:31 +00:00
|
|
|
|
2025-12-15 22:13:40 +00:00
|
|
|
card_board.board_completed.connect(func():
|
|
|
|
|
save_game.is_childhood_board_complete = true
|
|
|
|
|
save_room())
|
2026-01-16 15:30:58 +00:00
|
|
|
|
2026-01-16 12:59:09 +00:00
|
|
|
card_board.closed.connect(save_room)
|
2025-12-15 22:13:40 +00:00
|
|
|
|
2026-01-12 21:35:12 +00:00
|
|
|
card_picker.cards_picked.connect(card_board.populate_board)
|
2025-12-16 22:21:54 +00:00
|
|
|
|
|
|
|
|
ui.hide()
|
2025-03-25 21:34:13 +00:00
|
|
|
$sfx/distant_rain.play()
|
|
|
|
|
$"sfx/rain on window".play()
|
2026-01-12 21:35:12 +00:00
|
|
|
|
|
|
|
|
await get_tree().process_frame
|
2023-12-02 16:37:42 +00:00
|
|
|
|
2025-12-16 22:21:54 +00:00
|
|
|
|
2023-12-02 16:37:42 +00:00
|
|
|
func _ready():
|
2026-01-12 21:35:12 +00:00
|
|
|
printt(_ready, name)
|
2025-12-12 23:22:21 +00:00
|
|
|
super._ready()
|
2025-12-15 22:13:40 +00:00
|
|
|
id = State.rooms.YOUTH
|
2025-02-06 17:55:05 +00:00
|
|
|
Scenes.scene_finished.connect(_on_scene_finished)
|
2026-01-12 21:35:12 +00:00
|
|
|
|
2024-10-06 09:38:15 +00:00
|
|
|
|
2025-12-16 22:21:54 +00:00
|
|
|
|
2024-10-06 09:38:15 +00:00
|
|
|
func pull_save_state(save: SaveGame) -> void:
|
2025-12-16 22:21:54 +00:00
|
|
|
save_game = save
|
|
|
|
|
save_game.current_room = id
|
2026-01-16 15:30:58 +00:00
|
|
|
|
2026-01-16 12:03:39 +00:00
|
|
|
# Load board state from save first, before overwriting it
|
2025-12-16 22:21:54 +00:00
|
|
|
card_board.initialise_from_save(save_game)
|
2025-12-19 14:11:31 +00:00
|
|
|
|
2025-12-16 22:21:54 +00:00
|
|
|
Scenes.started_sequences = save_game.mementos_complete
|
|
|
|
|
Scenes.completed_sequences = save_game.mementos_complete
|
2026-01-16 15:30:58 +00:00
|
|
|
|
2026-01-16 12:03:39 +00:00
|
|
|
# Call parent to restore player position
|
|
|
|
|
super.pull_save_state(save)
|
2025-12-16 22:21:54 +00:00
|
|
|
|
2024-10-06 09:38:15 +00:00
|
|
|
|
2025-12-02 20:35:19 +00:00
|
|
|
func _on_scene_finished(_id: int, _repeat:bool):
|
2025-03-25 21:34:13 +00:00
|
|
|
await get_tree().create_timer(3).timeout
|
2024-10-06 09:38:15 +00:00
|
|
|
save_room()
|
2025-06-03 21:17:29 +00:00
|
|
|
|
2026-01-16 12:03:39 +00:00
|
|
|
func save_room():
|
|
|
|
|
# Update board state before saving
|
2026-01-16 12:59:09 +00:00
|
|
|
card_board.save_to_resource(save_game)
|
2026-01-16 12:03:39 +00:00
|
|
|
save_game.mementos_complete = Scenes.completed_sequences
|
|
|
|
|
super.save_room()
|
2025-12-16 22:21:54 +00:00
|
|
|
|
2025-06-03 21:17:29 +00:00
|
|
|
func prepare_transition():
|
|
|
|
|
save_room()
|
2025-12-16 22:21:54 +00:00
|
|
|
$visuals/AnimationPlayer.play("conserve_performance")
|
|
|
|
|
await $visuals/AnimationPlayer.animation_finished
|
2025-10-29 21:48:41 +00:00
|
|
|
unload()
|
2025-06-03 21:17:29 +00:00
|
|
|
|
2025-12-16 22:21:54 +00:00
|
|
|
|
2026-01-16 20:13:27 +00:00
|
|
|
## Override to handle scene-specific preparation (chest reveal animation)
|
|
|
|
|
func prepare_scene_start(scene_id: Scenes.id, is_repeating: bool) -> void:
|
|
|
|
|
# Only play chest reveal on first playthrough of voice training scene
|
|
|
|
|
if scene_id == Scenes.id.YOUTH_VOICE_TRAINING and not is_repeating:
|
|
|
|
|
await play_chest_reveal()
|
|
|
|
|
|
|
|
|
|
# Called when voice training scene starts
|
2026-01-05 15:04:59 +00:00
|
|
|
func play_chest_reveal() -> void:
|
2026-01-16 20:13:27 +00:00
|
|
|
$visuals/AnimationPlayer.play("chest_reveal")
|
2025-12-19 14:11:31 +00:00
|
|
|
$visuals/SecondaryAnimation.play("chest_reveal")
|
2026-01-15 20:40:00 +00:00
|
|
|
await $visuals/SecondaryAnimation.animation_finished
|
2025-12-16 22:21:54 +00:00
|
|
|
|
|
|
|
|
|
2025-06-03 21:17:29 +00:00
|
|
|
func unload():
|
|
|
|
|
$visuals.queue_free()
|