1
0

CargoOrderData.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Robust.Shared.Serialization;
  2. using System.Text;
  3. namespace Content.Shared.Cargo
  4. {
  5. [DataDefinition, NetSerializable, Serializable]
  6. public sealed partial class CargoOrderData
  7. {
  8. /// <summary>
  9. /// Price when the order was added.
  10. /// </summary>
  11. [DataField]
  12. public int Price;
  13. /// <summary>
  14. /// A unique (arbitrary) ID which identifies this order.
  15. /// </summary>
  16. [DataField]
  17. public int OrderId { get; private set; }
  18. /// <summary>
  19. /// Prototype Id for the item to be created
  20. /// </summary>
  21. [DataField]
  22. public string ProductId { get; private set; }
  23. /// <summary>
  24. /// Prototype Name
  25. /// </summary>
  26. [DataField]
  27. public string ProductName { get; private set; }
  28. /// <summary>
  29. /// The number of items in the order. Not readonly, as it might change
  30. /// due to caps on the amount of orders that can be placed.
  31. /// </summary>
  32. [DataField]
  33. public int OrderQuantity;
  34. /// <summary>
  35. /// How many instances of this order that we've already dispatched
  36. /// </summary>
  37. [DataField]
  38. public int NumDispatched = 0;
  39. [DataField]
  40. public string Requester { get; private set; }
  41. // public String RequesterRank; // TODO Figure out how to get Character ID card data
  42. // public int RequesterId;
  43. [DataField]
  44. public string Reason { get; private set; }
  45. public bool Approved;
  46. [DataField]
  47. public string? Approver;
  48. public CargoOrderData(int orderId, string productId, string productName, int price, int amount, string requester, string reason)
  49. {
  50. OrderId = orderId;
  51. ProductId = productId;
  52. ProductName = productName;
  53. Price = price;
  54. OrderQuantity = amount;
  55. Requester = requester;
  56. Reason = reason;
  57. }
  58. public void SetApproverData(string? approver)
  59. {
  60. Approver = approver;
  61. }
  62. public void SetApproverData(string? fullName, string? jobTitle)
  63. {
  64. var sb = new StringBuilder();
  65. if (!string.IsNullOrWhiteSpace(fullName))
  66. {
  67. sb.Append($"{fullName} ");
  68. }
  69. if (!string.IsNullOrWhiteSpace(jobTitle))
  70. {
  71. sb.Append($"({jobTitle})");
  72. }
  73. Approver = sb.ToString();
  74. }
  75. }
  76. }