Fix bug where lathe databases didn't get serialized correctly. (#252)
This commit is contained in:
committed by
Pieter-Jan Briers
parent
dd13d969b2
commit
50bc1bff48
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user