Prepping for other scenes.
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
class_name OverworldScene extends Node
|
||||
|
||||
@export var map:Node3D = null
|
||||
|
||||
func _enter_tree() -> void:
|
||||
OVERWORLD.mapChanged.connect(onMapChanged)
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _exit_tree() -> void:
|
||||
OVERWORLD.mapChanged.disconnect(onMapChanged)
|
||||
|
||||
func onMapChanged(newMap:PackedScene, playerDestinationNodeName:String) -> void:
|
||||
print("New map time.", newMap)
|
||||
for childScene in map.get_children():
|
||||
map.remove_child(childScene)
|
||||
|
||||
if !newMap:
|
||||
return
|
||||
|
||||
var newMapInstance = newMap.instantiate()
|
||||
map.add_child(newMapInstance)
|
||||
|
||||
# Find Player.
|
||||
# if playerDestinationNodeName:
|
||||
# var player = newMapInstance.get_node("Player")
|
||||
# var destNode = newMapInstance.get_node(playerDestinationNodeName)
|
||||
# if player && player is Player && destNode:
|
||||
# player.global_position = destNode.global_position
|
||||
# player.global_rotation.y = destNode.global_rotation.y
|
||||
# elif playerDestinationNodeName:
|
||||
# push_error("Player, or destination node not found in new map.")
|
||||
# pass
|
||||
@@ -1 +0,0 @@
|
||||
uid://dpvccegdmn7s6
|
||||
@@ -1,9 +0,0 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c0k1t3tyiaojl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dpvccegdmn7s6" path="res://scene/OverworldScene.gd" id="1_fa54r"]
|
||||
|
||||
[node name="OverworldScene" type="Node3D" node_paths=PackedStringArray("map")]
|
||||
script = ExtResource("1_fa54r")
|
||||
map = NodePath("Map")
|
||||
|
||||
[node name="Map" type="Node3D" parent="."]
|
||||
@@ -2,6 +2,8 @@ class_name RootScene extends Node3D
|
||||
|
||||
@export var overworld:Node3D = null
|
||||
@export var initial:Node3D = null
|
||||
@export var battle:Node3D = null
|
||||
@export var cooking:Node3D = null
|
||||
|
||||
func _enter_tree() -> void:
|
||||
SCENE.sceneChanged.connect(onSceneChange)
|
||||
@@ -12,7 +14,8 @@ func _exit_tree() -> void:
|
||||
|
||||
func onSceneChange(newScene:SceneSingleton.SceneType) -> void:
|
||||
print("overworld", overworld)
|
||||
remove_child(overworld)
|
||||
if overworld && overworld.get_parent() == self:
|
||||
remove_child(overworld)
|
||||
remove_child(initial)
|
||||
|
||||
overworld.visible = false
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://ckkewlcugc8ro"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://ckkewlcugc8ro"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ml70iui7qpo4" path="res://scene/RootScene.gd" id="1_nky1x"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy54m7dvjgqta" path="res://battle/BattleScene.tscn" id="2_0idls"]
|
||||
[ext_resource type="PackedScene" uid="uid://bs41nqi3ocih3" path="res://scene/InitialScene.tscn" id="2_hkmoa"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0k1t3tyiaojl" path="res://scene/OverworldScene.tscn" id="2_o1wvd"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0k1t3tyiaojl" path="res://overworld/OverworldScene.tscn" id="2_o1wvd"]
|
||||
[ext_resource type="PackedScene" uid="uid://cxkd4frxvt873" path="res://cooking/CookingScene.tscn" id="5_aj1eq"]
|
||||
|
||||
[node name="RootScene" type="Node3D" node_paths=PackedStringArray("overworld", "initial")]
|
||||
[node name="RootScene" type="Node3D" node_paths=PackedStringArray("overworld", "initial", "battle", "cooking")]
|
||||
script = ExtResource("1_nky1x")
|
||||
overworld = NodePath("OverworldScene")
|
||||
initial = NodePath("InitialScene")
|
||||
battle = NodePath("BattleScene")
|
||||
cooking = NodePath("CookingScene")
|
||||
metadata/_custom_type_script = "uid://ml70iui7qpo4"
|
||||
|
||||
[node name="InitialScene" parent="." instance=ExtResource("2_hkmoa")]
|
||||
|
||||
[node name="BattleScene" parent="." instance=ExtResource("2_0idls")]
|
||||
|
||||
[node name="OverworldScene" parent="." instance=ExtResource("2_o1wvd")]
|
||||
|
||||
[node name="InitialScene" parent="." instance=ExtResource("2_hkmoa")]
|
||||
[node name="CookingScene" parent="." instance=ExtResource("5_aj1eq")]
|
||||
|
||||
@@ -3,7 +3,9 @@ class_name SceneSingleton extends Node
|
||||
enum SceneType {
|
||||
UNSET,
|
||||
INITIAL,
|
||||
OVERWORLD
|
||||
OVERWORLD,
|
||||
BATTLE,
|
||||
COOKING
|
||||
}
|
||||
|
||||
var currentScene:SceneType = SceneType.UNSET
|
||||
|
||||
Reference in New Issue
Block a user