From f767dbf9661e072a107942829c54e55e0befb6c2 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 15 Jan 2025 22:18:44 -0600 Subject: [PATCH] Working meta scenes --- scenes/Meta/Overworld.tscn | 40 +++++++++++++ scenes/{ => Meta}/Systems.tscn | 18 +++--- scenes/Meta/UI.tscn | 17 ++++++ scenes/TestScene.tscn | 57 ++----------------- scenes/Testing/TestCube.tscn | 13 ----- scripts/Cooking/CookingGame.gd | 1 + scripts/Cooking/Recipe/CookingRecipe.gd | 6 +- scripts/Cooking/Recipe/VerticalSlice.gd | 8 ++- scripts/Cutscene/Cooking/CookingStartEvent.gd | 11 ++++ scripts/Cutscene/TestCutscene.gd | 11 ++-- scripts/Entities/TestNPCController.gd | 6 +- scripts/System/ItemSystem.gd | 21 ++++++- scripts/System/QuestSystem.gd | 4 +- scripts/System/SceneSystem.gd | 14 +++++ scripts/System/Systems.gd | 3 + 15 files changed, 144 insertions(+), 86 deletions(-) create mode 100644 scenes/Meta/Overworld.tscn rename scenes/{ => Meta}/Systems.tscn (68%) create mode 100644 scenes/Meta/UI.tscn delete mode 100644 scenes/Testing/TestCube.tscn create mode 100644 scripts/Cutscene/Cooking/CookingStartEvent.gd create mode 100644 scripts/System/SceneSystem.gd diff --git a/scenes/Meta/Overworld.tscn b/scenes/Meta/Overworld.tscn new file mode 100644 index 0000000..eaa53d0 --- /dev/null +++ b/scenes/Meta/Overworld.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=8 format=3 uid="uid://tmbx2kit0jyq"] + +[ext_resource type="PackedScene" uid="uid://yhtpoum3eek7" path="res://scenes/Entities/Rosa.tscn" id="1_xny00"] +[ext_resource type="PackedScene" uid="uid://dr4b2pmsknuhc" path="res://scenes/Entities/TestNPC.tscn" id="2_p8bk2"] +[ext_resource type="PackedScene" uid="uid://7wjfo6u4dp3h" path="res://scenes/Maps/test.tscn" id="3_dyt66"] +[ext_resource type="PackedScene" uid="uid://cy4r0tp2htivb" path="res://scenes/MapBounds.tscn" id="4_584ld"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_asdol"] +sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1) +sky_energy_multiplier = 0.0 +ground_bottom_color = Color(0, 0, 0, 1) +ground_horizon_color = Color(0.59625, 0.6135, 0.6375, 1) + +[sub_resource type="Sky" id="Sky_weucl"] +sky_material = SubResource("ProceduralSkyMaterial_asdol") + +[sub_resource type="Environment" id="Environment_pyuof"] +sky = SubResource("Sky_weucl") +ambient_light_source = 1 + +[node name="Overworld" type="Node3D"] + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_pyuof") + +[node name="Rosa" parent="." instance=ExtResource("1_xny00")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.651853, 0.684572, -0.0593004) + +[node name="TestNpc" parent="." instance=ExtResource("2_p8bk2")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.68747, 0.459578, -0.399262) + +[node name="OmniLight3D" type="OmniLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.1432, 54.7591, -25.7675) +light_energy = 15.315 +omni_range = 281.646 + +[node name="Map" parent="." instance=ExtResource("3_dyt66")] + +[node name="MapBounds" parent="." instance=ExtResource("4_584ld")] +transform = Transform3D(22.0363, 0, 0, 0, 7.5201, 0, 0, 0, 19.278, 1.48402, 2.89779, 1.65935) diff --git a/scenes/Systems.tscn b/scenes/Meta/Systems.tscn similarity index 68% rename from scenes/Systems.tscn rename to scenes/Meta/Systems.tscn index f6a8f2d..2b7f330 100644 --- a/scenes/Systems.tscn +++ b/scenes/Meta/Systems.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://iibqlagufwhm"] +[gd_scene load_steps=10 format=3 uid="uid://iibqlagufwhm"] [ext_resource type="Script" path="res://scripts/System/Systems.gd" id="1_uen2c"] [ext_resource type="Script" path="res://scripts/System/CutsceneSystem.gd" id="2_sf62c"] @@ -8,23 +8,24 @@ [ext_resource type="Script" path="res://scripts/System/PauseSystem.gd" id="6_hdi8m"] [ext_resource type="Script" path="res://scripts/System/BattleSystem.gd" id="7_miqgj"] [ext_resource type="Script" path="res://scripts/System/CookingSystem.gd" id="7_nou1j"] +[ext_resource type="Script" path="res://scripts/System/SceneSystem.gd" id="9_budbk"] -[node name="Systems" type="Node3D"] +[node name="Systems" type="Node"] script = ExtResource("1_uen2c") -[node name="Cutscene" type="Node3D" parent="."] +[node name="Cutscene" type="Node" parent="."] script = ExtResource("2_sf62c") -[node name="Item" type="Node3D" parent="."] +[node name="Item" type="Node" parent="."] script = ExtResource("3_nwp6i") -[node name="Quest" type="Node3D" parent="."] +[node name="Quest" type="Node" parent="."] script = ExtResource("4_d00wi") -[node name="VN" type="Node3D" parent="."] +[node name="VN" type="Node" parent="."] script = ExtResource("5_22p3i") -[node name="Pause" type="Node3D" parent="."] +[node name="Pause" type="Node" parent="."] script = ExtResource("6_hdi8m") [node name="Cooking" type="Node" parent="."] @@ -32,3 +33,6 @@ script = ExtResource("7_nou1j") [node name="Battle" type="Node" parent="."] script = ExtResource("7_miqgj") + +[node name="Scene" type="Node" parent="."] +script = ExtResource("9_budbk") diff --git a/scenes/Meta/UI.tscn b/scenes/Meta/UI.tscn new file mode 100644 index 0000000..b14d5a7 --- /dev/null +++ b/scenes/Meta/UI.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://dfwwtbs3ywcyq"] + +[ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://Themes/UI Theme.tres" id="1_3b1y4"] +[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/UI/VNTextbox.tscn" id="2_x0c4l"] + +[node name="UI" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_3b1y4") + +[node name="VNTextbox" parent="." instance=ExtResource("2_x0c4l")] +layout_mode = 1 +offset_top = -133.0 diff --git a/scenes/TestScene.tscn b/scenes/TestScene.tscn index 77aae94..92ac414 100644 --- a/scenes/TestScene.tscn +++ b/scenes/TestScene.tscn @@ -1,58 +1,13 @@ -[gd_scene load_steps=11 format=3 uid="uid://bdrpqtbwvtivd"] +[gd_scene load_steps=4 format=3 uid="uid://bdrpqtbwvtivd"] -[ext_resource type="PackedScene" uid="uid://yhtpoum3eek7" path="res://scenes/Entities/Rosa.tscn" id="1_3u2u0"] -[ext_resource type="PackedScene" uid="uid://iibqlagufwhm" path="res://scenes/Systems.tscn" id="1_3x3uf"] -[ext_resource type="PackedScene" uid="uid://dr4b2pmsknuhc" path="res://scenes/Entities/TestNPC.tscn" id="2_6f3lj"] -[ext_resource type="PackedScene" uid="uid://7wjfo6u4dp3h" path="res://scenes/Maps/test.tscn" id="4_18e1y"] -[ext_resource type="PackedScene" uid="uid://cy4r0tp2htivb" path="res://scenes/MapBounds.tscn" id="4_gv7tl"] -[ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://Themes/UI Theme.tres" id="6_d185f"] -[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/UI/VNTextbox.tscn" id="7_nofjj"] - -[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_1b6it"] -sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1) -sky_energy_multiplier = 0.0 -ground_bottom_color = Color(0, 0, 0, 1) -ground_horizon_color = Color(0.59625, 0.6135, 0.6375, 1) - -[sub_resource type="Sky" id="Sky_weucl"] -sky_material = SubResource("ProceduralSkyMaterial_1b6it") - -[sub_resource type="Environment" id="Environment_18twt"] -sky = SubResource("Sky_weucl") -ambient_light_source = 1 +[ext_resource type="PackedScene" uid="uid://iibqlagufwhm" path="res://scenes/Meta/Systems.tscn" id="1_3x3uf"] +[ext_resource type="PackedScene" uid="uid://tmbx2kit0jyq" path="res://scenes/Meta/Overworld.tscn" id="2_q3er3"] +[ext_resource type="PackedScene" uid="uid://dfwwtbs3ywcyq" path="res://scenes/Meta/UI.tscn" id="3_jjngg"] [node name="TestSceneRoot" type="Node3D"] [node name="Systems" parent="." instance=ExtResource("1_3x3uf")] -[node name="WorldEnvironment" type="WorldEnvironment" parent="."] -environment = SubResource("Environment_18twt") +[node name="Overworld" parent="." instance=ExtResource("2_q3er3")] -[node name="Rosa" parent="." instance=ExtResource("1_3u2u0")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.651853, 0.684572, -0.0593004) - -[node name="TestNpc" parent="." instance=ExtResource("2_6f3lj")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.68747, 0.459578, -0.399262) - -[node name="OmniLight3D" type="OmniLight3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.1432, 54.7591, -25.7675) -light_energy = 15.315 -omni_range = 281.646 - -[node name="Map" parent="." instance=ExtResource("4_18e1y")] - -[node name="MapBounds" parent="." instance=ExtResource("4_gv7tl")] -transform = Transform3D(22.0363, 0, 0, 0, 7.5201, 0, 0, 0, 19.278, 1.48402, 2.89779, 1.65935) - -[node name="UI" type="Control" parent="."] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = ExtResource("6_d185f") - -[node name="VNTextbox" parent="UI" instance=ExtResource("7_nofjj")] -layout_mode = 1 -offset_top = -133.0 +[node name="UI" parent="." instance=ExtResource("3_jjngg")] diff --git a/scenes/Testing/TestCube.tscn b/scenes/Testing/TestCube.tscn deleted file mode 100644 index 3d23868..0000000 --- a/scenes/Testing/TestCube.tscn +++ /dev/null @@ -1,13 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://dlwauw7qvyxnn"] - -[sub_resource type="BoxShape3D" id="BoxShape3D_qpmw6"] - -[sub_resource type="BoxMesh" id="BoxMesh_lddii"] - -[node name="TestCube" type="StaticBody3D"] - -[node name="CollisionShape3D" type="CollisionShape3D" parent="."] -shape = SubResource("BoxShape3D_qpmw6") - -[node name="MeshInstance3D" type="MeshInstance3D" parent="."] -mesh = SubResource("BoxMesh_lddii") diff --git a/scripts/Cooking/CookingGame.gd b/scripts/Cooking/CookingGame.gd index e09d809..17b9aa3 100644 --- a/scripts/Cooking/CookingGame.gd +++ b/scripts/Cooking/CookingGame.gd @@ -2,5 +2,6 @@ class_name CookingGame const VerticalSlice = preload("res://scripts/Cooking/Recipe/VerticalSlice.gd"); var recipe:CookingRecipe = null; + func _init(recipe:CookingRecipe) -> void: self.recipe = recipe; diff --git a/scripts/Cooking/Recipe/CookingRecipe.gd b/scripts/Cooking/Recipe/CookingRecipe.gd index 409e980..e8537f5 100644 --- a/scripts/Cooking/Recipe/CookingRecipe.gd +++ b/scripts/Cooking/Recipe/CookingRecipe.gd @@ -1,4 +1,8 @@ class_name CookingRecipe +const ItemStack = preload("res://scripts/Item/ItemStack.gd") func _init() -> void: - pass \ No newline at end of file + pass + +func getIngredients() -> Array[ItemStack]: + return [] diff --git a/scripts/Cooking/Recipe/VerticalSlice.gd b/scripts/Cooking/Recipe/VerticalSlice.gd index 0afde4c..0cb8cab 100644 --- a/scripts/Cooking/Recipe/VerticalSlice.gd +++ b/scripts/Cooking/Recipe/VerticalSlice.gd @@ -1,4 +1,10 @@ class_name VerticalSlice extends "res://scripts/Cooking/Recipe/CookingRecipe.gd" +const ItemSystem = preload("res://scripts/System/ItemSystem.gd") func _init() -> void: - super._init(); \ No newline at end of file + super._init(); + +func getIngredients() -> Array[ItemStack]: + return [ + ItemStack.new(ItemSystem.ITEM_POTION, 1) + ]; diff --git a/scripts/Cutscene/Cooking/CookingStartEvent.gd b/scripts/Cutscene/Cooking/CookingStartEvent.gd new file mode 100644 index 0000000..4f3815b --- /dev/null +++ b/scripts/Cutscene/Cooking/CookingStartEvent.gd @@ -0,0 +1,11 @@ +class_name CookingStartEvent extends "res://scripts/Cutscene/CutsceneEvent.gd" +const CookingGame = preload("res://scripts/Cooking/CookingGame.gd"); + +var cook:CookingGame; + +func _init(cook:CookingGame) -> void: + self.cook = cook; + +func start() -> void: + getSystems().COOKING.setCookingGame(self.cook); + getSystems().SCENE.setScene(SceneSystem.DawnScene.COOKING); \ No newline at end of file diff --git a/scripts/Cutscene/TestCutscene.gd b/scripts/Cutscene/TestCutscene.gd index e84a485..65f9e64 100644 --- a/scripts/Cutscene/TestCutscene.gd +++ b/scripts/Cutscene/TestCutscene.gd @@ -1,17 +1,14 @@ class_name TestCutscene extends "res://scripts/Cutscene/Cutscene.gd" const OverworldEntity = preload("res://scripts/Entities/OverworldEntity.gd"); -const TextboxEvent = preload("res://scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd"); -const PauseEvent = preload("res://scripts/Cutscene/Event/CutscenePauseEvent.gd"); -const OverworldChangeDirectionEvent = preload("res://scripts/Cutscene/Event/Entity/OverworldChangeDirectionEvent.gd"); -const BattleStartEvent = preload("res://scripts/Cutscene/Battle/BattleStartEvent.gd"); +const CookingStartEvent = preload("res://scripts/Cutscene/Cooking/CookingStartEvent.gd"); -var battle:Battle = null; +var cook:CookingGame; func _init(speaker:OverworldEntity, interacted:OverworldEntity ) -> void: - battle = Battle.new(); + cook = CookingGame.new(VerticalSlice.new()); pass func setupCutscene() -> void: add([ - BattleStartEvent.new(battle), + CookingStartEvent.new(cook), ]); diff --git a/scripts/Entities/TestNPCController.gd b/scripts/Entities/TestNPCController.gd index 3c3eb39..84cd155 100644 --- a/scripts/Entities/TestNPCController.gd +++ b/scripts/Entities/TestNPCController.gd @@ -5,10 +5,10 @@ func interact(interactor:OverworldEntity) -> void: # var battle = Battle.new(); # getSystems().BATTLE.startBattle(battle); - var game = CookingGame.new(VerticalSlice.new()); - getSystems().COOKING.setCookingGame(game); + # var game = CookingGame.new(VerticalSlice.new()); + # getSystems().COOKING.setCookingGame(game); - # getSystems().CUTSCENE.setCurrentCutscene(TestCutscene.new(interactor, self)); + getSystems().CUTSCENE.setCurrentCutscene(TestCutscene.new(interactor, self)); pass func updateMovement(delta:float) -> void: diff --git a/scripts/System/ItemSystem.gd b/scripts/System/ItemSystem.gd index 3d0e432..08f6a85 100644 --- a/scripts/System/ItemSystem.gd +++ b/scripts/System/ItemSystem.gd @@ -17,7 +17,9 @@ class ItemStackTypeComparator: # Constants const ITEM_STACK_SIZE_MAX = 99; -var ITEM_POTION = preload("res://scripts/Item/Potion.gd").new(); +static var ITEM_POTION = preload("res://scripts/Item/Potion.gd").new(); + +# Class var inventory:Array[ItemStack] = []; # Methods @@ -78,6 +80,23 @@ func removeItem(item: Item, quantity: int) -> void: if quantity == 0: return +func removeStack(stack: ItemStack) -> void: + self.removeItem(stack.item, stack.quantity); + +func hasItem(item: Item, quantity: int = 1) -> bool: + var totalQuantity = 0 + + for stack in inventory: + if stack.item != item: + continue + + totalQuantity += stack.quantity + + if totalQuantity >= quantity: + return true + + return false + func sortBy(by:ItemSortType) -> void: match by: ItemSortType.NAME: diff --git a/scripts/System/QuestSystem.gd b/scripts/System/QuestSystem.gd index 49e89fa..5b3261c 100644 --- a/scripts/System/QuestSystem.gd +++ b/scripts/System/QuestSystem.gd @@ -1,7 +1,7 @@ class_name QuestSystem extends Node -var QUEST_EXAMPLE = preload("res://scripts/Quest/QuestExample.gd").new(); +static var QUEST_EXAMPLE = preload("res://scripts/Quest/QuestExample.gd").new(); -var ALL_QUESTS = [ +static var ALL_QUESTS = [ QUEST_EXAMPLE ] diff --git a/scripts/System/SceneSystem.gd b/scripts/System/SceneSystem.gd new file mode 100644 index 0000000..2a41837 --- /dev/null +++ b/scripts/System/SceneSystem.gd @@ -0,0 +1,14 @@ +class_name SceneSystem extends Node + +enum DawnScene { + MAIN_MENU, + OVERWORLD, + BATTLE, + COOKING +}; + +var scene:DawnScene = DawnScene.OVERWORLD; + +func setScene(newScene:DawnScene) -> void: + print("Setting scene to " + str(newScene)); + scene = newScene; diff --git a/scripts/System/Systems.gd b/scripts/System/Systems.gd index ff5239f..40fb193 100644 --- a/scripts/System/Systems.gd +++ b/scripts/System/Systems.gd @@ -6,6 +6,7 @@ const VNSystem = preload("res://scripts/System/VNSystem.gd"); const PauseSystem = preload("res://scripts/System/PauseSystem.gd"); const BattleSystem = preload("res://scripts/System/BattleSystem.gd"); const CookingSystem = preload("res://scripts/System/CookingSystem.gd"); +const SceneSystem = preload("res://scripts/System/SceneSystem.gd"); var ITEM:ItemSystem; var CUTSCENE:CutsceneSystem; @@ -14,6 +15,7 @@ var VN:VNSystem; var PAUSE:PauseSystem; var BATTLE:BattleSystem; var COOKING:CookingSystem; +var SCENE:SceneSystem; func _ready(): ITEM = $Item; @@ -23,6 +25,7 @@ func _ready(): PAUSE = $Pause; BATTLE = $Battle; COOKING = $Cooking; + SCENE = $Scene; func _process(delta): pass