using System.Linq; using Robust.Shared.Prototypes; namespace Content.Shared.Kitchen; /// /// A system that caches all available non-secret microwave recipes. /// public sealed partial class RecipeSystem : EntitySystem { /// /// A list of all recipes available to the recipe manager. /// /// /// Order matters! The microwave system will use the *first* valid recipe. /// For this reason, this list gets sorted by "complexity" - recipes with more ingredients /// are sorted first. We make the assumption that more complex recipes are more "specific" /// than less complex recipes whose requirements are also fulfilled. /// public List Recipes { get; private set; } = new(); public override void Initialize() { base.Initialize(); ReloadRecipes(); SubscribeLocalEvent(OnPrototypesReloaded); } private void OnPrototypesReloaded(PrototypesReloadedEventArgs args) { if (args.WasModified()) ReloadRecipes(); } private void ReloadRecipes() { Recipes = ProtoMan .EnumeratePrototypes() .Where(x => !x.SecretRecipe) .OrderByDescending(x => x.Priority) .ThenByDescending(x => x.Ingredients.Count()) .ToList(); } }