CargoBountyHistoryData.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using Content.Shared.Cargo.Prototypes;
  2. using Robust.Shared.Prototypes;
  3. using Robust.Shared.Serialization;
  4. namespace Content.Shared.Cargo;
  5. /// <summary>
  6. /// A data structure for storing historical information about bounties.
  7. /// </summary>
  8. [DataDefinition, NetSerializable, Serializable]
  9. public readonly partial record struct CargoBountyHistoryData
  10. {
  11. /// <summary>
  12. /// A unique id used to identify the bounty
  13. /// </summary>
  14. [DataField]
  15. public string Id { get; init; } = string.Empty;
  16. /// <summary>
  17. /// Whether this bounty was completed or skipped.
  18. /// </summary>
  19. [DataField]
  20. public BountyResult Result { get; init; } = BountyResult.Completed;
  21. /// <summary>
  22. /// Optional name of the actor that completed/skipped the bounty.
  23. /// </summary>
  24. [DataField]
  25. public string? ActorName { get; init; } = default;
  26. /// <summary>
  27. /// Time when this bounty was completed or skipped
  28. /// </summary>
  29. [DataField]
  30. public TimeSpan Timestamp { get; init; } = TimeSpan.MinValue;
  31. /// <summary>
  32. /// The prototype containing information about the bounty.
  33. /// </summary>
  34. [DataField(required: true)]
  35. public ProtoId<CargoBountyPrototype> Bounty { get; init; } = string.Empty;
  36. public CargoBountyHistoryData(CargoBountyData bounty, BountyResult result, TimeSpan timestamp, string? actorName)
  37. {
  38. Bounty = bounty.Bounty;
  39. Result = result;
  40. Id = bounty.Id;
  41. ActorName = actorName;
  42. Timestamp = timestamp;
  43. }
  44. /// <summary>
  45. /// Covers how a bounty was actually finished.
  46. /// </summary>
  47. public enum BountyResult
  48. {
  49. /// <summary>
  50. /// Bounty was actually fulfilled and the goods sold
  51. /// </summary>
  52. Completed = 0,
  53. /// <summary>
  54. /// Bounty was explicitly skipped by some actor
  55. /// </summary>
  56. Skipped = 1,
  57. }
  58. }