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
@@ -44,17 +44,5 @@ namespace Content.Server.GameObjects.Components.Research
|
|||||||
Dirty();
|
Dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetRecipeIdList()
|
|
||||||
{
|
|
||||||
var list = new List<string>();
|
|
||||||
|
|
||||||
foreach (var recipe in this)
|
|
||||||
{
|
|
||||||
list.Add(recipe.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ namespace Content.Shared.GameObjects.Components.Research
|
|||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
|
|
||||||
|
if (serializer.Reading)
|
||||||
|
{
|
||||||
var recipes = serializer.ReadDataField("recipes", new List<string>());
|
var recipes = serializer.ReadDataField("recipes", new List<string>());
|
||||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||||
foreach (var id in recipes)
|
foreach (var id in recipes)
|
||||||
@@ -82,6 +84,23 @@ namespace Content.Shared.GameObjects.Components.Research
|
|||||||
if (!prototypeManager.TryIndex(id, out LatheRecipePrototype recipe)) continue;
|
if (!prototypeManager.TryIndex(id, out LatheRecipePrototype recipe)) continue;
|
||||||
_recipes.Add(recipe);
|
_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()
|
public IEnumerator<LatheRecipePrototype> GetEnumerator()
|
||||||
|
|||||||
Reference in New Issue
Block a user