Fix bug where lathe databases didn't get serialized correctly. (#252)

This commit is contained in:
Víctor Aguilera Puerto
2019-06-02 01:18:54 +02:00
committed by Pieter-Jan Briers
parent dd13d969b2
commit 50bc1bff48
2 changed files with 24 additions and 17 deletions

View File

@@ -75,15 +75,34 @@ namespace Content.Shared.GameObjects.Components.Research
{
base.ExposeData(serializer);
var recipes = serializer.ReadDataField("recipes", new List<string>());
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
foreach (var id in recipes)
if (serializer.Reading)
{
if (!prototypeManager.TryIndex(id, out LatheRecipePrototype recipe)) continue;
_recipes.Add(recipe);
var recipes = serializer.ReadDataField("recipes", new List<string>());
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
foreach (var id in recipes)
{
if (!prototypeManager.TryIndex(id, out LatheRecipePrototype recipe)) continue;
_recipes.Add(recipe);
}
} else if (serializer.Writing)
{
var recipes = GetRecipeIdList();
serializer.DataField(ref recipes, "recipes", new List<string>());
}
}
public List<string> GetRecipeIdList()
{
var list = new List<string>();
foreach (var recipe in this)
{
list.Add(recipe.ID);
}
return list;
}
public IEnumerator<LatheRecipePrototype> GetEnumerator()
{
return _recipes.GetEnumerator();