Moving files pre-refactor
This commit is contained in:
3
singletons/GamePhysics.gd
Normal file
3
singletons/GamePhysics.gd
Normal file
@@ -0,0 +1,3 @@
|
||||
class_name GamePhysicsSingleton extends Node
|
||||
|
||||
const GRAVITY = Vector3.DOWN * 9.8
|
1
singletons/GamePhysics.gd.uid
Normal file
1
singletons/GamePhysics.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bj8jxbaikqrhf
|
1
singletons/Input.gd.uid
Normal file
1
singletons/Input.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cxx6dl53tc5ym
|
32
singletons/Load.gd
Normal file
32
singletons/Load.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
class_name LoadSingleton extends Node
|
||||
|
||||
signal loadStart(scenePath:String, loadId:int)
|
||||
signal loadEnd(scenePath:String, loadId:int, resource:Resource)
|
||||
signal loadError(scenePath:String, loadId:int, error:String)
|
||||
signal loadProgress(scenePath:String, loadId:int, progress:float)
|
||||
|
||||
var watchingIds:Array[int] = []
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var wIds = watchingIds.duplicate()
|
||||
for watchId in wIds:
|
||||
var status = ResourceLoader.load_threaded_get_status(watchId)
|
||||
if status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_LOADED:
|
||||
watchingIds.erase(watchId)
|
||||
var resource = ResourceLoader.load_threaded_get(watchId)
|
||||
loadEnd.emit(watchId, resource)
|
||||
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_FAILED:
|
||||
watchingIds.erase(watchId)
|
||||
loadError.emit(watchId, "Error loading resource.")
|
||||
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_INVALID_RESOURCE:
|
||||
watchingIds.erase(watchId)
|
||||
loadError.emit(watchId, "Invalid Resource.")
|
||||
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_IN_PROGRESS:
|
||||
loadProgress.emit(watchId, 0.0)
|
||||
pass
|
||||
|
||||
func load(scenePath:String) -> int:
|
||||
var loadId = ResourceLoader.load_threaded_request(scenePath)
|
||||
watchingIds.append(loadId)
|
||||
loadStart.emit(scenePath, loadId)
|
||||
return loadId
|
1
singletons/Load.gd.uid
Normal file
1
singletons/Load.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dfpml5awf5i35
|
6
singletons/Load.tscn
Normal file
6
singletons/Load.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c8shl8u156rfi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dfpml5awf5i35" path="res://singletons/Load.gd" id="1_a3iwn"]
|
||||
|
||||
[node name="Load" type="Node"]
|
||||
script = ExtResource("1_a3iwn")
|
34
singletons/Overworld.gd
Normal file
34
singletons/Overworld.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
class_name OverworldSingleton extends Node
|
||||
|
||||
signal mapChanged(newMap:PackedScene, playerDestinationNodeName:String)
|
||||
|
||||
var newMap:PackedScene
|
||||
var playerDestinationNodeName:String
|
||||
|
||||
func _init() -> void:
|
||||
pass
|
||||
|
||||
func _exit_tree() -> void:
|
||||
TRANSITION.fadeOutEnd.disconnect(onFadeOutEnd)
|
||||
TRANSITION.fadeInEnd.disconnect(onFadeInEnd)
|
||||
|
||||
func mapChange(map:PackedScene, playerDestinationNodeName:String) -> void:
|
||||
TRANSITION.fade(TransitionSingleton.FadeType.FADE_OUT)
|
||||
TRANSITION.fadeOutEnd.connect(onFadeOutEnd)
|
||||
newMap = map
|
||||
self.playerDestinationNodeName = playerDestinationNodeName
|
||||
|
||||
func onFadeOutEnd() -> void:
|
||||
TRANSITION.fadeOutEnd.disconnect(onFadeOutEnd)
|
||||
TRANSITION.fade(TransitionSingleton.FadeType.FADE_IN)
|
||||
TRANSITION.fadeInEnd.connect(onFadeInEnd)
|
||||
mapChanged.emit(newMap, playerDestinationNodeName)
|
||||
|
||||
|
||||
func onFadeInEnd() -> void:
|
||||
TRANSITION.fadeInEnd.disconnect(onFadeInEnd)
|
||||
newMap = null
|
||||
|
||||
func isMapChanging() -> bool:
|
||||
# If the newMap is set, then we are in the process of changing maps.
|
||||
return newMap != null
|
1
singletons/Overworld.gd.uid
Normal file
1
singletons/Overworld.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dqtt405nifbhq
|
30
singletons/Pause.gd
Normal file
30
singletons/Pause.gd
Normal file
@@ -0,0 +1,30 @@
|
||||
class_name PauseSingleton extends Node
|
||||
|
||||
var cutscenePaused:bool = false
|
||||
|
||||
func cutscenePause() -> void:
|
||||
cutscenePaused = true
|
||||
|
||||
func cutsceneResume() -> void:
|
||||
cutscenePaused = false
|
||||
|
||||
func isMovementPaused() -> bool:
|
||||
if cutscenePaused:
|
||||
return true
|
||||
|
||||
if !UI.TEXTBOX.isClosed:
|
||||
return true
|
||||
|
||||
if UI.PAUSE.isOpen():
|
||||
return true
|
||||
|
||||
if OVERWORLD.isMapChanging():
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func menuPause() -> void:
|
||||
if UI.PAUSE.isOpen():
|
||||
UI.PAUSE.close()
|
||||
else:
|
||||
UI.PAUSE.open()
|
1
singletons/Pause.gd.uid
Normal file
1
singletons/Pause.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dmm23kdp5xcx
|
1
singletons/Quest.gd
Normal file
1
singletons/Quest.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name QuestSingleton extends Node
|
1
singletons/Quest.gd.uid
Normal file
1
singletons/Quest.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cd4lf5sm2aquv
|
7
singletons/Quest.tscn
Normal file
7
singletons/Quest.tscn
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dodd3jx81w40c"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cd4lf5sm2aquv" path="res://singletons/Quest.gd" id="1_u2r0s"]
|
||||
|
||||
[node name="Quest" type="Node"]
|
||||
script = ExtResource("1_u2r0s")
|
||||
metadata/_custom_type_script = "uid://cd4lf5sm2aquv"
|
19
singletons/Scene.gd
Normal file
19
singletons/Scene.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
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)
|
1
singletons/Scene.gd.uid
Normal file
1
singletons/Scene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c5q4206r2e3m1
|
81
singletons/Transition.gd
Normal file
81
singletons/Transition.gd
Normal file
@@ -0,0 +1,81 @@
|
||||
class_name TransitionSingleton extends Control
|
||||
|
||||
enum FadeType {
|
||||
NONE,
|
||||
FADE_IN,
|
||||
FADE_OUT
|
||||
}
|
||||
|
||||
signal fadeOutStart
|
||||
signal fadeOutEnd
|
||||
signal fadeInStart
|
||||
signal fadeInEnd
|
||||
signal fadeUpdate(t:float)
|
||||
|
||||
var fadeType:FadeType = FadeType.NONE
|
||||
var fadeDuration:float = 0.4
|
||||
var fadeTime:float = 0.0
|
||||
var inFade = false
|
||||
|
||||
func _enter_tree() -> void:
|
||||
$Overlay.visible = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if fadeType == FadeType.NONE:
|
||||
return
|
||||
|
||||
fadeTime += delta
|
||||
var t:float = fadeTime / fadeDuration
|
||||
|
||||
# Get destination alpha type.
|
||||
var destAlpha:float = 0.0
|
||||
var srcAlpha:float
|
||||
if fadeType == FadeType.FADE_IN:
|
||||
srcAlpha = 1.0
|
||||
destAlpha = 0.0
|
||||
elif fadeType == FadeType.FADE_OUT:
|
||||
srcAlpha = 0.0
|
||||
destAlpha = 1.0
|
||||
|
||||
# End?
|
||||
if t >= 1.0:
|
||||
fadeUpdate.emit(1.0)
|
||||
var cFade = fadeType
|
||||
fadeType = FadeType.NONE
|
||||
$Overlay.color.a = destAlpha
|
||||
inFade = false
|
||||
|
||||
if cFade == FadeType.FADE_OUT:
|
||||
fadeOutEnd.emit()
|
||||
elif cFade == FadeType.FADE_IN:
|
||||
fadeInEnd.emit()
|
||||
|
||||
return
|
||||
|
||||
# TODO: Use curves
|
||||
$Overlay.color.a = srcAlpha + (destAlpha - srcAlpha) * t
|
||||
fadeUpdate.emit(t)
|
||||
pass
|
||||
|
||||
func fade(
|
||||
fade:FadeType = FadeType.FADE_IN,
|
||||
duration:float = 0.4,
|
||||
color:Color = Color(0, 0, 0, 1),
|
||||
):
|
||||
if inFade:
|
||||
push_error("Transition: Cannot start a new fade while another is in progress.")
|
||||
return
|
||||
|
||||
$Overlay.visible = true
|
||||
$Overlay.color = color
|
||||
fadeDuration = duration
|
||||
fadeTime = 0
|
||||
fadeType = fade
|
||||
inFade = true
|
||||
|
||||
if fade == FadeType.FADE_IN:
|
||||
fadeInStart.emit()
|
||||
$Overlay.color.a = 0
|
||||
elif fade == FadeType.FADE_OUT:
|
||||
fadeOutStart.emit()
|
||||
$Overlay.color.a = 1
|
1
singletons/Transition.gd.uid
Normal file
1
singletons/Transition.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://iu3m73wtjlho
|
20
singletons/Transition.tscn
Normal file
20
singletons/Transition.tscn
Normal file
@@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://i4ukelrrsujw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://iu3m73wtjlho" path="res://singletons/Transition.gd" id="1_isjic"]
|
||||
|
||||
[node name="Transition" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_isjic")
|
||||
|
||||
[node name="Overlay" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
4
singletons/UI.gd
Normal file
4
singletons/UI.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
class_name UISingleton extends Control
|
||||
|
||||
@export var TEXTBOX: VNTextbox
|
||||
@export var PAUSE: PauseMenu
|
1
singletons/UI.gd.uid
Normal file
1
singletons/UI.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dq3qyyayugt5l
|
24
singletons/UI.tscn
Normal file
24
singletons/UI.tscn
Normal file
@@ -0,0 +1,24 @@
|
||||
[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://singletons/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")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")]
|
||||
visible = false
|
||||
layout_mode = 1
|
Reference in New Issue
Block a user