From 2b3e144549ef26a5514d5a3f89e0478115f16d26 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 28 Nov 2021 22:24:09 +1100 Subject: [PATCH] Add test for cargo products (#5470) --- Content.Shared/Cargo/CargoProductPrototype.cs | 4 +++- .../Cargo/Components/SharedGalacticMarketComponent.cs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Cargo/CargoProductPrototype.cs b/Content.Shared/Cargo/CargoProductPrototype.cs index 65099c20f9..e3f29e4347 100644 --- a/Content.Shared/Cargo/CargoProductPrototype.cs +++ b/Content.Shared/Cargo/CargoProductPrototype.cs @@ -1,8 +1,10 @@ using System; +using Nett; 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.Utility; using Robust.Shared.ViewVariables; @@ -70,7 +72,7 @@ namespace Content.Shared.Cargo /// The prototype name of the product. /// [ViewVariables] - [DataField("product")] + [DataField("product", customTypeSerializer: typeof(PrototypeIdSerializer))] public string Product { get; } = string.Empty; /// diff --git a/Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs b/Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs index 166489fb3c..fba2fe46d9 100644 --- a/Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs +++ b/Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs @@ -4,9 +4,11 @@ using System.Collections.Generic; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; using Robust.Shared.IoC; +using Robust.Shared.Log; 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.Cargo.Components { @@ -15,7 +17,7 @@ namespace Content.Shared.Cargo.Components { public sealed override string Name => "GalacticMarket"; - [DataField("products")] + [DataField("products", customTypeSerializer: typeof(PrototypeIdListSerializer))] protected List _productIds = new(); protected readonly List _products = new(); @@ -35,6 +37,7 @@ namespace Content.Shared.Cargo.Components { if (!prototypeManager.TryIndex(id, out CargoProductPrototype? product)) { + Logger.ErrorS("cargo", $"Unable to find {nameof(CargoProductPrototype)} for {id}"); continue; }