This commit is contained in:
2025-05-20 21:34:52 -05:00
parent 7b92b11696
commit 1bce56231c
11 changed files with 107 additions and 40 deletions

View File

@@ -46,7 +46,7 @@ interactEvent = NodePath("../../Events/TestConversation")
[node name="ItemOnGround" parent="Entities" instance=ExtResource("4_ejcqv")] [node name="ItemOnGround" parent="Entities" instance=ExtResource("4_ejcqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.546944, -0.547748, -3.46628) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.546944, -0.547748, -3.46628)
itemType = 1 itemType = 2
quantity = 2 quantity = 2
[node name="Map" type="Node3D" parent="."] [node name="Map" type="Node3D" parent="."]
@@ -106,7 +106,7 @@ metadata/_custom_type_script = "uid://c4d7nithqnx5y"
[node name="Text 1" type="Node" parent="Events/TestConversation/Before Quest STarted"] [node name="Text 1" type="Node" parent="Events/TestConversation/Before Quest STarted"]
script = ExtResource("6_gxq5o") script = ExtResource("6_gxq5o")
text = "Thanks for closing the quest menu" text = "Take this potion to help you on your way."
[node name="Get Item" type="Node" parent="Events/TestConversation/Before Quest STarted"] [node name="Get Item" type="Node" parent="Events/TestConversation/Before Quest STarted"]
script = ExtResource("10_avybc") script = ExtResource("10_avybc")

View File

@@ -1,7 +1,20 @@
[gd_scene load_steps=3 format=3 uid="uid://1l0tymk8cfxu"] [gd_scene load_steps=6 format=3 uid="uid://1l0tymk8cfxu"]
[ext_resource type="Script" uid="uid://j87s6jrx8unn" path="res://scripts/Singleton/Recipe.gd" id="1_o4nv4"] [ext_resource type="Script" uid="uid://j87s6jrx8unn" path="res://scripts/Singleton/Recipe.gd" id="1_o4nv4"]
[ext_resource type="Script" uid="uid://dipvg4uwjv6p2" path="res://scripts/Cooking/Recipe.gd" id="2_f5akq"] [ext_resource type="Script" uid="uid://dipvg4uwjv6p2" path="res://scripts/Cooking/Recipe.gd" id="2_f5akq"]
[ext_resource type="Script" uid="uid://c26aptwsjs044" path="res://scripts/Item/ItemResource.gd" id="3_b8y03"]
[sub_resource type="Resource" id="Resource_3dxl6"]
script = ExtResource("3_b8y03")
itemType = 2
count = 1
metadata/_custom_type_script = "uid://c26aptwsjs044"
[sub_resource type="Resource" id="Resource_b8y03"]
script = ExtResource("3_b8y03")
itemType = 1
count = 1
metadata/_custom_type_script = "uid://c26aptwsjs044"
[node name="RecipeSystem" type="Node"] [node name="RecipeSystem" type="Node"]
script = ExtResource("1_o4nv4") script = ExtResource("1_o4nv4")
@@ -10,4 +23,7 @@ metadata/_custom_type_script = "uid://j87s6jrx8unn"
[node name="Ash-Baked Sweet Potato" type="Node" parent="."] [node name="Ash-Baked Sweet Potato" type="Node" parent="."]
script = ExtResource("2_f5akq") script = ExtResource("2_f5akq")
recipeName = "Ash-Baked Sweet Potato" recipeName = "Ash-Baked Sweet Potato"
recipeDescription = "Tender, warm, and sweet meal, made by baking a sweet potato in campfire embers. Comforting, simple, and gently filling."
ingredients = Array[ExtResource("3_b8y03")]([SubResource("Resource_3dxl6")])
outputs = Array[ExtResource("3_b8y03")]([SubResource("Resource_b8y03")])
metadata/_custom_type_script = "uid://dipvg4uwjv6p2" metadata/_custom_type_script = "uid://dipvg4uwjv6p2"

View File

@@ -1,8 +1,30 @@
@tool
class_name Recipe extends Node class_name Recipe extends Node
@export var recipeName:String = "" @export var recipeName:String = ""
@export var ingredients:Array[RecipeIngredient] = [] @export var ingredients:Array[ItemResource] = []
@export var outputs:Array[ItemResource] = []
func test(): var learned:bool = false
print("test") var timesMade:int = 0
func hasIngredients(inventory:Inventory = null) -> bool:
if inventory == null:
inventory = ITEM.PLAYER_INVENTORY
for ingredient in ingredients:
if !inventory.hasItem(ingredient.type, ingredient.quantity):
return false
return true
func make(inventory:Inventory = null) -> void:
if inventory == null:
inventory = ITEM.PLAYER_INVENTORY
for ingredient in ingredients:
inventory.removeItem(ingredient.type, ingredient.quantity)
for output in outputs:
inventory.addItem(output.type, output.quantity)
timesMade += 1

View File

@@ -1,4 +0,0 @@
class_name RecipeIngredient extends Resource
@export var thing:int = 0
@export var count:int = 1

View File

@@ -18,9 +18,9 @@ func start() -> void:
var text:String = ""; var text:String = "";
match getType: match getType:
GetType.FOUND: GetType.FOUND:
text = "Found " + str(quantity) + " " + Item.getName(itemType, quantity) + "."; text = "Found " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
GetType.GIVEN: GetType.GIVEN:
text = "Received " + str(quantity) + " " + Item.getName(itemType, quantity) + "."; text = "Received " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
_: _:
pass pass
VN.getTextbox().setText(text); VN.getTextbox().setText(text);

View File

@@ -1,5 +1,8 @@
class_name EventStartQuest extends "res://scripts/Event/Quest/EventShowQuest.gd" class_name EventStartQuest extends "res://scripts/Event/Quest/EventShowQuest.gd"
@export_category("Event Start Quest")
var nothing:bool = false
func start(): func start():
assert(QUEST.quests.has(quest), "Quest not found.") assert(QUEST.quests.has(quest), "Quest not found.")
QUEST.quests[quest].start() QUEST.quests[quest].start()

View File

@@ -7,7 +7,7 @@ enum ItemSortType {
class ItemStackNameComparator: class ItemStackNameComparator:
static func _sort(a, b): static func _sort(a, b):
return a.item.getName().to_lower() < b.item.getName().to_lower() return Item.getItemName(a).to_lower() < Item.getItemName(b).to_lower()
class ItemStackTypeComparator: class ItemStackTypeComparator:
static func _sort(a, b): static func _sort(a, b):

View File

@@ -1,14 +1,22 @@
class_name Item class_name Item
enum Type { enum Type {
POTION, # Items
ONION POTION = 1,
# Ingredients
ONION = 2,
SWEET_POTATO = 3,
# Recipe outputs
ASH_BAKED_SWEET_POTATO = 4,
}; };
enum Category { enum Category {
MEDICINE, MEDICINE,
KEY_ITEM, KEY_ITEM,
INGREDIENT INGREDIENT,
FOOD
}; };
static func isStackable(itemType:Type) -> bool: static func isStackable(itemType:Type) -> bool:
@@ -17,7 +25,7 @@ static func isStackable(itemType:Type) -> bool:
_: _:
return true return true
static func getName(itemType:Type, count:int = 1) -> String: static func getItemName(itemType:Type, count:int = 1) -> String:
match itemType: match itemType:
Type.POTION: Type.POTION:
if count != 1: if count != 1:
@@ -29,35 +37,52 @@ static func getName(itemType:Type, count:int = 1) -> String:
return "Onions" return "Onions"
return "Onion" return "Onion"
Type.SWEET_POTATO:
if count != 1:
return "Sweet Potatoes"
return "Sweet Potato"
Type.ASH_BAKED_SWEET_POTATO:
if count != 1:
return "Ash-Baked Sweet Potatoes"
return "Ash-Baked Sweet Potato"
_: _:
assert(false, "Invalid item type") assert(false, "Invalid item type")
return "" return ""
# func getName() -> String: static func getItemDescription(itemType:Type) -> String:
# push_error("getName() must be overridden in derived classes"); match itemType:
# return ""; Type.POTION:
return "A potent healing drink, infused with magical properties. Restores health and stamina."
# func isStackable() -> bool: Type.ONION:
# return true; return "A common vegetable, known for its strong flavor and aroma. Can be used in cooking."
# func isDroppable() -> bool: Type.SWEET_POTATO:
# return true; return "A nutritious root vegetable, sweet and starchy. Can be used in cooking."
# func isSellable() -> bool: Type.ASH_BAKED_SWEET_POTATO:
# return true; return "Tender, warm, and sweet meal, made by baking a sweet potato in campfire embers. Comforting, simple, and gently filling."
# func getSellPrice() -> int: _:
# return 0; assert(false, "Invalid item type")
return ""
# func getBuyPrice() -> int: static func getItemCategory(itemType:Type) -> Category:
# return 0; match itemType:
Type.POTION:
return Category.MEDICINE
# func isConsumable() -> bool: Type.ONION:
# return false; return Category.INGREDIENT
# func consume() -> void: Type.SWEET_POTATO:
# pass return Category.INGREDIENT
# func getCategory() -> ItemCategory: Type.ASH_BAKED_SWEET_POTATO:
# push_error("getCategory() must be overriden in derived class"); return Category.FOOD
# return ItemCategory.MEDICINE;
_:
assert(false, "Invalid item type")
return Category.KEY_ITEM

View File

@@ -0,0 +1,4 @@
class_name ItemResource extends Resource
@export var itemType:Item.Type = Item.Type.ONION;
@export var count:int = 1;

View File

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

View File

@@ -1,5 +1,5 @@
class_name ItemLine extends HBoxContainer class_name ItemLine extends HBoxContainer
func setStack(stack:ItemStack) -> void: func setStack(stack:ItemStack) -> void:
$ItemName.text = Item.getName(stack.type, 1) $ItemName.text = Item.getItemName(stack.type, 1)
$ItemQuantity.text = str(stack.quantity) $ItemQuantity.text = str(stack.quantity)