extends Node3D

@onready var game_timer: Timer = get_node("Timer")
signal timer_updated(minutes: int, seconds: int)

func _ready():
	# Set timer to 2 minutes 30 seconds (150 seconds)
	game_timer.wait_time = 150.0
	game_timer.one_shot = true  # Timer runs once
	game_timer.start()
	
func _process(_delta):
	if game_timer.time_left > 0:
		var time_left = game_timer.time_left
		var minutes = int(time_left) / 60
		var seconds = int(time_left) % 60
		timer_updated.emit(minutes, seconds)
	else:
		print("Timer finished!")

func _on_timer_timeout() -> void:
	if game_timer.time_left == 0:
		get_tree().change_scene_to_file("res://scenes/main_menu.tscn")
