Add two-way serialization in ExposeData for some of the components that are missing it (#1451)
This commit is contained in:
@@ -83,20 +83,21 @@ namespace Content.Shared.GameObjects.Components.Research
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
if (serializer.Reading)
|
||||
{
|
||||
var techs = serializer.ReadDataField("technologies", new List<string>());
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
foreach (var id in techs)
|
||||
serializer.DataReadWriteFunction(
|
||||
"technologies",
|
||||
new List<string>(),
|
||||
techs =>
|
||||
{
|
||||
if (!prototypeManager.TryIndex(id, out TechnologyPrototype tech)) continue;
|
||||
_technologies.Add(tech);
|
||||
}
|
||||
} else if (serializer.Writing)
|
||||
{
|
||||
var techs = GetTechnologyIdList();
|
||||
serializer.DataField(ref techs, "technologies", new List<string>());
|
||||
}
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
foreach (var id in techs)
|
||||
{
|
||||
if (prototypeManager.TryIndex(id, out TechnologyPrototype tech))
|
||||
{
|
||||
_technologies.Add(tech);
|
||||
}
|
||||
}
|
||||
}, GetTechnologyIdList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user