using System.Collections.Generic; using Robust.Shared.IoC; using Robust.Shared.Prototypes; namespace Content.Shared.Kitchen { public sealed class RecipeManager { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; public List Recipes { get; private set; } = new(); public void Initialize() { Recipes = new List(); foreach (var item in _prototypeManager.EnumeratePrototypes()) { Recipes.Add(item); } Recipes.Sort(new RecipeComparer()); } /// /// Check if a prototype ids appears in any of the recipes that exist. /// /// /// public bool SolidAppears(string solidId) { foreach(var recipe in Recipes) { if(recipe.IngredientsSolids.ContainsKey(solidId)) { return true; } } return false; } private sealed class RecipeComparer : Comparer { public override int Compare(FoodRecipePrototype? x, FoodRecipePrototype? y) { if (x == null || y == null) { return 0; } return -x.IngredientsReagents.Count.CompareTo(y.IngredientsReagents.Count); } } } }