Unfuck mostly everything.
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.Kitchen
|
||||
{
|
||||
/// <summary>
|
||||
/// A recipe for space microwaves.
|
||||
/// </summary>
|
||||
|
||||
[Prototype("microwaveMealRecipe")]
|
||||
|
||||
public class MicrowaveMealRecipePrototype : IPrototype, IIndexedPrototype
|
||||
{
|
||||
|
||||
private string _id;
|
||||
private string _name;
|
||||
private string _result;
|
||||
private Dictionary<string, int> _ingredients;
|
||||
|
||||
public string ID => _id;
|
||||
public string Name => Loc.GetString(_name);
|
||||
public string Result => _result;
|
||||
public IReadOnlyDictionary<string, int> Ingredients => _ingredients;
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _name, "name", string.Empty);
|
||||
serializer.DataField(ref _result, "result", string.Empty);
|
||||
serializer.DataField(ref _ingredients, "ingredients", new Dictionary<string, int>());
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Content.Shared/Kitchen/RecipeManager.cs
Normal file
52
Content.Shared/Kitchen/RecipeManager.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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
|
||||
public List<MealRecipePrototype> Recipes { get; private set; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Recipes = new List<MealRecipePrototype>();
|
||||
foreach (var item in _prototypeManager.EnumeratePrototypes<MealRecipePrototype>())
|
||||
{
|
||||
Recipes.Add(item);
|
||||
}
|
||||
|
||||
Recipes.Sort(new RecipeComparer());
|
||||
}
|
||||
private class RecipeComparer : IComparer<MealRecipePrototype>
|
||||
{
|
||||
int IComparer<MealRecipePrototype>.Compare(MealRecipePrototype x, MealRecipePrototype y)
|
||||
{
|
||||
if (x == null || y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (x.Ingredients.Count < y.Ingredients.Count)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (x.Ingredients.Count > y.Ingredients.Count)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user