2023-12-02 16:37:42 +00:00
|
|
|
extends Node3D
|
|
|
|
|
|
2024-10-18 15:31:46 +00:00
|
|
|
signal room_loaded
|
|
|
|
|
|
|
|
|
|
var has_stage: bool = false:
|
|
|
|
|
set(stage):
|
|
|
|
|
has_stage = stage
|
|
|
|
|
if in_game and has_stage:
|
|
|
|
|
in_game = false
|
|
|
|
|
_return_to_menu()
|
|
|
|
|
|
2024-10-01 23:30:03 +00:00
|
|
|
@export_file(".tscn") var youth_room_path: String
|
2024-10-16 10:29:20 +00:00
|
|
|
@export_file(".tscn") var transition_room_path: String
|
|
|
|
|
@export_file(".tscn") var adulthood_room_path: String
|
|
|
|
|
@export_file(".tscn") var ending_path: String
|
2024-10-01 23:30:03 +00:00
|
|
|
|
2024-10-18 15:31:46 +00:00
|
|
|
@onready var main_menu:MainMenu = %"Main Menu"
|
2024-10-07 09:21:36 +00:00
|
|
|
@onready var menu_animation: AnimationTree = %MenuAnimationTree
|
|
|
|
|
@onready var focus_forward = %"Main Menu"
|
|
|
|
|
|
2024-10-18 15:31:46 +00:00
|
|
|
var current_room_id: State.rooms
|
|
|
|
|
|
2024-10-07 09:21:36 +00:00
|
|
|
var in_game = false
|
2024-10-01 23:30:03 +00:00
|
|
|
|
|
|
|
|
var current_loaded_room: Node3D
|
|
|
|
|
var currently_loading_room: String = "":
|
|
|
|
|
set(path):
|
|
|
|
|
if path != "":
|
|
|
|
|
ResourceLoader.load_threaded_request(path, "PackedScene")
|
2024-10-07 09:21:36 +00:00
|
|
|
menu_animation["parameters/conditions/loading_done"] = false
|
|
|
|
|
menu_animation["parameters/conditions/load_save"] = true
|
2024-10-01 23:30:03 +00:00
|
|
|
currently_loading_room = path
|
2024-10-06 09:40:42 +00:00
|
|
|
|
2024-10-01 23:30:03 +00:00
|
|
|
else:
|
2024-10-07 09:21:36 +00:00
|
|
|
menu_animation["parameters/conditions/loading_done"] = true
|
|
|
|
|
menu_animation["parameters/conditions/load_save"] = false
|
2023-12-02 16:37:42 +00:00
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready():
|
2024-10-01 23:30:03 +00:00
|
|
|
currently_loading_room = youth_room_path
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
|
if currently_loading_room != "":
|
2024-10-18 15:31:46 +00:00
|
|
|
if ResourceLoader.load_threaded_get_status(currently_loading_room) == 3:
|
2024-10-01 23:30:03 +00:00
|
|
|
current_loaded_room = ResourceLoader.load_threaded_get(youth_room_path).instantiate()
|
|
|
|
|
add_child(current_loaded_room)
|
|
|
|
|
move_child(current_loaded_room, 0)
|
|
|
|
|
currently_loading_room = ""
|
2024-10-18 15:31:46 +00:00
|
|
|
room_loaded.emit()
|
|
|
|
|
|
|
|
|
|
if Input.is_action_just_pressed("reset_demo") and (OS.has_feature("demo") or true):
|
|
|
|
|
State.stage_list = [self]
|
|
|
|
|
_return_to_menu()
|
|
|
|
|
$"Messe-Menue".show()
|
2023-12-02 16:37:42 +00:00
|
|
|
|
|
|
|
|
func debug_youth():
|
2024-09-15 09:30:31 +00:00
|
|
|
get_child(1).hide()
|
|
|
|
|
get_child(2).hide()
|
|
|
|
|
get_child(3).hide()
|
|
|
|
|
get_child(0).get_ready()
|
|
|
|
|
get_child(0).start()
|
2024-10-18 15:31:46 +00:00
|
|
|
|
|
|
|
|
func _return_to_menu():
|
|
|
|
|
State.active_save_game = null
|
|
|
|
|
|
|
|
|
|
menu_animation["parameters/conditions/start_game"] = false
|
|
|
|
|
|
|
|
|
|
State.pass_stage_to(main_menu)
|
|
|
|
|
|
|
|
|
|
currently_loading_room = get_room_path_from_id(main_menu.save_game_handle.get_most_recent_save().current_room)
|
|
|
|
|
|
|
|
|
|
menu_animation["parameters/conditions/return_to_menu"] = true
|
|
|
|
|
await(get_tree().create_timer(0.5).timeout)
|
|
|
|
|
menu_animation["parameters/conditions/return_to_menu"] = false
|
|
|
|
|
_on_ready_to_unload()
|
|
|
|
|
|
|
|
|
|
func load_save(save: SaveGame):
|
|
|
|
|
|
|
|
|
|
#if currently_loading_room != "":
|
|
|
|
|
# await(room_loaded)
|
|
|
|
|
|
|
|
|
|
if save.current_room != current_room_id:
|
|
|
|
|
# TODO Prevent race condition from appearing when save is loaded while room is still loading.
|
|
|
|
|
currently_loading_room = get_room_path_from_id(save.current_room)
|
|
|
|
|
await(room_loaded)
|
|
|
|
|
|
|
|
|
|
menu_animation["parameters/conditions/start_game"] = true
|
|
|
|
|
|
|
|
|
|
State.active_save_game = save
|
|
|
|
|
State.pass_stage_to(get_child(0))
|
|
|
|
|
|
|
|
|
|
func _on_ready_to_unload():
|
|
|
|
|
if get_child(0) is Node3D:
|
|
|
|
|
get_child(0).free()
|
|
|
|
|
|
|
|
|
|
func get_room_path_from_id(id: State.rooms) -> String:
|
|
|
|
|
match id:
|
|
|
|
|
State.rooms.YOUTH, State.rooms.MENU, State.rooms.DRAVEN:
|
|
|
|
|
return youth_room_path
|
|
|
|
|
State.rooms.TRANSITION:
|
|
|
|
|
return transition_room_path
|
|
|
|
|
State.rooms.ADULTHOOD:
|
|
|
|
|
return adulthood_room_path
|
|
|
|
|
_:
|
|
|
|
|
return ending_path
|
|
|
|
|
|
|
|
|
|
func start_demo():
|
|
|
|
|
load_save(SaveGame.new())
|
|
|
|
|
$"Messe-Menue".hide()
|
2025-01-16 16:32:58 +00:00
|
|
|
|
|
|
|
|
var last_mode := DisplayServer.WINDOW_MODE_WINDOWED
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
|
|
|
if event.is_action_pressed("toggle_fullscreen"):
|
|
|
|
|
|
|
|
|
|
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
|
|
|
|
DisplayServer.window_set_mode(last_mode)
|
|
|
|
|
else:
|
|
|
|
|
last_mode = DisplayServer.window_get_mode()
|
|
|
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|