Cargo Bounties (#17344)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
31
Content.Shared/Cargo/CargoBountyData.cs
Normal file
31
Content.Shared/Cargo/CargoBountyData.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using Content.Shared.Cargo.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Cargo;
|
||||
|
||||
/// <summary>
|
||||
/// A data structure for storing currently available bounties.
|
||||
/// </summary>
|
||||
[DataDefinition, NetSerializable, Serializable]
|
||||
public readonly record struct CargoBountyData(int Id, string Bounty, TimeSpan EndTime)
|
||||
{
|
||||
/// <summary>
|
||||
/// A numeric id used to identify the bounty
|
||||
/// </summary>
|
||||
[DataField("id"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public readonly int Id = Id;
|
||||
|
||||
/// <summary>
|
||||
/// The prototype containing information about the bounty.
|
||||
/// </summary>
|
||||
[DataField("bounty", customTypeSerializer: typeof(PrototypeIdSerializer<CargoBountyPrototype>)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public readonly string Bounty = Bounty;
|
||||
|
||||
/// <summary>
|
||||
/// The time at which the bounty is closed and no longer is available.
|
||||
/// </summary>
|
||||
[DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
public readonly TimeSpan EndTime = EndTime;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Cargo.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class CargoBountyConsoleComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The id of the label entity spawned by the print label button.
|
||||
/// </summary>
|
||||
[DataField("bountyLabelId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string BountyLabelId = "PaperCargoBountyManifest";
|
||||
|
||||
/// <summary>
|
||||
/// The time at which the console will be able to print a label again.
|
||||
/// </summary>
|
||||
[DataField("nextPrintTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
public TimeSpan NextPrintTime = TimeSpan.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// The time between prints.
|
||||
/// </summary>
|
||||
[DataField("printDelay")]
|
||||
public TimeSpan PrintDelay = TimeSpan.FromSeconds(5);
|
||||
|
||||
/// <summary>
|
||||
/// The sound made when printing occurs
|
||||
/// </summary>
|
||||
[DataField("printSound")]
|
||||
public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/printer.ogg");
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public sealed class CargoBountyConsoleState : BoundUserInterfaceState
|
||||
{
|
||||
public List<CargoBountyData> Bounties;
|
||||
|
||||
public CargoBountyConsoleState(List<CargoBountyData> bounties)
|
||||
{
|
||||
Bounties = bounties;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class BountyPrintLabelMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int BountyId;
|
||||
|
||||
public BountyPrintLabelMessage(int bountyId)
|
||||
{
|
||||
BountyId = bountyId;
|
||||
}
|
||||
}
|
||||
60
Content.Shared/Cargo/Prototypes/CargoBountyPrototype.cs
Normal file
60
Content.Shared/Cargo/Prototypes/CargoBountyPrototype.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Prototypes;
|
||||
|
||||
/// <summary>
|
||||
/// This is a prototype for a cargo bounty, a set of items
|
||||
/// that must be sold together in a labeled container in order
|
||||
/// to receive a monetary reward.
|
||||
/// </summary>
|
||||
[Prototype("cargoBounty"), Serializable, NetSerializable]
|
||||
public sealed class CargoBountyPrototype : IPrototype
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The monetary reward for completing the bounty
|
||||
/// </summary>
|
||||
[DataField("reward", required: true)]
|
||||
public readonly int Reward;
|
||||
|
||||
/// <summary>
|
||||
/// A description for flava purposes.
|
||||
/// </summary>
|
||||
[DataField("description")]
|
||||
public readonly string Description = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The entries that must be satisfied for the cargo bounty to be complete.
|
||||
/// </summary>
|
||||
[DataField("entries", required: true)]
|
||||
public readonly List<CargoBountyItemEntry> Entries = new();
|
||||
}
|
||||
|
||||
[DataDefinition, Serializable, NetSerializable]
|
||||
public readonly record struct CargoBountyItemEntry()
|
||||
{
|
||||
/// <summary>
|
||||
/// A whitelist for determining what items satisfy the entry.
|
||||
/// </summary>
|
||||
[DataField("whitelist", required: true)]
|
||||
public readonly EntityWhitelist Whitelist = default!;
|
||||
|
||||
// todo: implement some kind of simple generic condition system
|
||||
|
||||
/// <summary>
|
||||
/// How much of the item must be present to satisfy the entry
|
||||
/// </summary>
|
||||
[DataField("amount")]
|
||||
public readonly int Amount = 1;
|
||||
|
||||
/// <summary>
|
||||
/// A player-facing name for the item.
|
||||
/// </summary>
|
||||
[DataField("name")]
|
||||
public readonly string Name = string.Empty;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace Content.Shared.Cargo;
|
||||
public enum CargoConsoleUiKey : byte
|
||||
{
|
||||
Orders,
|
||||
Bounty,
|
||||
Shuttle,
|
||||
Telepad
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user