Add some more prototype serializers (#5934)

This commit is contained in:
metalgearsloth
2021-12-30 00:48:18 +11:00
committed by GitHub
parent 39e42899ca
commit 88bdf0ce61
24 changed files with 78 additions and 39 deletions

View File

@@ -12,7 +12,9 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
namespace Content.Server.Weapon.Ranged.Ammunition.Components
@@ -44,7 +46,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
private AppearanceComponent? _appearanceComponent;
// If there's anything already in the magazine
[DataField("fillPrototype")]
[DataField("fillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _fillPrototype;
// By default the magazine won't spawn the entity until needed so we need to keep track of how many left we can spawn

View File

@@ -10,7 +10,9 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Weapon.Ranged.Ammunition.Components
{
@@ -35,8 +37,8 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
public int AmmoLeft => _spawnedAmmo.Count + _unspawnedCount;
[DataField("fillPrototype")]
private string? _fillPrototype = default;
[DataField("fillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _fillPrototype;
protected override void Initialize()
{

View File

@@ -14,7 +14,9 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -55,7 +57,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
private BallisticCaliber _caliber = BallisticCaliber.Unspecified;
[ViewVariables]
[DataField("fillPrototype")]
[DataField("fillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _fillPrototype;
[ViewVariables]
private int _unspawnedCount;

View File

@@ -13,9 +13,11 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.ViewVariables;
namespace Content.Server.Weapon.Ranged.Barrels.Components
@@ -48,7 +50,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
public override int ShotsLeft => _ammoContainer.ContainedEntities.Count;
[ViewVariables]
[DataField("fillPrototype")]
[DataField("fillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _fillPrototype;
[ViewVariables]

View File

@@ -10,7 +10,9 @@ using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.ViewVariables;
namespace Content.Server.Weapon.Ranged.Barrels.Components
@@ -32,7 +34,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
[DataField("fireCost")]
[ViewVariables] private int _baseFireCost = 300;
// What gets fired
[DataField("ammoPrototype")]
[DataField("ammoPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
[ViewVariables] private string? _ammoPrototype;
public BatteryComponent? PowerCell => _entities.GetComponentOrNull<BatteryComponent>(CellSlot.Item);

View File

@@ -18,7 +18,9 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -80,7 +82,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
}
}
[DataField("magFillPrototype")]
[DataField("magFillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _magFillPrototype;
public bool BoltOpen