Reformat the way recipe prototypes work to something sensible.

More work on Microwave component.
This commit is contained in:
FL-OZ
2020-04-26 23:14:02 -05:00
parent f76a087e91
commit 7e4d4bb1d4
5 changed files with 160 additions and 28 deletions

View File

@@ -14,35 +14,25 @@ namespace Content.Shared.Kitchen
[Prototype("microwaveMealRecipe")]
public class FoodRecipe : IPrototype, IIndexedPrototype
public class MicrowaveMealRecipePrototype : IPrototype, IIndexedPrototype
{
public string ID {get; private set;}
public string Name {get; private set;}
public string Description {get; private set;}
public Dictionary<string,int> Ingredients {get; private set;}
private const char Seperator = ',';
public string OutPutPrototype { get; private set; }
public Dictionary<string,int> Ingredients {get; private set;}
public void LoadFrom(YamlMappingNode mapping)
{
ID = mapping.GetNode("id").ToString();
Name = Loc.GetString(mapping.GetNode("name").ToString());
Description = Loc.GetString(mapping.GetNode("description").ToString());
if(mapping.TryGetNode("ingredients", out YamlSequenceNode tempDict))
OutPutPrototype = mapping.GetNode("output").ToString();
if(mapping.TryGetNode("ingredients", out YamlMappingNode ingDict))
{
Ingredients = new Dictionary<string, int>();
foreach (var node in tempDict.Children)
foreach (var kvp in ingDict.Children)
{
var pair = node.ToString();
if (pair == null) continue;
var split = pair.Split(Seperator);
var ingnName = split[0];
if (int.TryParse(split[1], out var amt)) Ingredients.Add(ingnName, amt);
Ingredients.Add(kvp.Key.ToString(), kvp.Value.AsInt());
}
}