generated from krampus/template-godot4
Some checks failed
linting & formatting / build (push) Failing after 32s
itch.io publish action / build (linux64, x86_64) (push) Successful in 2m22s
itch.io publish action / build (osx, app) (push) Successful in 2m24s
itch.io publish action / build (win64, exe) (push) Successful in 2m30s
26 lines
932 B
GDScript
26 lines
932 B
GDScript
class_name LoadingTools
|
|
## Utilities for loading game states
|
|
|
|
const WORLD_SCENE := "res://src/world/world.tscn"
|
|
|
|
|
|
static func _load_world(level: PackedScene, save: SaveState = null) -> void:
|
|
var finish_load := func(world: World) -> void:
|
|
world.save_state = save
|
|
world.initial_level = level
|
|
|
|
print_debug("Loading world")
|
|
Game.instance.queue_scene(WORLD_SCENE).then(finish_load)
|
|
|
|
|
|
static func load_level(level_path: String, save: SaveState = null) -> void:
|
|
print_debug("Loading level from ", level_path)
|
|
var chain_load := func(level: PackedScene) -> void: LoadingTools._load_world(level, save)
|
|
Game.instance.queue_load(level_path).then(chain_load)
|
|
|
|
|
|
static func load_save(save_path: String) -> void:
|
|
print_debug("Loading save from ", save_path)
|
|
var chain_load := func(save: SaveState) -> void: load_level(save.level_path, save)
|
|
Game.instance.queue_load(save_path, ResourceLoader.CACHE_MODE_REPLACE_DEEP).then(chain_load)
|