Reformat the way recipe prototypes work to something sensible.
More work on Microwave component.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user