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

@@ -15,6 +15,7 @@ using Robust.Shared.Log;
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.ViewVariables;
namespace Content.Server.Actions.Spells
@@ -25,7 +26,7 @@ namespace Content.Server.Actions.Spells
{ //TODO: Needs to be an EntityPrototype for proper validation
[ViewVariables] [DataField("castMessage")] public string? CastMessage { get; set; } = default!;
[ViewVariables] [DataField("cooldown")] public float CoolDown { get; set; } = 1f;
[ViewVariables] [DataField("spellItem")] public string ItemProto { get; set; } = default!;
[ViewVariables] [DataField("spellItem", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))] public string ItemProto { get; set; } = default!;
[ViewVariables] [DataField("castSound", required: true)] public SoundSpecifier CastSound { get; set; } = default!;

View File

@@ -16,8 +16,10 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.ViewVariables;
namespace Content.Server.Arcade.Components
@@ -64,7 +66,7 @@ namespace Content.Server.Arcade.Components
"Vhakoid", "Peteoid", "slime", "Griefer", "ERPer", "Lizard Man", "Unicorn"
};
[ViewVariables(VVAccess.ReadWrite)]
[DataField("possibleRewards")]
[DataField("possibleRewards", customTypeSerializer:typeof(PrototypeIdListSerializer<EntityPrototype>))]
private List<string> _possibleRewards = new List<string>()
{
"ToyMouse", "ToyAi", "ToyNuke", "ToyAssistant", "ToyGriffin", "ToyHonk", "ToyIan",

View File

@@ -16,6 +16,7 @@ using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -103,7 +104,7 @@ namespace Content.Server.Botany
#region Output
[ViewVariables]
[DataField("productPrototypes")]
[DataField("productPrototypes", customTypeSerializer:typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> ProductPrototypes { get; set; } = new();
[ViewVariables]

View File

@@ -7,7 +7,9 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
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.Computer
@@ -18,7 +20,7 @@ namespace Content.Server.Computer
[Dependency] private readonly IEntityManager _entMan = default!;
[ViewVariables]
[DataField("board")]
[DataField("board", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _boardPrototype;
protected override void Initialize()

View File

@@ -5,7 +5,9 @@ using Content.Shared.Prototypes;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Construction.Completions
{
@@ -13,8 +15,10 @@ namespace Content.Server.Construction.Completions
[DataDefinition]
public class SpawnPrototype : IGraphAction
{
[DataField("prototype")] public string Prototype { get; private set; } = string.Empty;
[DataField("amount")] public int Amount { get; private set; } = 1;
[DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Prototype { get; private set; } = string.Empty;
[DataField("amount")]
public int Amount { get; private set; } = 1;
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{

View File

@@ -9,8 +9,10 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.ViewVariables;
namespace Content.Server.Explosion.Components
@@ -27,7 +29,7 @@ namespace Content.Server.Explosion.Components
/// <summary>
/// What we fill our prototype with if we want to pre-spawn with grenades.
/// </summary>
[ViewVariables] [DataField("fillPrototype")]
[ViewVariables] [DataField("fillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _fillPrototype;
/// <summary>

View File

@@ -19,7 +19,9 @@ using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
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.Timing;
using Robust.Shared.ViewVariables;
@@ -44,7 +46,7 @@ namespace Content.Server.Fluids.Components
private TimeSpan _cooldownEnd;
[DataField("cooldownTime")]
private float _cooldownTime = 0.5f;
[DataField("sprayedPrototype")]
[DataField("sprayedPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string _vaporPrototype = "Vapor";
[DataField("vaporAmount")]
private int _vaporAmount = 1;

View File

@@ -19,7 +19,9 @@ using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Maths;
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;
@@ -38,7 +40,7 @@ namespace Content.Server.Morgue.Components
public override string Name => "MorgueEntityStorage";
[ViewVariables(VVAccess.ReadWrite)]
[DataField("trayPrototype")]
[DataField("trayPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string? _trayPrototypeId;
[ViewVariables]

View File

@@ -1,14 +1,16 @@
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Tabletop
{
[UsedImplicitly]
public class TabletopChessSetup : TabletopSetup
{
[DataField("boardPrototype")]
[DataField("boardPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string ChessBoardPrototype { get; } = "ChessBoardTabletop";
// TODO: Un-hardcode the rest of entity prototype IDs, probably.

View File

@@ -1,25 +1,27 @@
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Tabletop
{
[UsedImplicitly]
public class TabletopParchisSetup : TabletopSetup
{
[DataField("boardPrototype")]
[DataField("boardPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string ParchisBoardPrototype { get; } = "ParchisBoardTabletop";
[DataField("redPiecePrototype")]
[DataField("redPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string RedPiecePrototype { get; } = "RedTabletopPiece";
[DataField("greenPiecePrototype")]
[DataField("greenPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string GreenPiecePrototype { get; } = "GreenTabletopPiece";
[DataField("yellowPiecePrototype")]
[DataField("yellowPiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string YellowPiecePrototype { get; } = "YellowTabletopPiece";
[DataField("bluePiecePrototype")]
[DataField("bluePiecePrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string BluePiecePrototype { get; } = "BlueTabletopPiece";
public override void SetupTabletop(TabletopSession session, IEntityManager entityManager)

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

View File

@@ -7,6 +7,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Lathe
{
@@ -18,7 +19,8 @@ namespace Content.Shared.Lathe
public override string Name => "ProtolatheDatabase";
[DataField("protolatherecipes")] private List<string> _recipeIds = new();
[DataField("protolatherecipes", customTypeSerializer:typeof(PrototypeIdListSerializer<EntityPrototype>))]
private List<string> _recipeIds = new();
/// <summary>
/// A full list of recipes this protolathe can print.

View File

@@ -5,6 +5,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -27,7 +28,7 @@ namespace Content.Shared.Research.Prototypes
[DataField("description")]
private string _description = string.Empty;
[DataField("result")]
[DataField("result", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
private string _result = string.Empty;
[DataField("completetime")]

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -56,7 +57,7 @@ namespace Content.Shared.Research.Prototypes
/// A list of recipe IDs this technology unlocks.
/// </summary>
[ViewVariables]
[DataField("unlockedRecipes")]
[DataField("unlockedRecipes", customTypeSerializer:typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> UnlockedRecipes { get; } = new();
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Content.Shared.Access;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.ViewVariables;
@@ -48,7 +49,7 @@ namespace Content.Shared.Roles
[DataField("head")]
public bool IsHead { get; private set; }
[DataField("startingGear")]
[DataField("startingGear", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
public string? StartingGear { get; private set; }
[DataField("icon")] public string Icon { get; } = string.Empty;

View File

@@ -6,6 +6,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Whitelist
{
@@ -36,7 +37,8 @@ namespace Content.Shared.Whitelist
/// <summary>
/// Tags that are allowed in the whitelist.
/// </summary>
[DataField("tags")] public string[]? Tags = null;
[DataField("tags")]
public string[]? Tags = null;
void ISerializationHooks.AfterDeserialization()
{

View File

@@ -42,8 +42,8 @@
requiredTechnologies:
- BasicResearch
unlockedRecipes:
- Scythe
- Hatchet
- HydroponicsToolScythe
- HydroponicsToolHatchet
- KitchenKnife
- type: technology
@@ -75,7 +75,7 @@
- Retractor
- Cautery
- Drill
- BoneSaw
- Saw
- Hemostat
# Chemistry Technology Tree
@@ -219,7 +219,7 @@
requiredTechnologies:
- BasicResearch
unlockedRecipes:
- ConveyorAssembly
- ConveyorBeltAssembly
- RCD
- RCDAmmo
- FlashlightLantern
@@ -239,7 +239,7 @@
- SheetSteel
- SheetPlastic
- SheetRGlass
- GlassStack
- SheetGlass1
# Electromagnetic Theory Technology Tree

View File

@@ -137,23 +137,23 @@
- LightTube
- LightBulb
- SheetSteel
- GlassStack
- SheetGlass1
- SheetRGlass
- SheetPlastic
- CableStack
- CableMVStack
- CableHVStack
- ConveyorAssembly
- ConveyorBeltAssembly
- RCD
- RCDAmmo
- Scythe
- Hatchet
- HydroponicsToolScythe
- HydroponicsToolHatchet
- Shovel
- Scalpel
- Retractor
- Cautery
- Drill
- BoneSaw
- Saw
- Hemostat
- Beaker
- LargeBeaker

View File

@@ -26,9 +26,9 @@
Glass: 100
- type: latheRecipe
id: GlowStickRed
id: GlowstickRed
icon: Objects/Misc/glowstick.rsi
result: GlowStickRed
result: GlowstickRed
completetime: 500
materials:
Plastic: 50