monsterfangen/globals/scene_manager.gd

25 lines
607 B
GDScript

extends Node
@onready var scene_root: Node3D = $/root/Game/CurrentScene
var current_world : Node = null
func get_world() -> String:
return current_world.scene_file_path
func set_world(path: String) -> void:
if ResourceLoader.exists(path):
var world: Node = load(path).instantiate()
scene_root.add_child(world)
current_world = world
else:
printerr("Level %s does not exist" % path)
func remove_world() -> void:
var world: Node3D = scene_root.get_child(0)
if world == null:
printerr("No world node found")
return
scene_root.remove_child(world)
world.queue_free()
current_world = null