Machine Port Prototypes (#7659)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Leon Friedrich
2022-05-12 20:46:20 +12:00
committed by GitHub
parent 32c2eb7a02
commit c00b459e31
29 changed files with 422 additions and 220 deletions

View File

@@ -0,0 +1,44 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Shared.MachineLinking;
/// <summary>
/// A prototype for a machine port, for use with machine linking.
/// </summary>
public abstract class MachinePortPrototype
{
/// <summary>
/// Localization string for the port name. Displayed in the linking UI.
/// </summary>
[DataField("name", required:true)]
public string Name = default!;
/// <summary>
/// Localization string for a description of the ports functionality. Should either indicate when a transmitter
/// port is fired, or what function a receiver port serves. Displayed as a tooltip in the linking UI.
/// </summary>
[DataField("description", required: true)]
public string Description = default!;
}
[Prototype("receiverPort")]
public sealed class ReceiverPortPrototype : MachinePortPrototype, IPrototype
{
[IdDataField]
public string ID { get; } = default!;
}
[Prototype("transmitterPort")]
public sealed class TransmitterPortPrototype : MachinePortPrototype, IPrototype
{
[IdDataField]
public string ID { get; } = default!;
/// <summary>
/// This is a set of receiver ports that this transmitter port will attempt to link to when using the
/// default-link functionality.
/// </summary>
[DataField("defaultLinks", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<ReceiverPortPrototype>))]
public HashSet<string>? DefaultLinks;
}