2025-07-25 07:58:53 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
|
|
|
public static class FoodDataExtensions
|
|
|
|
{
|
2025-07-29 15:56:47 +00:00
|
|
|
public static List<IngredientEntry> GetIngredients(this FoodData data) => CraftingHelper.ExtractIngredients(
|
2025-07-25 07:58:53 +00:00
|
|
|
data.IngredientKey1, data.IngredientAmount1,
|
|
|
|
data.IngredientKey2, data.IngredientAmount2,
|
|
|
|
data.IngredientKey3, data.IngredientAmount3,
|
|
|
|
data.IngredientKey4, data.IngredientAmount4
|
|
|
|
);
|
|
|
|
|
2025-07-27 22:55:07 +00:00
|
|
|
public static List<TasteData> GetTasteDatas(this FoodData data)
|
2025-07-28 11:33:04 +00:00
|
|
|
=> CraftingHelper.ResolveTasteDatas(
|
|
|
|
new[] { data.TasteKey1, data.TasteKey2, data.TasteKey3, data.TasteKey4, data.TasteKey5, data.TasteKey6 },
|
2025-07-30 09:42:33 +00:00
|
|
|
DataManager.Instance.GetDataSo<TasteDataSo>()
|
2025-07-28 11:33:04 +00:00
|
|
|
);
|
2025-07-27 22:55:07 +00:00
|
|
|
|
2025-07-28 11:33:04 +00:00
|
|
|
public static int GetCraftableCount(this FoodData data)
|
|
|
|
=> CraftingHelper.GetCraftableCount(data.GetIngredients());
|
2025-07-27 22:55:07 +00:00
|
|
|
|
2025-07-28 11:33:04 +00:00
|
|
|
public static bool TryConsumeIngredients(this FoodData data, int count = 1)
|
|
|
|
=> CraftingHelper.TryConsumeIngredients(data.GetIngredients(), count);
|
2025-07-27 22:55:07 +00:00
|
|
|
|
2025-07-28 11:33:04 +00:00
|
|
|
public static int ConsumeAllCraftableIngredients(this FoodData data)
|
2025-07-25 07:58:53 +00:00
|
|
|
{
|
|
|
|
var ingredients = data.GetIngredients();
|
2025-07-28 11:33:04 +00:00
|
|
|
int count = CraftingHelper.GetCraftableCount(ingredients);
|
|
|
|
return CraftingHelper.ConsumeAll(ingredients, count);
|
2025-07-25 07:58:53 +00:00
|
|
|
}
|
2025-07-28 11:33:04 +00:00
|
|
|
|
|
|
|
public static void RefundIngredients(this FoodData data, int count = 1)
|
|
|
|
=> CraftingHelper.RefundIngredients(data.GetIngredients(), count);
|
2025-07-25 07:58:53 +00:00
|
|
|
}
|
|
|
|
}
|