37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace DDD
|
|
{
|
|
public static class DrinkDataExtensions
|
|
{
|
|
public static List<IngredientEntry> GetIngredients(this DrinkData data)
|
|
=> CraftingHelper.ExtractIngredients(
|
|
data.IngredientKey1, data.IngredientAmount1,
|
|
data.IngredientKey2, data.IngredientAmount2,
|
|
data.IngredientKey3, data.IngredientAmount3,
|
|
data.IngredientKey4, data.IngredientAmount4
|
|
);
|
|
|
|
public static List<TasteData> GetTasteDatas(this DrinkData data)
|
|
=> CraftingHelper.ResolveTasteDatas(
|
|
new[] { data.TasteKey1, data.TasteKey2, data.TasteKey3, data.TasteKey4, data.TasteKey5, data.TasteKey6 },
|
|
DataManager.Instance.GetDataSo<TasteDataSo>()
|
|
);
|
|
|
|
public static int GetCraftableCount(this DrinkData data)
|
|
=> CraftingHelper.GetCraftableCount(data.GetIngredients());
|
|
|
|
public static bool TryConsumeIngredients(this DrinkData data, int count = 1)
|
|
=> CraftingHelper.TryConsumeIngredients(data.GetIngredients(), count);
|
|
|
|
public static int ConsumeAllCraftableIngredients(this DrinkData data)
|
|
{
|
|
var ingredients = data.GetIngredients();
|
|
int count = CraftingHelper.GetCraftableCount(ingredients);
|
|
return CraftingHelper.ConsumeAll(ingredients, count);
|
|
}
|
|
|
|
public static void RefundIngredients(this DrinkData data, int count = 1)
|
|
=> CraftingHelper.RefundIngredients(data.GetIngredients(), count);
|
|
}
|
|
} |