class_name LevelLoader
extends Node

@export
var current_level: Node

@export
var start_menu: PackedScene

func _ready() -> void:
	Globals.levelLoader = self
	load_level(start_menu)


func load_level(level: PackedScene):
	var children = current_level.get_children()
	for child in children:
		child.queue_free()
	
	await get_tree().process_frame

	current_level.add_child(level.instantiate())
