Chill bounties + fixes (#23411)

* Chill bounties + fixes

* localize

* fix arbitage
This commit is contained in:
Nemanja
2024-01-03 19:34:47 -05:00
committed by GitHub
parent 9d8ac7846a
commit 4662d463b8
22 changed files with 284 additions and 182 deletions

View File

@@ -1,7 +1,6 @@
using Robust.Shared.Serialization;
using Content.Shared.Cargo.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Prototypes;
namespace Content.Shared.Cargo;
@@ -9,28 +8,24 @@ namespace Content.Shared.Cargo;
/// A data structure for storing currently available bounties.
/// </summary>
[DataDefinition, NetSerializable, Serializable]
public readonly partial record struct CargoBountyData(int Id, string Bounty, TimeSpan EndTime)
public readonly partial record struct CargoBountyData
{
/// <summary>
/// A numeric id used to identify the bounty
/// A unique id used to identify the bounty
/// </summary>
[DataField("id"), ViewVariables(VVAccess.ReadWrite)]
public int Id { get; init; } = Id;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public string Id { get; init; } = string.Empty;
/// <summary>
/// The prototype containing information about the bounty.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("bounty", customTypeSerializer: typeof(PrototypeIdSerializer<CargoBountyPrototype>), required:true)]
public string Bounty { get; init; } = Bounty;
[DataField(required: true)]
public ProtoId<CargoBountyPrototype> Bounty { get; init; } = string.Empty;
/// <summary>
/// The time at which the bounty is closed and no longer is available.
/// </summary>
[DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan EndTime { get; init; } = EndTime;
public CargoBountyData() : this(default, string.Empty, default)
public CargoBountyData(CargoBountyPrototype bounty, int uniqueIdentifier)
{
Bounty = bounty.ID;
Id = $"{bounty.IdPrefix}{uniqueIdentifier:D3}";
}
}

View File

@@ -48,9 +48,9 @@ public sealed class CargoBountyConsoleState : BoundUserInterfaceState
[Serializable, NetSerializable]
public sealed class BountyPrintLabelMessage : BoundUserInterfaceMessage
{
public int BountyId;
public string BountyId;
public BountyPrintLabelMessage(int bountyId)
public BountyPrintLabelMessage(string bountyId)
{
BountyId = bountyId;
}

View File

@@ -9,7 +9,7 @@ namespace Content.Shared.Cargo.Prototypes;
/// that must be sold together in a labeled container in order
/// to receive a monetary reward.
/// </summary>
[Prototype("cargoBounty"), Serializable, NetSerializable]
[Prototype, Serializable, NetSerializable]
public sealed partial class CargoBountyPrototype : IPrototype
{
/// <inheritdoc/>
@@ -19,20 +19,26 @@ public sealed partial class CargoBountyPrototype : IPrototype
/// <summary>
/// The monetary reward for completing the bounty
/// </summary>
[DataField("reward", required: true)]
[DataField(required: true)]
public int Reward;
/// <summary>
/// A description for flava purposes.
/// </summary>
[DataField("description")]
public string Description = string.Empty;
[DataField]
public LocId Description = string.Empty;
/// <summary>
/// The entries that must be satisfied for the cargo bounty to be complete.
/// </summary>
[DataField("entries", required: true)]
[DataField( required: true)]
public List<CargoBountyItemEntry> Entries = new();
/// <summary>
/// A prefix appended to the beginning of a bounty's ID.
/// </summary>
[DataField]
public string IdPrefix = "NT";
}
[DataDefinition, Serializable, NetSerializable]
@@ -41,7 +47,7 @@ public readonly partial record struct CargoBountyItemEntry()
/// <summary>
/// A whitelist for determining what items satisfy the entry.
/// </summary>
[DataField("whitelist", required: true)]
[DataField(required: true)]
public EntityWhitelist Whitelist { get; init; } = default!;
// todo: implement some kind of simple generic condition system
@@ -49,12 +55,12 @@ public readonly partial record struct CargoBountyItemEntry()
/// <summary>
/// How much of the item must be present to satisfy the entry
/// </summary>
[DataField("amount")]
[DataField]
public int Amount { get; init; } = 1;
/// <summary>
/// A player-facing name for the item.
/// </summary>
[DataField("name")]
public string Name { get; init; } = string.Empty;
[DataField]
public LocId Name { get; init; } = string.Empty;
}