Improved recipes and added resources to it. Changed how ingredients and items work.

This commit is contained in:
=
2026-05-05 19:26:31 +02:00
parent fc26fa2a75
commit a320a86a2f
9 changed files with 248 additions and 135 deletions
+11 -11
View File
@@ -3,23 +3,23 @@ using Godot;
public class Inventory
{
public List<Ingredient> inventory = new();
public List<Item> inventory = new();
public int maxInventorySize = 8;
public bool AddIngredient(Ingredient ingredient, int amount)
public bool AddItem(Item item, int amount)
{
Ingredient ing = inventory.Find(x => x.name == ingredient.name && x.currentAmount + amount <= x.stackSize);
if (ing != null)
Item inventoryItem = inventory.Find(x => x.data.Id == item.data.Id && x.currentAmount + amount <= x.data.StackSize);
if (inventoryItem != null)
{
ing.currentAmount += amount;
inventoryItem.currentAmount += amount;
return true;
}
else
{
if (inventory.Count < maxInventorySize)
{
inventory.Add(ingredient);
inventory.Add(item);
inventory[inventory.Count - 1].currentAmount += amount;
return true;
}
@@ -27,14 +27,14 @@ public class Inventory
return false;
}
public bool CanCraft(Dictionary<Ingredient, int> neededIngredients, int amount)
public bool CanCraft(List<Ingredient> neededIngredients, int amount)
{
bool canCraft = true;
Ingredient ingredient;
foreach(Ingredient key in neededIngredients.Keys)
Item item;
foreach(Ingredient ingredient in neededIngredients)
{
ingredient = inventory.Find(x => x.name == key.name && x.currentAmount >= neededIngredients[key] * amount);
if (ingredient == null)
item = inventory.Find(x => x.data.Id == ingredient.item && x.currentAmount >= ingredient.amount * amount);
if (item == null)
{
canCraft = false;
break;