Files
tbd-station-14/Content.Shared/Cargo/CargoBountyHistoryData.cs
BarryNorfolk 18592148f7 Add history tab to bounty console (#33932)
* Add struct for holding historical data on cargo bounties

* Add localisation strings for bounty history

* Add new XAML entry for display bounty history

* Expand cargo bounty menu to include tabs

* Ensure station databases hold historical bounty data

* Add to the bounty history when removing one from active

* Feed bounty history into cargo's bounty system

* Move tab title setting to constructor

* Remove redundant access specifications

* Remove un-needed override

* Fixup BountyHistoryEntry backing code

* Fix formatting in CargoBountyMenu

* Reformat BountyHistoryData

* Rework TryRemoveBounty to use new Entity type

* Add Enum for showing bounty results

* Rework look and feel of History tab

* Add visible text when no bounties have been completed yet

* Remove control

* Swap default to null

* Reverse ordering of bounties so last entry comes first

* Remove redundant Visible

* Move enum docs into the enum
2025-01-30 09:27:36 -08:00

68 lines
1.9 KiB
C#

using Content.Shared.Cargo.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Cargo;
/// <summary>
/// A data structure for storing historical information about bounties.
/// </summary>
[DataDefinition, NetSerializable, Serializable]
public readonly partial record struct CargoBountyHistoryData
{
/// <summary>
/// A unique id used to identify the bounty
/// </summary>
[DataField]
public string Id { get; init; } = string.Empty;
/// <summary>
/// Whether this bounty was completed or skipped.
/// </summary>
[DataField]
public BountyResult Result { get; init; } = BountyResult.Completed;
/// <summary>
/// Optional name of the actor that completed/skipped the bounty.
/// </summary>
[DataField]
public string? ActorName { get; init; } = default;
/// <summary>
/// Time when this bounty was completed or skipped
/// </summary>
[DataField]
public TimeSpan Timestamp { get; init; } = TimeSpan.MinValue;
/// <summary>
/// The prototype containing information about the bounty.
/// </summary>
[DataField(required: true)]
public ProtoId<CargoBountyPrototype> Bounty { get; init; } = string.Empty;
public CargoBountyHistoryData(CargoBountyData bounty, BountyResult result, TimeSpan timestamp, string? actorName)
{
Bounty = bounty.Bounty;
Result = result;
Id = bounty.Id;
ActorName = actorName;
Timestamp = timestamp;
}
/// <summary>
/// Covers how a bounty was actually finished.
/// </summary>
public enum BountyResult
{
/// <summary>
/// Bounty was actually fulfilled and the goods sold
/// </summary>
Completed = 0,
/// <summary>
/// Bounty was explicitly skipped by some actor
/// </summary>
Skipped = 1,
}
}