Added requirements to mixer recipes

This commit is contained in:
Pasha Bibko
2026-04-28 11:43:13 +01:00
parent 3f12e49b0f
commit c116028016
3 changed files with 49 additions and 34 deletions

View File

@@ -11,11 +11,13 @@ namespace Fruitomation.Game
{
private struct Recipe
{
public BasicUpgrade Requirement;
public ItemType[] Ingredients;
public ItemType Product;
public Recipe(ItemType[] ingredients, ItemType product)
public Recipe(BasicUpgrade requirement, ItemType[] ingredients, ItemType product)
{
Requirement = requirement;
Ingredients = ingredients;
Product = product;
}
@@ -25,6 +27,7 @@ namespace Fruitomation.Game
{
new
(
BasicUpgrade.DriedFruitSelection,
new[]
{
ItemType.DriedAppleSlices,
@@ -36,6 +39,7 @@ namespace Fruitomation.Game
new
(
BasicUpgrade.AppleMangoJuice,
new[]
{
ItemType.AppleJuice,
@@ -46,6 +50,7 @@ namespace Fruitomation.Game
new
(
BasicUpgrade.SpicedBananaIceCream,
new[]
{
ItemType.BananaIceCream,
@@ -56,6 +61,7 @@ namespace Fruitomation.Game
new
(
BasicUpgrade.ExoticFruitSelection,
new[]
{
ItemType.SlicedKiwi,
@@ -68,6 +74,7 @@ namespace Fruitomation.Game
new
(
BasicUpgrade.SpicedPitayaIceCream,
new[]
{
ItemType.PitayaIceCream,
@@ -134,27 +141,30 @@ namespace Fruitomation.Game
foreach (Recipe recipe in Recipes)
{
bool hasAllIngredients = recipe.Ingredients.Aggregate(true,
(current, ingredient)
=> current && StoredItems.ContainsKey(ingredient)
);
if (hasAllIngredients)
if (UpgradeManager.Is(recipe.Requirement))
{
foreach (ItemType ingredient in recipe.Ingredients)
{
int count = StoredItems[ingredient] - 1;
if (count <= 0)
{
StoredItems.Remove(ingredient);
}
else
{
StoredItems[ingredient] = count;
}
}
bool hasAllIngredients = recipe.Ingredients.Aggregate(true,
(current, ingredient)
=> current && StoredItems.ContainsKey(ingredient)
);
FruitSpawner.SpawnItem(recipe.Product, OutputLocation.position);
if (hasAllIngredients)
{
foreach (ItemType ingredient in recipe.Ingredients)
{
int count = StoredItems[ingredient] - 1;
if (count <= 0)
{
StoredItems.Remove(ingredient);
}
else
{
StoredItems[ingredient] = count;
}
}
FruitSpawner.SpawnItem(recipe.Product, OutputLocation.position);
}
}
}
}