class_name LoadingScreen
extends MenuBase

var _interactive_loader: InteractiveLoader

@onready var progress_bar: ProgressBar = %ProgressBar


func _process(_delta: float) -> void:
	if is_instance_valid(_interactive_loader) and not _interactive_loader.load_progress.is_empty():
		progress_bar.value = _interactive_loader.load_progress.front()


func load_scene(path: String) -> PackedScene:
	_interactive_loader = InteractiveLoader.new()
	add_child(_interactive_loader)
	var resource: Object = await _interactive_loader.load_threaded(path)
	_interactive_loader.queue_free()
	return resource
