Add two-way serialization in ExposeData for some of the components that are missing it (#1451)

This commit is contained in:
DrSmugleaf
2020-07-23 01:46:09 +02:00
committed by GitHub
parent 989025b222
commit a8b3c99075
19 changed files with 252 additions and 172 deletions

View File

@@ -26,20 +26,22 @@ namespace Content.Shared.GameObjects.Components.Research
{
base.ExposeData(serializer);
if (serializer.Reading)
{
var recipes = serializer.ReadDataField("protolatherecipes", new List<string>());
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
foreach (var id in recipes)
serializer.DataReadWriteFunction(
"protolatherecipes",
new List<string>(),
recipes =>
{
if (!prototypeManager.TryIndex(id, out LatheRecipePrototype recipe)) continue;
_protolatheRecipes.Add(recipe);
}
} else if (serializer.Writing)
{
var recipes = GetProtolatheRecipeIdList();
serializer.DataField(ref recipes, "protolatherecipes", new List<string>());
}
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
foreach (var id in recipes)
{
if (prototypeManager.TryIndex(id, out LatheRecipePrototype recipe))
{
_protolatheRecipes.Add(recipe);
}
}
},
GetProtolatheRecipeIdList);
}
/// <summary>