Overworld map loading
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user