ProjectDDD/Assets/_DDD/_Scripts/GameUi/RestaurantManagementUi/ExtensionsUi/FoodDataExtensions.cs

36 lines
1.5 KiB
C#

using System.Collections.Generic;
namespace DDD
{
public static class FoodDataExtensions
{
public static List<IngredientEntry> GetIngredients(this FoodData 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 FoodData 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 FoodData data)
=> CraftingHelper.GetCraftableCount(data.GetIngredients());
public static bool TryConsumeIngredients(this FoodData data, int count = 1)
=> CraftingHelper.TryConsumeIngredients(data.GetIngredients(), count);
public static int ConsumeAllCraftableIngredients(this FoodData data)
{
var ingredients = data.GetIngredients();
int count = CraftingHelper.GetCraftableCount(ingredients);
return CraftingHelper.ConsumeAll(ingredients, count);
}
public static void RefundIngredients(this FoodData data, int count = 1)
=> CraftingHelper.RefundIngredients(data.GetIngredients(), count);
}
}