From 3b7de160dcde3eb39f075ea5120d5bfe9700cc00 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Thu, 15 Jan 2026 17:28:39 -0600 Subject: [PATCH] Prepping cooking --- cooking/CookBook.gd.uid | 1 + cooking/Cooking.gd | 28 ++++++++++++++- cooking/Recipe.gd | 42 ++++++++++++++++++++++ cooking/Recipe.gd.uid | 1 + cooking/RecipeBook.gd | 14 ++++++++ cooking/RecipeBook.gd.uid | 1 + cutscene/CutsceneResource.gd | 8 +++++ cutscene/CutsceneResource.gd.uid | 1 + cutscene/cooking/CookingStartAction.gd | 18 ++++++++++ cutscene/cooking/CookingStartAction.gd.uid | 1 + cutscene/cutscene/TestCutscene.gd | 6 ++++ cutscene/cutscene/TestCutscene.gd.uid | 1 + item/Item.gd | 2 +- item/ItemResource.gd | 2 +- overworld/entity/Entity.gd | 5 ++- overworld/entity/EntityInteractableArea.gd | 17 +++++---- overworld/map/TestMap.tscn | 13 ++++++- project.godot | 4 +-- {singleton => scene}/Load.gd | 0 {singleton => scene}/Load.gd.uid | 0 {singleton => scene}/Load.tscn | 2 +- {singleton => scene}/Pause.gd | 0 {singleton => scene}/Pause.gd.uid | 0 {singleton => scene}/Transition.gd | 0 {singleton => scene}/Transition.gd.uid | 0 {singleton => scene}/Transition.tscn | 2 +- singleton/Input.gd.uid | 1 - 27 files changed, 151 insertions(+), 19 deletions(-) create mode 100644 cooking/CookBook.gd.uid create mode 100644 cooking/Recipe.gd create mode 100644 cooking/Recipe.gd.uid create mode 100644 cooking/RecipeBook.gd create mode 100644 cooking/RecipeBook.gd.uid create mode 100644 cutscene/CutsceneResource.gd create mode 100644 cutscene/CutsceneResource.gd.uid create mode 100644 cutscene/cooking/CookingStartAction.gd create mode 100644 cutscene/cooking/CookingStartAction.gd.uid create mode 100644 cutscene/cutscene/TestCutscene.gd create mode 100644 cutscene/cutscene/TestCutscene.gd.uid rename {singleton => scene}/Load.gd (100%) rename {singleton => scene}/Load.gd.uid (100%) rename {singleton => scene}/Load.tscn (84%) rename {singleton => scene}/Pause.gd (100%) rename {singleton => scene}/Pause.gd.uid (100%) rename {singleton => scene}/Transition.gd (100%) rename {singleton => scene}/Transition.gd.uid (100%) rename {singleton => scene}/Transition.tscn (92%) delete mode 100644 singleton/Input.gd.uid diff --git a/cooking/CookBook.gd.uid b/cooking/CookBook.gd.uid new file mode 100644 index 0000000..0ab50c7 --- /dev/null +++ b/cooking/CookBook.gd.uid @@ -0,0 +1 @@ +uid://bu1fdc6j7aep5 diff --git a/cooking/Cooking.gd b/cooking/Cooking.gd index 9fac8d6..f8629db 100644 --- a/cooking/Cooking.gd +++ b/cooking/Cooking.gd @@ -1 +1,27 @@ -class_name CookingSingleton extends Node \ No newline at end of file +class_name CookingSingleton extends Node + +# Cooking State +var cutscene:Cutscene = null +var active:bool = false + +# Signals +signal cookingStarted + +func start(params:Dictionary) -> void: + assert(params.has('recipe')) + assert(!active) + + if params['cutscene'] != null: + cutscene = params['cutscene'] + else: + cutscene = Cutscene.new() + + # TODO: Add cooking things here + + # Emit signals + active = true + cookingStarted.emit() + + # Start the cutscene. + if !cutscene.running: + cutscene.start() \ No newline at end of file diff --git a/cooking/Recipe.gd b/cooking/Recipe.gd new file mode 100644 index 0000000..cc5715f --- /dev/null +++ b/cooking/Recipe.gd @@ -0,0 +1,42 @@ +class_name Recipe + +enum Id { + NULL, + BAKED_POTATO, +} + +# Data storage +static var RECIPES = [] + +# Initializer +static func defineRecipe(params:Dictionary) -> Dictionary: + assert(params.has("id")) + assert(params.has("handle")) + + var recipe = { + "id": params["id"], + "handle": params.get("handle"), + } + + RECIPES.insert(params["id"], recipe) + return recipe + +# Instances +static var RECIPE_NULL = defineRecipe({ + "id": Id.NULL, + "handle": "unknown" +}) + +static var BAKED_POTATO = defineRecipe({ + "id": Id.BAKED_POTATO, + "handle": "baked_potato" +}) + +# Getters +static func getData(id:int) -> Dictionary: + if RECIPES.size() <= id || id < 0: + return RECIPE_NULL + return RECIPES[id] + +static func getRecipeHandle(id:Id) -> String: + return getData(id)["handle"] diff --git a/cooking/Recipe.gd.uid b/cooking/Recipe.gd.uid new file mode 100644 index 0000000..9b8ac72 --- /dev/null +++ b/cooking/Recipe.gd.uid @@ -0,0 +1 @@ +uid://cuxhuep2pi734 diff --git a/cooking/RecipeBook.gd b/cooking/RecipeBook.gd new file mode 100644 index 0000000..99cb8b1 --- /dev/null +++ b/cooking/RecipeBook.gd @@ -0,0 +1,14 @@ +class_name RecipeBook + +static var RECIPES_KNOWN:Array[Recipe.Id] = [] + +static func learnRecipe(recipeId:Recipe.Id) -> void: + if recipeId in RECIPES_KNOWN: + return + RECIPES_KNOWN.append(recipeId) + +static func isRecipeKnown(recipeId:Recipe.Id) -> bool: + return recipeId in RECIPES_KNOWN + +static func getKnownRecipes() -> Array[Recipe.Id]: + return RECIPES_KNOWN.duplicate() \ No newline at end of file diff --git a/cooking/RecipeBook.gd.uid b/cooking/RecipeBook.gd.uid new file mode 100644 index 0000000..fbcf773 --- /dev/null +++ b/cooking/RecipeBook.gd.uid @@ -0,0 +1 @@ +uid://cucoo6enonu3v diff --git a/cutscene/CutsceneResource.gd b/cutscene/CutsceneResource.gd new file mode 100644 index 0000000..e957020 --- /dev/null +++ b/cutscene/CutsceneResource.gd @@ -0,0 +1,8 @@ +extends Resource +class_name CutsceneResource + +func queue(_cutscene:Cutscene) -> void: + pass + +func canRun() -> bool: + return true \ No newline at end of file diff --git a/cutscene/CutsceneResource.gd.uid b/cutscene/CutsceneResource.gd.uid new file mode 100644 index 0000000..fc1ab6f --- /dev/null +++ b/cutscene/CutsceneResource.gd.uid @@ -0,0 +1 @@ +uid://bbjol1dxa3wvo diff --git a/cutscene/cooking/CookingStartAction.gd b/cutscene/cooking/CookingStartAction.gd new file mode 100644 index 0000000..c0a8804 --- /dev/null +++ b/cutscene/cooking/CookingStartAction.gd @@ -0,0 +1,18 @@ +class_name CookingStartAction + +static func startCookingCallable(params:Dictionary) -> int: + assert(params.has("recipe")) + + SCENE.setScene(SceneSingleton.SceneType.COOKING) + COOKING.start({ + 'recipe': params['recipe'], + 'cutscene': params.get('cutscene', null) + }) + return Cutscene.CUTSCENE_CONTINUE + +static func getStartCookingCallable(params:Dictionary) -> Dictionary: + assert(params.has("recipe")) + return { + "function": startCookingCallable, + 'recipe': params['recipe'] + } \ No newline at end of file diff --git a/cutscene/cooking/CookingStartAction.gd.uid b/cutscene/cooking/CookingStartAction.gd.uid new file mode 100644 index 0000000..1bb4ddf --- /dev/null +++ b/cutscene/cooking/CookingStartAction.gd.uid @@ -0,0 +1 @@ +uid://b8b43y70xfy04 diff --git a/cutscene/cutscene/TestCutscene.gd b/cutscene/cutscene/TestCutscene.gd new file mode 100644 index 0000000..053ecdc --- /dev/null +++ b/cutscene/cutscene/TestCutscene.gd @@ -0,0 +1,6 @@ +class_name TestCutscene extends CutsceneResource + +func queue(cutscene:Cutscene) -> void: + cutscene.addCallable(CookingStartAction.getStartCookingCallable({ + 'recipe': Recipe.Id.BAKED_POTATO + })) \ No newline at end of file diff --git a/cutscene/cutscene/TestCutscene.gd.uid b/cutscene/cutscene/TestCutscene.gd.uid new file mode 100644 index 0000000..95c359e --- /dev/null +++ b/cutscene/cutscene/TestCutscene.gd.uid @@ -0,0 +1 @@ +uid://b5c8g5frishjs diff --git a/item/Item.gd b/item/Item.gd index d0bc217..f575c26 100644 --- a/item/Item.gd +++ b/item/Item.gd @@ -38,7 +38,7 @@ static var ITEM_NULL = itemDefine({ 'type': Type.NULL }) -static var ITEM_POTION = itemDefine({ +static var POTION = itemDefine({ 'id': Id.POTION, 'handle': "potion", 'type': Type.MEDICINE diff --git a/item/ItemResource.gd b/item/ItemResource.gd index 7f03d0d..d42d2a2 100644 --- a/item/ItemResource.gd +++ b/item/ItemResource.gd @@ -10,4 +10,4 @@ func toItemStack() -> ItemStack: var stack = ItemStack.new() stack.item = item stack.quantity = quantity - return stack \ No newline at end of file + return stack diff --git a/overworld/entity/Entity.gd b/overworld/entity/Entity.gd index c5a47d2..c5a58e1 100644 --- a/overworld/entity/Entity.gd +++ b/overworld/entity/Entity.gd @@ -12,7 +12,7 @@ enum InteractType { NONE, CONVERSATION, ONE_TIME_ITEM, - TEST_BATTLE + CUTSCENE }; @export_category("Identification") @@ -29,9 +29,8 @@ var button := func(): @export_category("Interactions") @export var interactType:InteractType = InteractType.NONE @export var conversation:Array[ConversationResource] = [] - -@export_category("One-Time Item") @export var oneTimeItem:ItemResource = null +@export var cutscene:CutsceneResource = null # TEST BATTLE @export_category("Test Battle") diff --git a/overworld/entity/EntityInteractableArea.gd b/overworld/entity/EntityInteractableArea.gd index aee43b4..ff8381f 100644 --- a/overworld/entity/EntityInteractableArea.gd +++ b/overworld/entity/EntityInteractableArea.gd @@ -11,10 +11,15 @@ func isInteractable() -> bool: return false if entity.interactType == Entity.InteractType.CONVERSATION: - if entity.conversation.size() != 0: - return true + if entity.conversation.size() == 0: + return false + return true - if entity.interactType == Entity.InteractType.TEST_BATTLE: + if entity.interactType == Entity.InteractType.CUTSCENE: + if entity.cutscene == null: + return false + if !entity.cutscene.canRun(): + return false return true if entity.interactType == Entity.InteractType.ONE_TIME_ITEM: @@ -53,11 +58,9 @@ func onInteract(other:Entity) -> void: _onItemInteract(other) return - Entity.InteractType.TEST_BATTLE: + Entity.InteractType.CUTSCENE: var cutscene:Cutscene = Cutscene.new() - cutscene.addCallable(BattleStartAction.getStartBattleCallable({ - BATTLE.BattlePosition.RIGHT_TOP_FRONT: PartySingleton.PARTY_JOHN, - })) + entity.cutscene.queue(cutscene) cutscene.start() return diff --git a/overworld/map/TestMap.tscn b/overworld/map/TestMap.tscn index 59328ba..df23bfe 100644 --- a/overworld/map/TestMap.tscn +++ b/overworld/map/TestMap.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=8 format=3 uid="uid://d0ywgijpuqy0r"] +[gd_scene load_steps=10 format=3 uid="uid://d0ywgijpuqy0r"] [ext_resource type="Script" uid="uid://xe6pcuq741xi" path="res://overworld/map/TestMap.gd" id="1_6ms5s"] [ext_resource type="PackedScene" uid="uid://cluuhtfjeodwb" path="res://overworld/map/TestMapBase.tscn" id="1_ox0si"] [ext_resource type="PackedScene" uid="uid://by4a0r2hp0w6s" path="res://overworld/entity/Entity.tscn" id="2_jmygs"] [ext_resource type="Script" uid="uid://yn7kxdargafx" path="res://cutscene/conversation/ConversationResource.gd" id="3_p7git"] [ext_resource type="Script" uid="uid://38ya6vphm5bu" path="res://item/ItemResource.gd" id="4_xf0pb"] +[ext_resource type="Script" uid="uid://b5c8g5frishjs" path="res://cutscene/cutscene/TestCutscene.gd" id="5_125nt"] [sub_resource type="Resource" id="Resource_xf0pb"] script = ExtResource("3_p7git") @@ -18,6 +19,10 @@ item = 1 quantity = 1 metadata/_custom_type_script = "uid://38ya6vphm5bu" +[sub_resource type="Resource" id="Resource_tr4a0"] +script = ExtResource("5_125nt") +metadata/_custom_type_script = "uid://b5c8g5frishjs" + [node name="TestMap" type="Node3D"] script = ExtResource("1_6ms5s") @@ -33,6 +38,12 @@ entityId = "ad5a1504-7fbf-45d6-b1bf-6e7af6314066" interactType = 2 oneTimeItem = SubResource("Resource_125nt") +[node name="NotPlayer3" parent="." instance=ExtResource("2_jmygs")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.29413, 1.11219, 1.45094) +entityId = "ad5a1504-7fbf-45d6-b1bf-6e7af6314066" +interactType = 3 +cutscene = SubResource("Resource_tr4a0") + [node name="TestMapBase" parent="." instance=ExtResource("1_ox0si")] [node name="Player" parent="." instance=ExtResource("2_jmygs")] diff --git a/project.godot b/project.godot index 420824a..cbb49c6 100644 --- a/project.godot +++ b/project.godot @@ -17,8 +17,8 @@ config/icon="res://icon.svg" [autoload] -PAUSE="*res://singleton/Pause.gd" -TRANSITION="*res://singleton/Transition.tscn" +PAUSE="*res://scene/Pause.gd" +TRANSITION="*res://scene/Transition.tscn" QUEST="*res://quest/Quest.tscn" OVERWORLD="*res://overworld/Overworld.gd" SCENE="*res://scene/Scene.gd" diff --git a/singleton/Load.gd b/scene/Load.gd similarity index 100% rename from singleton/Load.gd rename to scene/Load.gd diff --git a/singleton/Load.gd.uid b/scene/Load.gd.uid similarity index 100% rename from singleton/Load.gd.uid rename to scene/Load.gd.uid diff --git a/singleton/Load.tscn b/scene/Load.tscn similarity index 84% rename from singleton/Load.tscn rename to scene/Load.tscn index 3f197da..3cb31d6 100644 --- a/singleton/Load.tscn +++ b/scene/Load.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://c8shl8u156rfi"] -[ext_resource type="Script" uid="uid://dfpml5awf5i35" path="res://singleton/Load.gd" id="1_a3iwn"] +[ext_resource type="Script" uid="uid://dfpml5awf5i35" path="res://scene/Load.gd" id="1_a3iwn"] [node name="Load" type="Node"] script = ExtResource("1_a3iwn") diff --git a/singleton/Pause.gd b/scene/Pause.gd similarity index 100% rename from singleton/Pause.gd rename to scene/Pause.gd diff --git a/singleton/Pause.gd.uid b/scene/Pause.gd.uid similarity index 100% rename from singleton/Pause.gd.uid rename to scene/Pause.gd.uid diff --git a/singleton/Transition.gd b/scene/Transition.gd similarity index 100% rename from singleton/Transition.gd rename to scene/Transition.gd diff --git a/singleton/Transition.gd.uid b/scene/Transition.gd.uid similarity index 100% rename from singleton/Transition.gd.uid rename to scene/Transition.gd.uid diff --git a/singleton/Transition.tscn b/scene/Transition.tscn similarity index 92% rename from singleton/Transition.tscn rename to scene/Transition.tscn index 6e1a7e1..250a9e1 100644 --- a/singleton/Transition.tscn +++ b/scene/Transition.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://i4ukelrrsujw"] -[ext_resource type="Script" uid="uid://iu3m73wtjlho" path="res://singleton/Transition.gd" id="1_isjic"] +[ext_resource type="Script" uid="uid://iu3m73wtjlho" path="res://scene/Transition.gd" id="1_isjic"] [node name="Transition" type="Control"] layout_mode = 3 diff --git a/singleton/Input.gd.uid b/singleton/Input.gd.uid deleted file mode 100644 index 66d5eb5..0000000 --- a/singleton/Input.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cxx6dl53tc5ym