Add two-way serialization in ExposeData for some of the components that are missing it (#1451)
This commit is contained in:
@@ -65,23 +65,25 @@ namespace Content.Shared.GameObjects.Components.Cargo
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
if (serializer.Reading)
|
||||
{
|
||||
var products = serializer.ReadDataField("products", new List<string>());
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
_products.Clear();
|
||||
foreach (var id in products)
|
||||
serializer.DataReadWriteFunction(
|
||||
"products",
|
||||
new List<string>(),
|
||||
products =>
|
||||
{
|
||||
if (!prototypeManager.TryIndex(id, out CargoProductPrototype product))
|
||||
continue;
|
||||
_products.Add(product);
|
||||
}
|
||||
}
|
||||
else if (serializer.Writing)
|
||||
{
|
||||
var products = GetProductIdList();
|
||||
serializer.DataField(ref products, "products", new List<string>());
|
||||
}
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
_products.Clear();
|
||||
foreach (var id in products)
|
||||
{
|
||||
if (!prototypeManager.TryIndex(id, out CargoProductPrototype product))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_products.Add(product);
|
||||
}
|
||||
},
|
||||
GetProductIdList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user