Overworld map loading

This commit is contained in:
2025-05-08 22:18:05 -05:00
parent 703f70bcf0
commit 50ee75e997
13 changed files with 72 additions and 21 deletions

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()

View File

@@ -0,0 +1 @@
class_name LoadManager extends Node

View File

@@ -0,0 +1 @@
uid://whqkvjhckgb0

View File

@@ -1,13 +1,16 @@
extends Node
const MAPS:Dictionary[String, String] = {
"TestMap": "res://scenes/Maps/TestMap.tscn"
"TestMap": "res://scenes/Maps/TestMap/TestMap.tscn"
};
var currentMap:String = "";
signal mapChanged(mapHandle:String, mapScene:String);
func setMap(map:String) -> void:
if MAPS.has(map):
currentMap = map
else:
push_error("Map not found: " + map)
assert(MAPS.has(map), "Map not found: " + map)
if currentMap == map:
return
currentMap = map
mapChanged.emit(map, MAPS[map])

View File

@@ -16,6 +16,14 @@ func _ready() -> void:
$OverworldOption/MapDropdown.add_item(map, i);
i = i + 1;
func _exit_tree() -> void:
$MainMenu.disconnect("pressed", _on_MainMenu_pressed);
$OverworldOption/Overworld.disconnect("pressed", _on_Overworld_pressed);
$Quests.disconnect("pressed", _on_Quests_pressed);
$Cutscene.disconnect("pressed", _on_Custscene_pressed);
$Cooking.disconnect("pressed", _on_Cooking_pressed);
$Battle.disconnect("pressed", _on_Battle_pressed);
func _process(delta: float) -> void:
if Input.is_action_just_pressed("debug"):
print("Debug key pressed")

View File

@@ -23,6 +23,11 @@ func _ready() -> void:
questObjectiveList.item_selected.connect(_onQuestObjectiveSelected)
QUEST.questUpdated.connect(_onQuestUpdated)
func _exit_tree() -> void:
questList.item_selected.disconnect(_onQuestSelected)
closeButton.pressed.disconnect(_onCloseClicked)
questObjectiveList.item_selected.disconnect(_onQuestObjectiveSelected)
QUEST.questUpdated.disconnect(_onQuestUpdated)
func setQuest(questKey = null):
if questKey == null || questKey == -1: