2020-04-30 18:08:51 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Content.Shared.Prototypes.Kitchen;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Kitchen
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public class RecipeManager
|
|
|
|
|
|
{
|
|
|
|
|
|
#pragma warning disable 649
|
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
|
|
|
|
|
#pragma warning restore 649
|
2020-04-30 23:07:27 -05:00
|
|
|
|
public List<FoodRecipePrototype> Recipes { get; private set; }
|
2020-04-30 18:08:51 -05:00
|
|
|
|
|
|
|
|
|
|
public void Initialize()
|
|
|
|
|
|
{
|
2020-04-30 23:07:27 -05:00
|
|
|
|
Recipes = new List<FoodRecipePrototype>();
|
|
|
|
|
|
foreach (var item in _prototypeManager.EnumeratePrototypes<FoodRecipePrototype>())
|
2020-04-30 18:08:51 -05:00
|
|
|
|
{
|
|
|
|
|
|
Recipes.Add(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Recipes.Sort(new RecipeComparer());
|
|
|
|
|
|
}
|
2020-05-04 13:54:54 -04:00
|
|
|
|
private class RecipeComparer : Comparer<FoodRecipePrototype>
|
2020-04-30 18:08:51 -05:00
|
|
|
|
{
|
2020-05-04 13:54:54 -04:00
|
|
|
|
public override int Compare(FoodRecipePrototype x, FoodRecipePrototype y)
|
2020-04-30 18:08:51 -05:00
|
|
|
|
{
|
|
|
|
|
|
if (x == null || y == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2020-05-04 13:54:54 -04:00
|
|
|
|
|
|
|
|
|
|
return -x.IngredientsReagents.Count.CompareTo(y.IngredientsReagents.Count);
|
2020-04-30 18:08:51 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|