ProjectDDD/Assets/_DDD/_Scripts/GameUi/New/DrinkDataExtensions.cs

37 lines
1.5 KiB
C#
Raw Normal View History

2025-07-25 07:58:53 +00:00
using System.Collections.Generic;
namespace DDD
{
public static class DrinkDataExtensions
{
public static List<IngredientEntry> GetIngredients(this DrinkData data)
2025-07-28 11:33:04 +00:00
=> 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 DrinkData data)
2025-07-28 11:33:04 +00:00
=> CraftingHelper.ResolveTasteDatas(
new[] { data.TasteKey1, data.TasteKey2, data.TasteKey3, data.TasteKey4, data.TasteKey5, data.TasteKey6 },
DataManager.Instance.TasteDataSo
);
2025-07-27 22:55:07 +00:00
2025-07-28 11:33:04 +00:00
public static int GetCraftableCount(this DrinkData 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 DrinkData 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 DrinkData 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 DrinkData data, int count = 1)
=> CraftingHelper.RefundIngredients(data.GetIngredients(), count);
2025-07-25 07:58:53 +00:00
}
}