From f76a087e916f27f368c4066ad066d715e47b914c Mon Sep 17 00:00:00 2001 From: FL-OZ Date: Sun, 26 Apr 2020 15:44:20 -0500 Subject: [PATCH] Add meal recipe prototype class and yaml file. Add bare bones MicrowaveComponent. --- .../Kitchen/KitchenMicrowaveComponent.cs | 34 +++++++++++++ .../Kitchen/MicrowaveMealRecipePrototype.cs | 51 +++++++++++++++++++ Resources/Prototypes/Kitchen/meal_recipes.yml | 7 +++ 3 files changed, 92 insertions(+) create mode 100644 Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs create mode 100644 Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs create mode 100644 Resources/Prototypes/Kitchen/meal_recipes.yml diff --git a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs new file mode 100644 index 0000000000..a997471845 --- /dev/null +++ b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs @@ -0,0 +1,34 @@ +using Content.Server.GameObjects.Components.Sound; +using Content.Server.GameObjects.EntitySystems; +using Content.Shared.Audio; +using Robust.Server.GameObjects; +using Robust.Shared.Audio; +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.Random; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using Robust.Shared.Prototypes; +using Robust.Shared.Random; +using Robust.Shared.Serialization; +using Robust.Shared.Utility; +using Robust.Shared.ViewVariables; + +namespace Content.Server.GameObjects.Components.Kitchen +{ + [RegisterComponent] + + public class KitchenMicrowaveComponent : Component, IActivate + { + +#pragma warning disable 649 + [Dependency] private readonly IPrototypeManager _prototypeManager; +#pragma warning restore 649 + + public override string Name => "Microwave"; + + public void Activate(ActivateEventArgs eventArgs) + { + + } + } +} diff --git a/Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs b/Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs new file mode 100644 index 0000000000..d20d63025b --- /dev/null +++ b/Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Robust.Shared.Localization; +using Robust.Shared.Prototypes; +using Robust.Shared.Utility; +using YamlDotNet.RepresentationModel; + +namespace Content.Shared.Kitchen +{ + /// + /// A recipe for space microwaves. + /// + + [Prototype("microwaveMealRecipe")] + + public class FoodRecipe : IPrototype, IIndexedPrototype + { + + public string ID {get; private set;} + public string Name {get; private set;} + + public string Description {get; private set;} + + public Dictionary Ingredients {get; private set;} + + private const char Seperator = ','; + + 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)) + { + Ingredients = new Dictionary(); + foreach (var node in tempDict.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); + + } + } + + } + } +} diff --git a/Resources/Prototypes/Kitchen/meal_recipes.yml b/Resources/Prototypes/Kitchen/meal_recipes.yml new file mode 100644 index 0000000000..4082dad6eb --- /dev/null +++ b/Resources/Prototypes/Kitchen/meal_recipes.yml @@ -0,0 +1,7 @@ +- type: microwaveMealRecipe + id: RecipeBurger + name: "Burger" + description: "A burger, in space." + ingredients: + - "Flour,15" + - "Meat,5"