Overworld map loading

This commit is contained in:
YourWishes committed 2025-05-08 22:18:05 -05:00
1 parent 703f70bcf0
commit 50ee75e997
13 files changed
+72 -21

No files matched your search

+24
View File
@@ -1 +1,25 @@
class_name OverworldScene extends Node3D
func _ready() -> void:
_updateMap()
OVERWORLD.mapChanged.connect(_onMapChanged)
func _exit_tree() -> void:
OVERWORLD.mapChanged.disconnect(_onMapChanged)
func _updateMap() -> void:
# Remove all children
for child in $Map.get_children():
child.queue_free()
$Map.remove_child(child)
# Load the new map
if not OVERWORLD.MAPS.has(OVERWORLD.currentMap):
return
var map = load(OVERWORLD.MAPS[OVERWORLD.currentMap])
var mapInstance = map.instantiate()
$Map.add_child(mapInstance)
func _onMapChanged(mapHandle:String, mapScene:String) -> void:
_updateMap()