* Add special microwave board to Combat Bakery Kit * use event instead of trycomp * make the board sus * add instructions note * embarrassing typo * Add functionality to Donk Co. microwave instead * update note
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using System.Linq;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Kitchen
|
|
{
|
|
public sealed class RecipeManager
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
public List<FoodRecipePrototype> Recipes { get; private set; } = new();
|
|
|
|
public void Initialize()
|
|
{
|
|
Recipes = new List<FoodRecipePrototype>();
|
|
foreach (var item in _prototypeManager.EnumeratePrototypes<FoodRecipePrototype>())
|
|
{
|
|
if (!item.SecretRecipe)
|
|
Recipes.Add(item);
|
|
}
|
|
|
|
Recipes.Sort(new RecipeComparer());
|
|
}
|
|
/// <summary>
|
|
/// Check if a prototype ids appears in any of the recipes that exist.
|
|
/// </summary>
|
|
public bool SolidAppears(string solidId)
|
|
{
|
|
return Recipes.Any(recipe => recipe.IngredientsSolids.ContainsKey(solidId));
|
|
}
|
|
|
|
private sealed class RecipeComparer : Comparer<FoodRecipePrototype>
|
|
{
|
|
public override int Compare(FoodRecipePrototype? x, FoodRecipePrototype? y)
|
|
{
|
|
if (x == null || y == null)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
var nx = x.IngredientCount();
|
|
var ny = y.IngredientCount();
|
|
return -nx.CompareTo(ny);
|
|
}
|
|
}
|
|
}
|
|
}
|