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
+12 -20
View File
@@ -1,32 +1,23 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Godot;
public class Item : Ingredient
public class Item
{
public Dictionary<Ingredient, int> ingredients;
public double craftTime;
public double elapsedCraftTime;
public int amountCrafted;
public Item(string name, Dictionary<Ingredient, int> ingredients, int stackSize, double craftTime)
{
this.name = name;
this.ingredients = ingredients;
currentAmount = 0;
this.stackSize = stackSize;
this.craftTime = craftTime;
amountCrafted = 0;
}
public ItemData data;
public int currentAmount = 0;
public double elapsedCraftTime = 0;
public int amountCrafted = 0;
public Texture2D display;
public CraftingResult Craft(int amount, double delta)
{
if (GameData.inventory.CanCraft(ingredients, amount-amountCrafted))
if (GameData.inventory.CanCraft(data.Inputs, amount - amountCrafted))
{
elapsedCraftTime += delta;
if (elapsedCraftTime >= craftTime)
if (elapsedCraftTime >= data.CraftTime)
{
elapsedCraftTime -= craftTime;
elapsedCraftTime -= data.CraftTime;
currentAmount += 1;
amountCrafted++;
if (amountCrafted >= amount)
@@ -40,4 +31,5 @@ public class Item : Ingredient
}
return CraftingResult.FAILED;
}
}
}