diff --git a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs
index 14723c806d..bf23b5134b 100644
--- a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs
+++ b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs
@@ -76,13 +76,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
private BoundUserInterface _userInterface;
private Container _storage;
- ///
- /// A dictionary of PrototypeIDs and integers representing quantity.
- ///
- private Dictionary _solids;
- private List _solidsVisualList;
-
-
+
public override void ExposeData(ObjectSerializer serializer)
{
@@ -107,9 +101,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
_audioSystem = _entitySystemManager.GetEntitySystem();
_userInterface = Owner.GetComponent()
.GetBoundUserInterface(MicrowaveUiKey.Key);
-
- _solids = new Dictionary();
- _solidsVisualList = new List();
+
_userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
}
@@ -149,7 +141,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
case MicrowaveVaporizeReagentIndexedMessage msg:
if (HasContents)
{
- _solution.TryRemoveReagent(msg.ReagentQuantity.ReagentId, msg.ReagentQuantity.Quantity);
+ VaporizeReagentWithReagentQuantity(msg.ReagentQuantity);
ClickSound();
UpdateUserInterface();
}
@@ -175,13 +167,14 @@ namespace Content.Server.GameObjects.Components.Kitchen
private void UpdateUserInterface()
{
- _solidsVisualList.Clear();
+ var solidsVisualList = new List();
+ solidsVisualList.Clear();
foreach(var item in _storage.ContainedEntities)
{
- _solidsVisualList.Add(item.Uid);
+ solidsVisualList.Add(item.Uid);
}
- _userInterface.SetState(new MicrowaveUpdateUserInterfaceState(_solution.Solution.Contents, _solidsVisualList));
+ _userInterface.SetState(new MicrowaveUpdateUserInterfaceState(_solution.Solution.Contents, solidsVisualList));
}
void IActivate.Activate(ActivateEventArgs eventArgs)
@@ -257,16 +250,17 @@ namespace Content.Server.GameObjects.Components.Kitchen
_busy = true;
// Convert storage into Dictionary of ingredients
- _solids.Clear();
+ var solidsDict = new Dictionary();
+ solidsDict.Clear();
foreach(var item in _storage.ContainedEntities)
{
- if(_solids.ContainsKey(item.Prototype.ID))
+ if(solidsDict.ContainsKey(item.Prototype.ID))
{
- _solids[item.Prototype.ID]++;
+ solidsDict[item.Prototype.ID]++;
}
else
{
- _solids.Add(item.Prototype.ID, 1);
+ solidsDict.Add(item.Prototype.ID, 1);
}
}
@@ -274,7 +268,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
FoodRecipePrototype recipeToCook = null;
foreach(var r in _recipeManager.Recipes)
{
- if (!CanSatisfyRecipe(r))
+ if (!CanSatisfyRecipe(r, solidsDict))
{
continue;
}
@@ -316,9 +310,9 @@ namespace Content.Server.GameObjects.Components.Kitchen
_solution.RemoveAllSolution();
}
- private void VaporizeReagentWithIndex()
+ private void VaporizeReagentWithReagentQuantity(Solution.ReagentQuantity reagentQuantity)
{
-
+ _solution.TryRemoveReagent(reagentQuantity.ReagentId, reagentQuantity.Quantity);
}
private void VaporizeSolids()
@@ -329,7 +323,6 @@ namespace Content.Server.GameObjects.Components.Kitchen
_storage.Remove(item);
item.Delete();
}
- _solids.Clear();
}
private void EjectSolids()
@@ -339,13 +332,14 @@ namespace Content.Server.GameObjects.Components.Kitchen
{
_storage.Remove(_storage.ContainedEntities.ElementAt(i));
}
-
- _solids.Clear();
}
private void EjectSolidWithIndex(EntityUid entityID)
{
- _storage.Remove(_entityManager.GetEntity(entityID));
+ if (_entityManager.EntityExists(entityID))
+ {
+ _storage.Remove(_entityManager.GetEntity(entityID));
+ }
}
@@ -374,7 +368,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
}
- private bool CanSatisfyRecipe(FoodRecipePrototype recipe)
+ private bool CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary solids)
{
foreach (var reagent in recipe.IngredientsReagents)
{
@@ -391,12 +385,12 @@ namespace Content.Server.GameObjects.Components.Kitchen
foreach (var solid in recipe.IngredientsSolids)
{
- if (!_solids.ContainsKey(solid.Key))
+ if (!solids.ContainsKey(solid.Key))
{
return false;
}
- if (_solids[solid.Key] < solid.Value)
+ if (solids[solid.Key] < solid.Value)
{
return false;
}
diff --git a/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs b/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs
index abae3d5eb1..0d64a7d073 100644
--- a/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs
+++ b/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs
@@ -19,29 +19,31 @@ namespace Content.Shared.Prototypes.Kitchen
{
private string _id;
- public string Name => Loc.GetString(Name);
private string _name;
- public string Result;
- public int CookTime;
+ private string _result;
+ private int _cookTime;
+
+ private Dictionary _ingsReagents;
+ private Dictionary _ingsSolids;
+
+ public string Name => Loc.GetString(_name);
+ public string ID => _id;
+ public string Result => _result;
+ public int CookTime => _cookTime;
public IReadOnlyDictionary IngredientsReagents => _ingsReagents;
public IReadOnlyDictionary IngredientsSolids => _ingsSolids;
- private Dictionary _ingsReagents;
- private Dictionary _ingsSolids;
-
-
- public string ID => _id;
-
+
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 _result, "result", string.Empty);
serializer.DataField(ref _ingsReagents, "reagents", new Dictionary());
serializer.DataField(ref _ingsSolids, "solids", new Dictionary());
- serializer.DataField(ref CookTime, "time", 5);
+ serializer.DataField(ref _cookTime, "time", 5);
}
}