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

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