SalvageExpeditions.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using Content.Shared.Salvage.Expeditions.Modifiers;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Serialization;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  6. namespace Content.Shared.Salvage.Expeditions;
  7. [Serializable, NetSerializable]
  8. public sealed class SalvageExpeditionConsoleState : BoundUserInterfaceState
  9. {
  10. public TimeSpan NextOffer;
  11. public bool Claimed;
  12. public bool Cooldown;
  13. public ushort ActiveMission;
  14. public List<SalvageMissionParams> Missions;
  15. public SalvageExpeditionConsoleState(TimeSpan nextOffer, bool claimed, bool cooldown, ushort activeMission, List<SalvageMissionParams> missions)
  16. {
  17. NextOffer = nextOffer;
  18. Claimed = claimed;
  19. Cooldown = cooldown;
  20. ActiveMission = activeMission;
  21. Missions = missions;
  22. }
  23. }
  24. /// <summary>
  25. /// Used to interact with salvage expeditions and claim them.
  26. /// </summary>
  27. [RegisterComponent, NetworkedComponent]
  28. public sealed partial class SalvageExpeditionConsoleComponent : Component
  29. {
  30. /// <summary>
  31. /// The sound made when spawning a coordinates disk
  32. /// </summary>
  33. [DataField]
  34. public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/terminal_insert_disc.ogg");
  35. }
  36. [Serializable, NetSerializable]
  37. public sealed class ClaimSalvageMessage : BoundUserInterfaceMessage
  38. {
  39. public ushort Index;
  40. }
  41. /// <summary>
  42. /// Added per station to store data on their available salvage missions.
  43. /// </summary>
  44. [RegisterComponent, AutoGenerateComponentPause]
  45. public sealed partial class SalvageExpeditionDataComponent : Component
  46. {
  47. /// <summary>
  48. /// Is there an active salvage expedition.
  49. /// </summary>
  50. [ViewVariables]
  51. public bool Claimed => ActiveMission != 0;
  52. /// <summary>
  53. /// Are we actively cooling down from the last salvage mission.
  54. /// </summary>
  55. [ViewVariables(VVAccess.ReadWrite), DataField("cooldown")]
  56. public bool Cooldown = false;
  57. /// <summary>
  58. /// Nexy time salvage missions are offered.
  59. /// </summary>
  60. [ViewVariables(VVAccess.ReadWrite), DataField("nextOffer", customTypeSerializer:typeof(TimeOffsetSerializer))]
  61. [AutoPausedField]
  62. public TimeSpan NextOffer;
  63. [ViewVariables]
  64. public readonly Dictionary<ushort, SalvageMissionParams> Missions = new();
  65. [ViewVariables] public ushort ActiveMission;
  66. public ushort NextIndex = 1;
  67. }
  68. [Serializable, NetSerializable]
  69. public sealed record SalvageMissionParams
  70. {
  71. [ViewVariables]
  72. public ushort Index;
  73. [ViewVariables(VVAccess.ReadWrite)] public int Seed;
  74. public string Difficulty = string.Empty;
  75. }
  76. /// <summary>
  77. /// Created from <see cref="SalvageMissionParams"/>. Only needed for data the client also needs for mission
  78. /// display.
  79. /// </summary>
  80. public sealed record SalvageMission(
  81. int Seed,
  82. string Dungeon,
  83. string Faction,
  84. string Biome,
  85. string Air,
  86. float Temperature,
  87. Color? Color,
  88. TimeSpan Duration,
  89. List<string> Modifiers)
  90. {
  91. /// <summary>
  92. /// Seed used for the mission.
  93. /// </summary>
  94. public readonly int Seed = Seed;
  95. /// <summary>
  96. /// <see cref="SalvageDungeonModPrototype"/> to be used.
  97. /// </summary>
  98. public readonly string Dungeon = Dungeon;
  99. /// <summary>
  100. /// <see cref="SalvageFactionPrototype"/> to be used.
  101. /// </summary>
  102. public readonly string Faction = Faction;
  103. /// <summary>
  104. /// Biome to be used for the mission.
  105. /// </summary>
  106. public readonly string Biome = Biome;
  107. /// <summary>
  108. /// Air mixture to be used for the mission's planet.
  109. /// </summary>
  110. public readonly string Air = Air;
  111. /// <summary>
  112. /// Temperature of the planet's atmosphere.
  113. /// </summary>
  114. public readonly float Temperature = Temperature;
  115. /// <summary>
  116. /// Lighting color to be used (AKA outdoor lighting).
  117. /// </summary>
  118. public readonly Color? Color = Color;
  119. /// <summary>
  120. /// Mission duration.
  121. /// </summary>
  122. public TimeSpan Duration = Duration;
  123. /// <summary>
  124. /// Modifiers (outside of the above) applied to the mission.
  125. /// </summary>
  126. public List<string> Modifiers = Modifiers;
  127. }
  128. [Serializable, NetSerializable]
  129. public enum SalvageConsoleUiKey : byte
  130. {
  131. Expedition,
  132. }