26 lines
614 B
GDScript
26 lines
614 B
GDScript
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()
|