GasAnalyzerComponent.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using Robust.Shared.GameStates;
  2. using Robust.Shared.Map;
  3. using Robust.Shared.Serialization;
  4. namespace Content.Shared.Atmos.Components;
  5. [RegisterComponent, NetworkedComponent]
  6. public sealed partial class GasAnalyzerComponent : Component
  7. {
  8. [ViewVariables]
  9. public EntityUid? Target;
  10. [ViewVariables]
  11. public EntityUid User;
  12. [DataField("enabled"), ViewVariables(VVAccess.ReadWrite)]
  13. public bool Enabled;
  14. [Serializable, NetSerializable]
  15. public enum GasAnalyzerUiKey
  16. {
  17. Key,
  18. }
  19. /// <summary>
  20. /// Atmospheric data is gathered in the system and sent to the user
  21. /// </summary>
  22. [Serializable, NetSerializable]
  23. public sealed class GasAnalyzerUserMessage : BoundUserInterfaceMessage
  24. {
  25. public string DeviceName;
  26. public NetEntity DeviceUid;
  27. public bool DeviceFlipped;
  28. public string? Error;
  29. public GasMixEntry[] NodeGasMixes;
  30. public GasAnalyzerUserMessage(GasMixEntry[] nodeGasMixes, string deviceName, NetEntity deviceUid, bool deviceFlipped, string? error = null)
  31. {
  32. NodeGasMixes = nodeGasMixes;
  33. DeviceName = deviceName;
  34. DeviceUid = deviceUid;
  35. DeviceFlipped = deviceFlipped;
  36. Error = error;
  37. }
  38. }
  39. /// <summary>
  40. /// Contains information on a gas mix entry, turns into a tab in the UI
  41. /// </summary>
  42. [Serializable, NetSerializable]
  43. public struct GasMixEntry
  44. {
  45. /// <summary>
  46. /// Name of the tab in the UI
  47. /// </summary>
  48. public readonly string Name;
  49. public readonly float Volume;
  50. public readonly float Pressure;
  51. public readonly float Temperature;
  52. public readonly GasEntry[]? Gases;
  53. public GasMixEntry(string name, float volume, float pressure, float temperature, GasEntry[]? gases = null)
  54. {
  55. Name = name;
  56. Volume = volume;
  57. Pressure = pressure;
  58. Temperature = temperature;
  59. Gases = gases;
  60. }
  61. }
  62. /// <summary>
  63. /// Individual gas entry data for populating the UI
  64. /// </summary>
  65. [Serializable, NetSerializable]
  66. public struct GasEntry
  67. {
  68. public readonly string Name;
  69. public readonly float Amount;
  70. public readonly string Color;
  71. public GasEntry(string name, float amount, string color)
  72. {
  73. Name = name;
  74. Amount = amount;
  75. Color = color;
  76. }
  77. public override string ToString()
  78. {
  79. // e.g. "Plasma: 2000 mol"
  80. return Loc.GetString(
  81. "gas-entry-info",
  82. ("gasName", Name),
  83. ("gasAmount", Amount));
  84. }
  85. }
  86. [Serializable, NetSerializable]
  87. public sealed class GasAnalyzerDisableMessage : BoundUserInterfaceMessage
  88. {
  89. }
  90. }
  91. [Serializable, NetSerializable]
  92. public enum GasAnalyzerVisuals : byte
  93. {
  94. Enabled,
  95. }