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

@@ -152,15 +152,11 @@ namespace Content.Client.GameObjects
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (!serializer.Reading) serializer.DataReadWriteFunction(
{ "hands",
return; new List<string>(),
} hands => hands.ForEach(slot => _hands.Add(slot, null)),
() => _hands.Keys.ToList());
foreach (var slot in serializer.ReadDataFieldCached("hands", new List<string>()))
{
_hands.Add(slot, null);
}
serializer.DataField(this, x => ActiveIndex, "defaultHand", _hands.Keys.LastOrDefault()); serializer.DataField(this, x => ActiveIndex, "defaultHand", _hands.Keys.LastOrDefault());
} }

View File

@@ -96,14 +96,11 @@ namespace Content.Client.GameObjects.Components.Sound
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Writing) return;
serializer.TryReadDataField("schedules", out List<ScheduledSound> schedules); serializer.DataReadFunction(
if (schedules == null) return; "schedules",
foreach (var schedule in schedules) new List<ScheduledSound>(),
{ schedules => schedules.ForEach(AddScheduledSound));
if (schedule == null) continue;
AddScheduledSound(schedule);
}
} }
} }
} }

View File

@@ -61,16 +61,10 @@ namespace Content.Server.GameObjects
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
// TODO: This does not serialize what objects are held. serializer.DataReadWriteFunction("hands",
serializer.DataField(ref _orderedHands, "hands", new List<string>(0)); new List<string>(0),
if (serializer.Reading) hands => hands.ForEach(AddHand),
{ () => _orderedHands);
foreach (var handsname in _orderedHands)
{
AddHand(handsname);
}
}
serializer.DataField(ref _activeIndex, "defaultHand", _orderedHands.LastOrDefault()); serializer.DataField(ref _activeIndex, "defaultHand", _orderedHands.LastOrDefault());
} }

View File

@@ -65,14 +65,25 @@ namespace Content.Server.GameObjects.Components.Interactable
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading) serializer.DataReadWriteFunction(
{ "qualities",
var qualities = serializer.ReadDataField("qualities", new List<ToolQuality>()); new List<ToolQuality>(),
foreach (var quality in qualities) qualities => qualities.ForEach(AddQuality),
() =>
{ {
AddQuality(quality); var qualities = new List<ToolQuality>();
}
} foreach (ToolQuality quality in Enum.GetValues(typeof(ToolQuality)))
{
if ((_qualities & quality) != 0)
{
qualities.Add(quality);
}
}
return qualities;
});
serializer.DataField(this, mod => SpeedModifier, "speed", 1); serializer.DataField(this, mod => SpeedModifier, "speed", 1);
serializer.DataField(this, use => UseSound, "useSound", string.Empty); serializer.DataField(this, use => UseSound, "useSound", string.Empty);
serializer.DataField(this, collection => UseSoundCollection, "useSoundCollection", string.Empty); serializer.DataField(this, collection => UseSoundCollection, "useSoundCollection", string.Empty);

View File

@@ -44,19 +44,29 @@ namespace Content.Server.GameObjects.Components.Nutrition
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
serializer.DataField(ref _useSound, "useSound", "/Audio/Items/eatfood.ogg"); serializer.DataField(ref _useSound, "useSound", "/Audio/Items/eatfood.ogg");
serializer.DataField(ref _transferAmount, "transferAmount", ReagentUnit.New(5)); serializer.DataField(ref _transferAmount, "transferAmount", ReagentUnit.New(5));
serializer.DataField(ref _trashPrototype, "trash", null); serializer.DataField(ref _trashPrototype, "trash", null);
if (serializer.Reading) serializer.DataReadWriteFunction(
{ "utensils",
var utensils = serializer.ReadDataField("utensils", new List<UtensilType>()); new List<UtensilType>(),
foreach (var utensil in utensils) types => types.ForEach(type => _utensilsNeeded |= type),
() =>
{ {
_utensilsNeeded |= utensil; var types = new List<UtensilType>();
Dirty();
} foreach (UtensilType type in Enum.GetValues(typeof(UtensilType)))
} {
if ((_utensilsNeeded & type) != 0)
{
types.Add(type);
}
}
return types;
});
} }
public override void Initialize() public override void Initialize()

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.GameObjects.Components.Nutrition;
using Content.Server.Utility; using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Utensil; using Content.Shared.GameObjects.Components.Utensil;
@@ -83,14 +84,23 @@ namespace Content.Server.GameObjects.Components.Utensil
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading) serializer.DataReadWriteFunction("types",
{ new List<UtensilType>(),
var types = serializer.ReadDataField("types", new List<UtensilType>()); types => types.ForEach(AddType),
foreach (var type in types) () =>
{ {
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 _breakChance, "breakChance", 0);
serializer.DataField(ref _breakSound, "breakSound", "/Audio/Items/snap.ogg"); serializer.DataField(ref _breakSound, "breakSound", "/Audio/Items/snap.ogg");

View File

@@ -44,15 +44,13 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
serializer.DataField(ref _caliber, "caliber", BallisticCaliber.Unspecified); serializer.DataField(ref _caliber, "caliber", BallisticCaliber.Unspecified);
serializer.DataReadWriteFunction(
if (serializer.Reading) "capacity",
{ 6,
var capacity = serializer.ReadDataField("capacity", 6); cap => _ammoSlots = new IEntity[cap],
_ammoSlots = new IEntity[capacity]; () => _ammoSlots.Length);
}
// TODO: Writing?
serializer.DataField(ref _fillPrototype, "fillPrototype", null); serializer.DataField(ref _fillPrototype, "fillPrototype", null);
// Sounds // Sounds

View File

@@ -75,11 +75,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading)
{
_powerCellPrototype = serializer.ReadDataField<string>("powerCellPrototype", null);
}
serializer.DataField(ref _powerCellPrototype, "powerCellPrototype", null);
serializer.DataField(ref _powerCellRemovable, "powerCellRemovable", false); serializer.DataField(ref _powerCellRemovable, "powerCellRemovable", false);
serializer.DataField(ref _baseFireCost, "fireCost", 300); serializer.DataField(ref _baseFireCost, "fireCost", 300);
serializer.DataField(ref _ammoPrototype, "ammoPrototype", null); serializer.DataField(ref _ammoPrototype, "ammoPrototype", null);

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition; using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged; using Content.Shared.GameObjects.Components.Weapons.Ranged;
@@ -95,14 +96,25 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading)
{ serializer.DataReadWriteFunction(
var magTypes = serializer.ReadDataField("magazineTypes", new List<MagazineType>()); "magazineTypes",
foreach (var mag in magTypes) new List<MagazineType>(),
types => types.ForEach(mag => _magazineTypes |= mag),
() =>
{ {
_magazineTypes |= mag; var types = new List<MagazineType>();
}
} foreach (MagazineType mag in Enum.GetValues(typeof(MagazineType)))
{
if ((_magazineTypes & mag) != 0)
{
types.Add(mag);
}
}
return types;
});
serializer.DataField(ref _caliber, "caliber", BallisticCaliber.Unspecified); serializer.DataField(ref _caliber, "caliber", BallisticCaliber.Unspecified);
serializer.DataField(ref _magFillPrototype, "magFillPrototype", null); serializer.DataField(ref _magFillPrototype, "magFillPrototype", null);
serializer.DataField(ref _autoEjectMag, "autoEjectMag", false); serializer.DataField(ref _autoEjectMag, "autoEjectMag", false);

View File

@@ -84,31 +84,57 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
serializer.DataField(ref _fireRateSelector, "currentSelector", FireRateSelector.Safety); serializer.DataField(ref _fireRateSelector, "currentSelector", FireRateSelector.Safety);
serializer.DataField(ref _fireRate, "fireRate", 2.0f); serializer.DataField(ref _fireRate, "fireRate", 2.0f);
// This hard-to-read area's dealing with recoil // This hard-to-read area's dealing with recoil
// Use degrees in yaml as it's easier to read compared to "0.0125f" // Use degrees in yaml as it's easier to read compared to "0.0125f"
if (serializer.Reading) serializer.DataReadWriteFunction(
{ "minAngle",
var minAngle = serializer.ReadDataField("minAngle", 0) / 2; 0,
_minAngle = Angle.FromDegrees(minAngle); angle => _minAngle = Angle.FromDegrees(angle / 2f),
// Random doubles it as it's +/- so uhh we'll just half it here for readability () => _minAngle.Degrees * 2);
var maxAngle = serializer.ReadDataField("maxAngle", 45) / 2;
_maxAngle = Angle.FromDegrees(maxAngle);
var angleIncrease = serializer.ReadDataField("angleIncrease", (40 / _fireRate));
_angleIncrease = angleIncrease * (float) Math.PI / 180;
var angleDecay = serializer.ReadDataField("angleDecay", (float) 20);
_angleDecay = angleDecay * (float) Math.PI / 180;
serializer.DataField(ref _spreadRatio, "ammoSpreadRatio", 1.0f);
// FireRate options // Random doubles it as it's +/- so uhh we'll just half it here for readability
var allFireRates = serializer.ReadDataField("allSelectors", new List<FireRateSelector>()); serializer.DataReadWriteFunction(
foreach (var fireRate in allFireRates) "maxAngle",
45,
angle => _maxAngle = Angle.FromDegrees(angle / 2f),
() => _maxAngle.Degrees * 2);
serializer.DataReadWriteFunction(
"angleIncrease",
40 / _fireRate,
angle => _angleIncrease = angle * (float) Math.PI / 180,
() => _angleIncrease / (float) Math.PI / 180);
serializer.DataReadWriteFunction(
"angleDecay",
20f,
angle => _angleDecay = angle * (float) Math.PI / 180,
() => _angleDecay / (float) Math.PI / 180);
serializer.DataField(ref _spreadRatio, "ammoSpreadRatio", 1.0f);
serializer.DataReadWriteFunction(
"allSelectors",
new List<FireRateSelector>(),
selectors => selectors.ForEach(selector => _allRateSelectors |= selector),
() =>
{ {
_allRateSelectors |= fireRate; var types = new List<FireRateSelector>();
}
} foreach (FireRateSelector selector in Enum.GetValues(typeof(FireRateSelector)))
{
if ((_allRateSelectors & selector) != 0)
{
types.Add(selector);
}
}
return types;
});
// For simplicity we'll enforce it this way; ammo determines max spread // For simplicity we'll enforce it this way; ammo determines max spread
if (_spreadRatio > 1.0f) if (_spreadRatio > 1.0f)
@@ -118,6 +144,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
} }
serializer.DataField(ref _canMuzzleFlash, "canMuzzleFlash", true); serializer.DataField(ref _canMuzzleFlash, "canMuzzleFlash", true);
// Sounds // Sounds
serializer.DataField(ref _soundGunshot, "soundGunshot", null); serializer.DataField(ref _soundGunshot, "soundGunshot", null);
serializer.DataField(ref _soundEmpty, "soundEmpty", "/Audio/Weapons/Guns/Empty/empty.ogg"); serializer.DataField(ref _soundEmpty, "soundEmpty", "/Audio/Weapons/Guns/Empty/empty.ogg");

View File

@@ -25,6 +25,9 @@ namespace Content.Server.BodySystem {
[ViewVariables] [ViewVariables]
private BodyTemplate _template; private BodyTemplate _template;
[ViewVariables]
private string _presetName;
[ViewVariables] [ViewVariables]
private Dictionary<string, BodyPart> _partDictionary = new Dictionary<string, BodyPart>(); private Dictionary<string, BodyPart> _partDictionary = new Dictionary<string, BodyPart>();
@@ -103,7 +106,7 @@ namespace Content.Server.BodySystem {
} }
/// <summary> /// <summary>
/// Returns whether the given slot name exists within the current <see cref="BodyTemplate"/>. /// Returns whether the given slot name exists within the current <see cref="BodyTemplate"/>.
/// </summary> /// </summary>
public bool SlotExists(string slotName) public bool SlotExists(string slotName)
{ {
@@ -175,29 +178,46 @@ namespace Content.Server.BodySystem {
///////// Server-specific stuff ///////// Server-specific stuff
///////// /////////
public override void ExposeData(ObjectSerializer serializer) { public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer); base.ExposeData(serializer);
string templateName = null; serializer.DataReadWriteFunction(
serializer.DataField(ref templateName, "BaseTemplate", "bodyTemplate.Humanoid"); "BaseTemplate",
if (serializer.Reading) { "bodyTemplate.Humanoid",
if (!_prototypeManager.TryIndex(templateName, out BodyTemplatePrototype templateData)) template =>
throw new InvalidOperationException("No BodyTemplatePrototype was found with the name " + templateName + " while loading a BodyTemplate!"); //Should never happen unless you fuck up the prototype. {
if (!_prototypeManager.TryIndex(template, out BodyTemplatePrototype templateData))
{
throw new InvalidOperationException("No BodyTemplatePrototype was found with the name " + template + " while loading a BodyTemplate!"); //Should never happen unless you fuck up the prototype.
}
string presetName = null; _template = new BodyTemplate(templateData);
serializer.DataField(ref presetName, "BasePreset", "bodyPreset.BasicHuman"); },
if (!_prototypeManager.TryIndex(presetName, out BodyPresetPrototype presetData)) () => _template.Name);
throw new InvalidOperationException("No BodyPresetPrototype was found with the name " + presetName + " while loading a BodyPreset!"); //Should never happen unless you fuck up the prototype.
_template = new BodyTemplate(templateData); serializer.DataReadWriteFunction(
LoadBodyPreset(new BodyPreset(presetData)); "BasePreset",
} "bodyPreset.BasicHuman",
preset =>
{
if (!_prototypeManager.TryIndex(preset, out BodyPresetPrototype presetData))
{
throw new InvalidOperationException("No BodyPresetPrototype was found with the name " + preset + " while loading a BodyPreset!"); //Should never happen unless you fuck up the prototype.
}
LoadBodyPreset(new BodyPreset(presetData));
},
() => _presetName);
} }
/// <summary> /// <summary>
/// Loads the given <see cref="BodyPreset"/> - forcefully changes all limbs found in both the preset and this template! /// Loads the given <see cref="BodyPreset"/> - forcefully changes all limbs found in both the preset and this template!
/// </summary> /// </summary>
public void LoadBodyPreset(BodyPreset preset) { public void LoadBodyPreset(BodyPreset preset)
{
_presetName = preset.Name;
foreach (var (slotName, type) in _template.Slots) { foreach (var (slotName, type) in _template.Slots) {
if (!preset.PartIDs.TryGetValue(slotName, out string partID)) { //For each slot in our BodyManagerComponent's template, try and grab what the ID of what the preset says should be inside it. if (!preset.PartIDs.TryGetValue(slotName, out string partID)) { //For each slot in our BodyManagerComponent's template, try and grab what the ID of what the preset says should be inside it.
continue; //If the preset doesn't define anything for it, continue. continue; //If the preset doesn't define anything for it, continue.
@@ -289,7 +309,7 @@ namespace Content.Server.BodySystem {
} }
/// <summary> /// <summary>
/// Disconnects the given <see cref="BodyPart"/> reference, potentially dropping other <see cref="BodyPart">BodyParts</see> if they were hanging off it. /// Disconnects the given <see cref="BodyPart"/> reference, potentially dropping other <see cref="BodyPart">BodyParts</see> if they were hanging off it.
/// </summary> /// </summary>
public void DisconnectBodyPart(BodyPart part, bool dropEntity) { public void DisconnectBodyPart(BodyPart part, bool dropEntity) {
if (!_partDictionary.ContainsValue(part)) if (!_partDictionary.ContainsValue(part))
@@ -314,7 +334,7 @@ namespace Content.Server.BodySystem {
} }
/// <summary> /// <summary>
/// Internal string version of DisconnectBodyPart for performance purposes. Yes, it is actually more performant. /// Internal string version of DisconnectBodyPart for performance purposes. Yes, it is actually more performant.
/// </summary> /// </summary>
private void DisconnectBodyPartByName(string name, bool dropEntity) { private void DisconnectBodyPartByName(string name, bool dropEntity) {
if (!TryGetBodyPart(name, out BodyPart part)) if (!TryGetBodyPart(name, out BodyPart part))

View File

@@ -45,16 +45,16 @@ namespace Content.Shared.Chemistry
/// <inheritdoc /> /// <inheritdoc />
public void ExposeData(ObjectSerializer serializer) public void ExposeData(ObjectSerializer serializer)
{ {
serializer.DataField(ref _contents, "reagents", new List<ReagentQuantity>()); serializer.DataReadWriteFunction(
"reagents",
if (serializer.Reading) new List<ReagentQuantity>(),
{ quantities =>
TotalVolume = ReagentUnit.New(0);
foreach (var reagent in _contents)
{ {
TotalVolume += reagent.Quantity; _contents = quantities;
} TotalVolume = ReagentUnit.New(0);
} quantities.ForEach(reagent => TotalVolume += reagent.Quantity);
},
() => _contents);
} }
/// <summary> /// <summary>

View File

@@ -65,23 +65,25 @@ namespace Content.Shared.GameObjects.Components.Cargo
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading) serializer.DataReadWriteFunction(
{ "products",
var products = serializer.ReadDataField("products", new List<string>()); new List<string>(),
var prototypeManager = IoCManager.Resolve<IPrototypeManager>(); products =>
_products.Clear();
foreach (var id in products)
{ {
if (!prototypeManager.TryIndex(id, out CargoProductPrototype product)) var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
continue;
_products.Add(product); _products.Clear();
} foreach (var id in products)
} {
else if (serializer.Writing) if (!prototypeManager.TryIndex(id, out CargoProductPrototype product))
{ {
var products = GetProductIdList(); continue;
serializer.DataField(ref products, "products", new List<string>()); }
}
_products.Add(product);
}
},
GetProductIdList);
} }
} }

View File

@@ -28,7 +28,7 @@ namespace Content.Shared.GameObjects.Components.Materials
base.ExposeData(serializer); base.ExposeData(serializer);
// TODO: Writing. // TODO: Writing.
if (!serializer.Reading) if (serializer.Writing)
{ {
return; return;
} }
@@ -61,7 +61,7 @@ namespace Content.Shared.GameObjects.Components.Materials
public void ExposeData(ObjectSerializer serializer) public void ExposeData(ObjectSerializer serializer)
{ {
if (!serializer.Reading) if (serializer.Writing)
{ {
return; return;
} }

View File

@@ -74,20 +74,23 @@ namespace Content.Shared.GameObjects.Components.Research
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading) serializer.DataReadWriteFunction(
{ "recipes",
var recipes = serializer.ReadDataField("recipes", new List<string>()); new List<string>(),
var prototypeManager = IoCManager.Resolve<IPrototypeManager>(); recipes =>
foreach (var id in recipes)
{ {
if (!prototypeManager.TryIndex(id, out LatheRecipePrototype recipe)) continue; var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
_recipes.Add(recipe);
} foreach (var id in recipes)
} else if (serializer.Writing) {
{ if (prototypeManager.TryIndex(id, out LatheRecipePrototype recipe))
var recipes = GetRecipeIdList(); {
serializer.DataField(ref recipes, "recipes", new List<string>()); _recipes.Add(recipe);
} }
}
},
GetRecipeIdList);
} }
public List<string> GetRecipeIdList() public List<string> GetRecipeIdList()

View File

@@ -26,20 +26,22 @@ namespace Content.Shared.GameObjects.Components.Research
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading) serializer.DataReadWriteFunction(
{ "protolatherecipes",
var recipes = serializer.ReadDataField("protolatherecipes", new List<string>()); new List<string>(),
var prototypeManager = IoCManager.Resolve<IPrototypeManager>(); recipes =>
foreach (var id in recipes)
{ {
if (!prototypeManager.TryIndex(id, out LatheRecipePrototype recipe)) continue; var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
_protolatheRecipes.Add(recipe);
} foreach (var id in recipes)
} else if (serializer.Writing) {
{ if (prototypeManager.TryIndex(id, out LatheRecipePrototype recipe))
var recipes = GetProtolatheRecipeIdList(); {
serializer.DataField(ref recipes, "protolatherecipes", new List<string>()); _protolatheRecipes.Add(recipe);
} }
}
},
GetProtolatheRecipeIdList);
} }
/// <summary> /// <summary>

View File

@@ -83,20 +83,21 @@ namespace Content.Shared.GameObjects.Components.Research
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
if (serializer.Reading) serializer.DataReadWriteFunction(
{ "technologies",
var techs = serializer.ReadDataField("technologies", new List<string>()); new List<string>(),
var prototypeManager = IoCManager.Resolve<IPrototypeManager>(); techs =>
foreach (var id in techs)
{ {
if (!prototypeManager.TryIndex(id, out TechnologyPrototype tech)) continue; var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
_technologies.Add(tech);
} foreach (var id in techs)
} else if (serializer.Writing) {
{ if (prototypeManager.TryIndex(id, out TechnologyPrototype tech))
var techs = GetTechnologyIdList(); {
serializer.DataField(ref techs, "technologies", new List<string>()); _technologies.Add(tech);
} }
}
}, GetTechnologyIdList);
} }
} }

View File

@@ -53,7 +53,7 @@ namespace Content.Shared.GameObjects.Components
serializer.DataFieldCached(ref _maxCount, "max", 50); serializer.DataFieldCached(ref _maxCount, "max", 50);
serializer.DataFieldCached(ref _count, "count", MaxCount); serializer.DataFieldCached(ref _count, "count", MaxCount);
if (!serializer.Reading) if (serializer.Writing)
{ {
return; return;
} }

View File

@@ -108,7 +108,7 @@ namespace Content.Shared.GameObjects.Components.Sound
public void ExposeData(ObjectSerializer serializer) public void ExposeData(ObjectSerializer serializer)
{ {
if (!serializer.Reading) if (serializer.Writing)
return; return;
Filename = serializer.ReadDataField("filename", ""); Filename = serializer.ReadDataField("filename", "");