Remove unncessary class dictionary and list. Fix meal prototype properties.
This commit is contained in:
@@ -76,12 +76,6 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
private BoundUserInterface _userInterface;
|
private BoundUserInterface _userInterface;
|
||||||
|
|
||||||
private Container _storage;
|
private Container _storage;
|
||||||
/// <summary>
|
|
||||||
/// A dictionary of PrototypeIDs and integers representing quantity.
|
|
||||||
/// </summary>
|
|
||||||
private Dictionary<string, int> _solids;
|
|
||||||
private List<EntityUid> _solidsVisualList;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
@@ -108,8 +102,6 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
||||||
.GetBoundUserInterface(MicrowaveUiKey.Key);
|
.GetBoundUserInterface(MicrowaveUiKey.Key);
|
||||||
|
|
||||||
_solids = new Dictionary<string, int>();
|
|
||||||
_solidsVisualList = new List<EntityUid>();
|
|
||||||
_userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
|
_userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +141,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
case MicrowaveVaporizeReagentIndexedMessage msg:
|
case MicrowaveVaporizeReagentIndexedMessage msg:
|
||||||
if (HasContents)
|
if (HasContents)
|
||||||
{
|
{
|
||||||
_solution.TryRemoveReagent(msg.ReagentQuantity.ReagentId, msg.ReagentQuantity.Quantity);
|
VaporizeReagentWithReagentQuantity(msg.ReagentQuantity);
|
||||||
ClickSound();
|
ClickSound();
|
||||||
UpdateUserInterface();
|
UpdateUserInterface();
|
||||||
}
|
}
|
||||||
@@ -175,13 +167,14 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
private void UpdateUserInterface()
|
private void UpdateUserInterface()
|
||||||
{
|
{
|
||||||
_solidsVisualList.Clear();
|
var solidsVisualList = new List<EntityUid>();
|
||||||
|
solidsVisualList.Clear();
|
||||||
foreach(var item in _storage.ContainedEntities)
|
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)
|
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||||
@@ -257,16 +250,17 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
_busy = true;
|
_busy = true;
|
||||||
// Convert storage into Dictionary of ingredients
|
// Convert storage into Dictionary of ingredients
|
||||||
_solids.Clear();
|
var solidsDict = new Dictionary<string, int>();
|
||||||
|
solidsDict.Clear();
|
||||||
foreach(var item in _storage.ContainedEntities)
|
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
|
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;
|
FoodRecipePrototype recipeToCook = null;
|
||||||
foreach(var r in _recipeManager.Recipes)
|
foreach(var r in _recipeManager.Recipes)
|
||||||
{
|
{
|
||||||
if (!CanSatisfyRecipe(r))
|
if (!CanSatisfyRecipe(r, solidsDict))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -316,9 +310,9 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
_solution.RemoveAllSolution();
|
_solution.RemoveAllSolution();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VaporizeReagentWithIndex()
|
private void VaporizeReagentWithReagentQuantity(Solution.ReagentQuantity reagentQuantity)
|
||||||
{
|
{
|
||||||
|
_solution.TryRemoveReagent(reagentQuantity.ReagentId, reagentQuantity.Quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VaporizeSolids()
|
private void VaporizeSolids()
|
||||||
@@ -329,7 +323,6 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
_storage.Remove(item);
|
_storage.Remove(item);
|
||||||
item.Delete();
|
item.Delete();
|
||||||
}
|
}
|
||||||
_solids.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EjectSolids()
|
private void EjectSolids()
|
||||||
@@ -339,13 +332,14 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
{
|
{
|
||||||
_storage.Remove(_storage.ContainedEntities.ElementAt(i));
|
_storage.Remove(_storage.ContainedEntities.ElementAt(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
_solids.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EjectSolidWithIndex(EntityUid entityID)
|
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<string,int> solids)
|
||||||
{
|
{
|
||||||
foreach (var reagent in recipe.IngredientsReagents)
|
foreach (var reagent in recipe.IngredientsReagents)
|
||||||
{
|
{
|
||||||
@@ -391,12 +385,12 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
foreach (var solid in recipe.IngredientsSolids)
|
foreach (var solid in recipe.IngredientsSolids)
|
||||||
{
|
{
|
||||||
if (!_solids.ContainsKey(solid.Key))
|
if (!solids.ContainsKey(solid.Key))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_solids[solid.Key] < solid.Value)
|
if (solids[solid.Key] < solid.Value)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,18 +19,20 @@ namespace Content.Shared.Prototypes.Kitchen
|
|||||||
{
|
{
|
||||||
|
|
||||||
private string _id;
|
private string _id;
|
||||||
public string Name => Loc.GetString(Name);
|
|
||||||
private string _name;
|
private string _name;
|
||||||
public string Result;
|
private string _result;
|
||||||
public int CookTime;
|
private int _cookTime;
|
||||||
public IReadOnlyDictionary<string, int> IngredientsReagents => _ingsReagents;
|
|
||||||
public IReadOnlyDictionary<string, int> IngredientsSolids => _ingsSolids;
|
|
||||||
|
|
||||||
private Dictionary<string, int> _ingsReagents;
|
private Dictionary<string, int> _ingsReagents;
|
||||||
private Dictionary<string, int> _ingsSolids;
|
private Dictionary<string, int> _ingsSolids;
|
||||||
|
|
||||||
|
public string Name => Loc.GetString(_name);
|
||||||
public string ID => _id;
|
public string ID => _id;
|
||||||
|
public string Result => _result;
|
||||||
|
public int CookTime => _cookTime;
|
||||||
|
public IReadOnlyDictionary<string, int> IngredientsReagents => _ingsReagents;
|
||||||
|
public IReadOnlyDictionary<string, int> IngredientsSolids => _ingsSolids;
|
||||||
|
|
||||||
|
|
||||||
public void LoadFrom(YamlMappingNode mapping)
|
public void LoadFrom(YamlMappingNode mapping)
|
||||||
{
|
{
|
||||||
@@ -38,10 +40,10 @@ namespace Content.Shared.Prototypes.Kitchen
|
|||||||
|
|
||||||
serializer.DataField(ref _id, "id", string.Empty);
|
serializer.DataField(ref _id, "id", string.Empty);
|
||||||
serializer.DataField(ref _name, "name", 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<string, int>());
|
serializer.DataField(ref _ingsReagents, "reagents", new Dictionary<string, int>());
|
||||||
serializer.DataField(ref _ingsSolids, "solids", new Dictionary<string, int>());
|
serializer.DataField(ref _ingsSolids, "solids", new Dictionary<string, int>());
|
||||||
serializer.DataField(ref CookTime, "time", 5);
|
serializer.DataField(ref _cookTime, "time", 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user