Add test for cargo products (#5470)
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Nett;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ namespace Content.Shared.Cargo
|
|||||||
/// The prototype name of the product.
|
/// The prototype name of the product.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
[DataField("product")]
|
[DataField("product", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||||
public string Product { get; } = string.Empty;
|
public string Product { get; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ using System.Collections.Generic;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||||
|
|
||||||
namespace Content.Shared.Cargo.Components
|
namespace Content.Shared.Cargo.Components
|
||||||
{
|
{
|
||||||
@@ -15,7 +17,7 @@ namespace Content.Shared.Cargo.Components
|
|||||||
{
|
{
|
||||||
public sealed override string Name => "GalacticMarket";
|
public sealed override string Name => "GalacticMarket";
|
||||||
|
|
||||||
[DataField("products")]
|
[DataField("products", customTypeSerializer: typeof(PrototypeIdListSerializer<CargoProductPrototype>))]
|
||||||
protected List<string> _productIds = new();
|
protected List<string> _productIds = new();
|
||||||
|
|
||||||
protected readonly List<CargoProductPrototype> _products = new();
|
protected readonly List<CargoProductPrototype> _products = new();
|
||||||
@@ -35,6 +37,7 @@ namespace Content.Shared.Cargo.Components
|
|||||||
{
|
{
|
||||||
if (!prototypeManager.TryIndex(id, out CargoProductPrototype? product))
|
if (!prototypeManager.TryIndex(id, out CargoProductPrototype? product))
|
||||||
{
|
{
|
||||||
|
Logger.ErrorS("cargo", $"Unable to find {nameof(CargoProductPrototype)} for {id}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user