Prepping cooking

This commit is contained in:
2026-01-15 17:28:39 -06:00
parent 098a9d47f9
commit 3b7de160dc
27 changed files with 151 additions and 19 deletions

32
scene/Load.gd Normal file
View File

@@ -0,0 +1,32 @@
class_name LoadSingleton extends Node
signal loadStart(scenePath:String, loadId:int)
signal loadEnd(scenePath:String, loadId:int, resource:Resource)
signal loadError(scenePath:String, loadId:int, error:String)
signal loadProgress(scenePath:String, loadId:int, progress:float)
var watchingIds:Array[int] = []
func _process(delta: float) -> void:
var wIds = watchingIds.duplicate()
for watchId in wIds:
var status = ResourceLoader.load_threaded_get_status(watchId)
if status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_LOADED:
watchingIds.erase(watchId)
var resource = ResourceLoader.load_threaded_get(watchId)
loadEnd.emit(watchId, resource)
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_FAILED:
watchingIds.erase(watchId)
loadError.emit(watchId, "Error loading resource.")
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_INVALID_RESOURCE:
watchingIds.erase(watchId)
loadError.emit(watchId, "Invalid Resource.")
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_IN_PROGRESS:
loadProgress.emit(watchId, 0.0)
pass
func load(scenePath:String) -> int:
var loadId = ResourceLoader.load_threaded_request(scenePath)
watchingIds.append(loadId)
loadStart.emit(scenePath, loadId)
return loadId