extends Area2D

var planetTwo = preload("res://planets/planetTwo/planetTwo.tscn")
var activated: bool = false

func _ready() -> void:
	var scoreBar = get_tree().root.find_child("ProgressBar", true, false)
	scoreBar.connect("complete", Callable(self, "levelComplete"))

func levelComplete():
	activated = true
	print("exit active")

signal playerExit

func _on_body_entered(body: Node2D) -> void:
	if activated:
		emit_signal("playerExit")
		await get_tree().create_timer(2).timeout
		get_tree().change_scene_to_packed(planetTwo)
