Add two-way serialization in ExposeData for some of the components that are missing it (#1451)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Nutrition;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.GameObjects.Components.Utensil;
|
||||
@@ -83,14 +84,23 @@ namespace Content.Server.GameObjects.Components.Utensil
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
if (serializer.Reading)
|
||||
{
|
||||
var types = serializer.ReadDataField("types", new List<UtensilType>());
|
||||
foreach (var type in types)
|
||||
serializer.DataReadWriteFunction("types",
|
||||
new List<UtensilType>(),
|
||||
types => types.ForEach(AddType),
|
||||
() =>
|
||||
{
|
||||
AddType(type);
|
||||
}
|
||||
}
|
||||
var types = new List<UtensilType>();
|
||||
|
||||
foreach (UtensilType type in Enum.GetValues(typeof(UtensilType)))
|
||||
{
|
||||
if ((Types & type) != 0)
|
||||
{
|
||||
types.Add(type);
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
});
|
||||
|
||||
serializer.DataField(ref _breakChance, "breakChance", 0);
|
||||
serializer.DataField(ref _breakSound, "breakSound", "/Audio/Items/snap.ogg");
|
||||
|
||||
Reference in New Issue
Block a user