extends Control

@export var visible_ui: Control
@export var animation_fade_in: AnimationPlayer
@export_file var restart_scene: String :
	set(value):
		if value == null:
			return
		
		restart_scene = value

func _ready() -> void:
	# Game Over Screen is hidden at the beginning
	visible_ui.hide()
	GameManager.GameLost.connect(_on_game_over);

func _exit_tree() -> void:
	GameManager.GameLost.disconnect(_on_game_over);

func _on_game_over():
	# Call this function when a signal game_over is emitted to show the Game Over Screen
	visible_ui.show()
	animation_fade_in.play("show")
	

func _on_restart_game_button_pressed() -> void:
	get_tree().change_scene_to_file(restart_scene)
