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

@@ -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);
}
}