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()
|
||||
|
1
scripts/Singleton/Load.gd
Normal file
1
scripts/Singleton/Load.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name LoadManager extends Node
|
1
scripts/Singleton/Load.gd.uid
Normal file
1
scripts/Singleton/Load.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://whqkvjhckgb0
|
@@ -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])
|
@@ -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")
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user