diff --git a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs index 62dbda34ad..8ccaa8c91a 100644 --- a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs @@ -1,14 +1,6 @@ -using System.Collections.Generic; -using Content.Server.GameObjects.Components.Sound; -using Content.Server.GameObjects.EntitySystems; -using Content.Server.GameObjects.Components; -using Content.Shared.Audio; -using Robust.Server.GameObjects; -using Robust.Shared.Audio; +using Content.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Prototypes; using Robust.Shared.ViewVariables; using Content.Server.GameObjects.Components.Chemistry; using Content.Shared.Chemistry; @@ -64,33 +56,40 @@ namespace Content.Server.GameObjects.Components.Kitchen { if(CanSatisfyRecipe(r)) { + RemoveContents(r); var resultPrototype = r.Result; _entityManager.SpawnEntity(resultPrototype, Owner.Transform.GridPosition); return; } - } } - } - private bool CanSatisfyRecipe(MealRecipePrototype recipe) + private bool CanSatisfyRecipe(FoodRecipePrototype recipe) { - foreach(var ingredient in recipe.Ingredients) + foreach (var item in recipe.Ingredients) { - var ingName = ingredient.Key.ToString(); - var ingQuantity = ingredient.Value; - if (_contents.ContainsReagent(ingName, out var amt) && amt >= ingQuantity) + if (!_contents.ContainsReagent(item.Key, out var amount)) { - _contents.TryRemoveReagent(ingName, ReagentUnit.New(ingQuantity)); - return true; + return false; } + if (amount.Int() < item.Value) + { + return false; + } } - return false; + return true; } + private void RemoveContents(FoodRecipePrototype recipe) + { + foreach(var item in recipe.Ingredients) + { + _contents.TryRemoveReagent(item.Key, ReagentUnit.New(item.Value)); + } + } } diff --git a/Content.Shared/Kitchen/RecipeManager.cs b/Content.Shared/Kitchen/RecipeManager.cs index 81c15279c1..6b653ee96a 100644 --- a/Content.Shared/Kitchen/RecipeManager.cs +++ b/Content.Shared/Kitchen/RecipeManager.cs @@ -12,21 +12,21 @@ namespace Content.Shared.Kitchen #pragma warning disable 649 [Dependency] private readonly IPrototypeManager _prototypeManager; #pragma warning restore 649 - public List Recipes { get; private set; } + public List Recipes { get; private set; } public void Initialize() { - Recipes = new List(); - foreach (var item in _prototypeManager.EnumeratePrototypes()) + Recipes = new List(); + foreach (var item in _prototypeManager.EnumeratePrototypes()) { Recipes.Add(item); } Recipes.Sort(new RecipeComparer()); } - private class RecipeComparer : IComparer + private class RecipeComparer : IComparer { - int IComparer.Compare(MealRecipePrototype x, MealRecipePrototype y) + int IComparer.Compare(FoodRecipePrototype x, FoodRecipePrototype y) { if (x == null || y == null) { diff --git a/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs b/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs index d61d11590d..f120499af4 100644 --- a/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs +++ b/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs @@ -15,7 +15,7 @@ namespace Content.Shared.Prototypes.Kitchen [Prototype("microwaveMealRecipe")] - public class MealRecipePrototype : IPrototype, IIndexedPrototype + public class FoodRecipePrototype : IPrototype, IIndexedPrototype { private string _id; diff --git a/Resources/Prototypes/Kitchen/meal_recipes.yml b/Resources/Prototypes/Kitchen/meal_recipes.yml index 2c1c261fcc..a383a7fbce 100644 --- a/Resources/Prototypes/Kitchen/meal_recipes.yml +++ b/Resources/Prototypes/Kitchen/meal_recipes.yml @@ -1,7 +1,7 @@ - type: microwaveMealRecipe id: RecipeCheeseburger - name: "Cheeseburger Recipe" + name: Cheeseburger Recipe result: FoodCheeseburger ingredients: - chem.Flour: 15 + chem.H2O: 15 chem.Nutriment: 5