Refactoring

This commit is contained in:
2026-01-07 22:09:56 -06:00
parent fff088a0a7
commit b7716201d8
62 changed files with 110 additions and 78 deletions

View File

@@ -1,3 +0,0 @@
class_name GamePhysicsSingleton extends Node
const GRAVITY = Vector3.DOWN * 100

View File

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

View File

@@ -1,85 +0,0 @@
class_name OverworldSingleton extends Node
signal mapChanged(map:PackedScene, playerDestinationNodeName:String)
var newMapPath:String
var hasFadedOut:bool = false
var playerDestinationNodeName:String
var newMapLoaded:bool = false
func isMapChanging() -> bool:
return newMapPath != ""
func _enter_tree() -> void:
pass
func _exit_tree() -> void:
TRANSITION.fadeOutEnd.disconnect(onFadeOutEnd)
TRANSITION.fadeInEnd.disconnect(onFadeInEnd)
func _process(_delta:float) -> void:
if(!isMapChanging()):
return
var status = ResourceLoader.load_threaded_get_status(newMapPath)
if status == ResourceLoader.THREAD_LOAD_FAILED:
push_error("Failed to load map: " + newMapPath)
newMapPath = ""
elif status == ResourceLoader.THREAD_LOAD_INVALID_RESOURCE:
push_error("Failed to load map: " + newMapPath)
newMapPath = ""
elif status == ResourceLoader.THREAD_LOAD_IN_PROGRESS:
print("Map loading in progress for: " + newMapPath)
elif status == ResourceLoader.THREAD_LOAD_LOADED:
newMapLoaded = true
newMapReady()
func mapChange(map:String, playerDestinationNodeName:String) -> void:
# Begin Loading new map
newMapPath = map
playerDestinationNodeName = playerDestinationNodeName
ResourceLoader.load_threaded_request(newMapPath)
# Begin fadeout
hasFadedOut = false
TRANSITION.fade(TransitionSingleton.FadeType.FADE_OUT)
TRANSITION.fadeOutEnd.connect(onFadeOutEnd)
func onFadeOutEnd() -> void:
# Fade out has occurred, are we still waiting for the map to load?
TRANSITION.fadeOutEnd.disconnect(onFadeOutEnd)
hasFadedOut = true
# Make sure we aren't still waiting for the map to load.
if !newMapLoaded:
return
newMapReady()
func newMapReady():
if !hasFadedOut:
return
# Instantiate the new map
var mapResource = ResourceLoader.load_threaded_get(newMapPath)
if mapResource == null:
push_error("Failed to load map resource: " + newMapPath)
return
# Stop tracking new map name
newMapPath = ""
# Emit event
mapChanged.emit(mapResource, playerDestinationNodeName)
# Begin Fade In
TRANSITION.fade(TransitionSingleton.FadeType.FADE_IN)
TRANSITION.fadeInEnd.connect(onFadeInEnd)
func onFadeInEnd() -> void:
TRANSITION.fadeInEnd.disconnect(onFadeInEnd)

View File

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

View File

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

View File

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

View File

@@ -1,7 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://dodd3jx81w40c"]
[ext_resource type="Script" uid="uid://cd4lf5sm2aquv" path="res://singleton/Quest.gd" id="1_u2r0s"]
[node name="Quest" type="Node"]
script = ExtResource("1_u2r0s")
metadata/_custom_type_script = "uid://cd4lf5sm2aquv"

View File

@@ -1,19 +0,0 @@
class_name SceneSingleton extends Node
enum SceneType {
UNSET,
INITIAL,
OVERWORLD
}
var currentScene:SceneType = SceneType.UNSET
signal sceneChanged(newScene:SceneType)
func _enter_tree() -> void:
currentScene = SceneType.UNSET
func setScene(newScene:SceneType) -> void:
if currentScene == newScene:
return
currentScene = newScene
sceneChanged.emit(currentScene)

View File

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

View File

@@ -1,4 +0,0 @@
class_name UISingleton extends Control
@export var TEXTBOX: VNTextbox
@export var PAUSE: PauseMenu

View File

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

View File

@@ -1,23 +0,0 @@
[gd_scene load_steps=4 format=3 uid="uid://baos0arpiskbp"]
[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://ui/component/VNTextbox.tscn" id="1_1mtk3"]
[ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://singleton/UI.gd" id="1_son71"]
[ext_resource type="PackedScene" uid="uid://c0i5e2dj11d8c" path="res://ui/pause/PauseMenu.tscn" id="2_atyu8"]
[node name="UI" type="Control" node_paths=PackedStringArray("TEXTBOX", "PAUSE")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_son71")
TEXTBOX = NodePath("VNTextbox")
PAUSE = NodePath("PauseMenu")
[node name="PauseMenu" parent="." instance=ExtResource("2_atyu8")]
layout_mode = 1
[node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")]
visible = false
layout_mode = 1