prog
This commit is contained in:
@@ -46,7 +46,7 @@ interactEvent = NodePath("../../Events/TestConversation")
|
||||
|
||||
[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)
|
||||
itemType = 1
|
||||
itemType = 2
|
||||
quantity = 2
|
||||
|
||||
[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"]
|
||||
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"]
|
||||
script = ExtResource("10_avybc")
|
||||
|
@@ -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://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"]
|
||||
script = ExtResource("1_o4nv4")
|
||||
@@ -10,4 +23,7 @@ metadata/_custom_type_script = "uid://j87s6jrx8unn"
|
||||
[node name="Ash-Baked Sweet Potato" type="Node" parent="."]
|
||||
script = ExtResource("2_f5akq")
|
||||
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"
|
||||
|
@@ -1,8 +1,30 @@
|
||||
@tool
|
||||
class_name Recipe extends Node
|
||||
|
||||
@export var recipeName:String = ""
|
||||
@export var ingredients:Array[RecipeIngredient] = []
|
||||
@export var ingredients:Array[ItemResource] = []
|
||||
@export var outputs:Array[ItemResource] = []
|
||||
|
||||
func test():
|
||||
print("test")
|
||||
var learned:bool = false
|
||||
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
|
@@ -1,4 +0,0 @@
|
||||
class_name RecipeIngredient extends Resource
|
||||
|
||||
@export var thing:int = 0
|
||||
@export var count:int = 1
|
@@ -18,9 +18,9 @@ func start() -> void:
|
||||
var text:String = "";
|
||||
match getType:
|
||||
GetType.FOUND:
|
||||
text = "Found " + str(quantity) + " " + Item.getName(itemType, quantity) + ".";
|
||||
text = "Found " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
|
||||
GetType.GIVEN:
|
||||
text = "Received " + str(quantity) + " " + Item.getName(itemType, quantity) + ".";
|
||||
text = "Received " + str(quantity) + " " + Item.getItemName(itemType, quantity) + ".";
|
||||
_:
|
||||
pass
|
||||
VN.getTextbox().setText(text);
|
||||
|
@@ -1,5 +1,8 @@
|
||||
class_name EventStartQuest extends "res://scripts/Event/Quest/EventShowQuest.gd"
|
||||
|
||||
@export_category("Event Start Quest")
|
||||
var nothing:bool = false
|
||||
|
||||
func start():
|
||||
assert(QUEST.quests.has(quest), "Quest not found.")
|
||||
QUEST.quests[quest].start()
|
||||
|
@@ -7,7 +7,7 @@ enum ItemSortType {
|
||||
|
||||
class ItemStackNameComparator:
|
||||
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:
|
||||
static func _sort(a, b):
|
||||
|
@@ -1,14 +1,22 @@
|
||||
class_name Item
|
||||
|
||||
enum Type {
|
||||
POTION,
|
||||
ONION
|
||||
# Items
|
||||
POTION = 1,
|
||||
|
||||
# Ingredients
|
||||
ONION = 2,
|
||||
SWEET_POTATO = 3,
|
||||
|
||||
# Recipe outputs
|
||||
ASH_BAKED_SWEET_POTATO = 4,
|
||||
};
|
||||
|
||||
enum Category {
|
||||
MEDICINE,
|
||||
KEY_ITEM,
|
||||
INGREDIENT
|
||||
INGREDIENT,
|
||||
FOOD
|
||||
};
|
||||
|
||||
static func isStackable(itemType:Type) -> bool:
|
||||
@@ -17,7 +25,7 @@ static func isStackable(itemType:Type) -> bool:
|
||||
_:
|
||||
return true
|
||||
|
||||
static func getName(itemType:Type, count:int = 1) -> String:
|
||||
static func getItemName(itemType:Type, count:int = 1) -> String:
|
||||
match itemType:
|
||||
Type.POTION:
|
||||
if count != 1:
|
||||
@@ -29,35 +37,52 @@ static func getName(itemType:Type, count:int = 1) -> String:
|
||||
return "Onions"
|
||||
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")
|
||||
return ""
|
||||
|
||||
# func getName() -> String:
|
||||
# push_error("getName() must be overridden in derived classes");
|
||||
# return "";
|
||||
static func getItemDescription(itemType:Type) -> String:
|
||||
match itemType:
|
||||
Type.POTION:
|
||||
return "A potent healing drink, infused with magical properties. Restores health and stamina."
|
||||
|
||||
# func isStackable() -> bool:
|
||||
# return true;
|
||||
Type.ONION:
|
||||
return "A common vegetable, known for its strong flavor and aroma. Can be used in cooking."
|
||||
|
||||
# func isDroppable() -> bool:
|
||||
# return true;
|
||||
Type.SWEET_POTATO:
|
||||
return "A nutritious root vegetable, sweet and starchy. Can be used in cooking."
|
||||
|
||||
# func isSellable() -> bool:
|
||||
# return true;
|
||||
Type.ASH_BAKED_SWEET_POTATO:
|
||||
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:
|
||||
# return 0;
|
||||
static func getItemCategory(itemType:Type) -> Category:
|
||||
match itemType:
|
||||
Type.POTION:
|
||||
return Category.MEDICINE
|
||||
|
||||
# func isConsumable() -> bool:
|
||||
# return false;
|
||||
Type.ONION:
|
||||
return Category.INGREDIENT
|
||||
|
||||
# func consume() -> void:
|
||||
# pass
|
||||
|
||||
# func getCategory() -> ItemCategory:
|
||||
# push_error("getCategory() must be overriden in derived class");
|
||||
# return ItemCategory.MEDICINE;
|
||||
Type.SWEET_POTATO:
|
||||
return Category.INGREDIENT
|
||||
|
||||
Type.ASH_BAKED_SWEET_POTATO:
|
||||
return Category.FOOD
|
||||
|
||||
_:
|
||||
assert(false, "Invalid item type")
|
||||
return Category.KEY_ITEM
|
||||
|
4
scripts/Item/ItemResource.gd
Normal file
4
scripts/Item/ItemResource.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
class_name ItemResource extends Resource
|
||||
|
||||
@export var itemType:Item.Type = Item.Type.ONION;
|
||||
@export var count:int = 1;
|
1
scripts/Item/ItemResource.gd.uid
Normal file
1
scripts/Item/ItemResource.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c26aptwsjs044
|
@@ -1,5 +1,5 @@
|
||||
class_name ItemLine extends HBoxContainer
|
||||
|
||||
func setStack(stack:ItemStack) -> void:
|
||||
$ItemName.text = Item.getName(stack.type, 1)
|
||||
$ItemName.text = Item.getItemName(stack.type, 1)
|
||||
$ItemQuantity.text = str(stack.quantity)
|
||||
|
Reference in New Issue
Block a user