extends Control

@onready var sceneName
@onready var scene_load_status : float = 0
@onready var progress = []
@onready var progressBar = $TextureProgressBar


func _ready():
	sceneName = SceneSwitcher.new_scene
	ResourceLoader.load_threaded_request(sceneName)


func _process(_delta):
	scene_load_status = ResourceLoader.load_threaded_get_status(sceneName,progress)
	progressBar.value = lerp(progressBar.value,progress[0]*100,0.25)
	#print(progressBar.value)
	if scene_load_status == ResourceLoader.THREAD_LOAD_LOADED and progressBar.value >= 99:
		var newScene = ResourceLoader.load_threaded_get(sceneName)
		get_tree().change_scene_to_packed(newScene)
		
