GeigerComponent.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using Content.Shared.Radiation.Systems;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Serialization;
  5. namespace Content.Shared.Radiation.Components;
  6. /// <summary>
  7. /// Geiger counter that shows current radiation level.
  8. /// Can be added as a component to clothes.
  9. /// </summary>
  10. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
  11. [Access(typeof(SharedGeigerSystem))]
  12. public sealed partial class GeigerComponent : Component
  13. {
  14. /// <summary>
  15. /// If true it will be active only when player equipped it.
  16. /// </summary>
  17. [DataField]
  18. public bool AttachedToSuit;
  19. /// <summary>
  20. /// Is geiger counter currently active?
  21. /// If false attached entity will ignore any radiation rays.
  22. /// </summary>
  23. [DataField, AutoNetworkedField]
  24. public bool IsEnabled;
  25. /// <summary>
  26. /// Should it shows examine message with current radiation level?
  27. /// </summary>
  28. [ViewVariables(VVAccess.ReadWrite)]
  29. [DataField]
  30. public bool ShowExamine;
  31. /// <summary>
  32. /// Should it shows item control when equipped by player?
  33. /// </summary>
  34. [ViewVariables(VVAccess.ReadWrite)]
  35. [DataField]
  36. public bool ShowControl;
  37. /// <summary>
  38. /// Map of sounds that should be play on loop for different radiation levels.
  39. /// </summary>
  40. [DataField]
  41. public Dictionary<GeigerDangerLevel, SoundSpecifier> Sounds = new()
  42. {
  43. {GeigerDangerLevel.Low, new SoundPathSpecifier("/Audio/Items/Geiger/low.ogg")},
  44. {GeigerDangerLevel.Med, new SoundPathSpecifier("/Audio/Items/Geiger/med.ogg")},
  45. {GeigerDangerLevel.High, new SoundPathSpecifier("/Audio/Items/Geiger/high.ogg")},
  46. {GeigerDangerLevel.Extreme, new SoundPathSpecifier("/Audio/Items/Geiger/ext.ogg")}
  47. };
  48. /// <summary>
  49. /// Current radiation level in rad per second.
  50. /// </summary>
  51. [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
  52. public float CurrentRadiation;
  53. /// <summary>
  54. /// Estimated radiation danger level.
  55. /// </summary>
  56. [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
  57. public GeigerDangerLevel DangerLevel = GeigerDangerLevel.None;
  58. /// <summary>
  59. /// Current player that equipped geiger counter.
  60. /// Because sound is annoying, geiger counter clicks will play
  61. /// only for player that equipped it.
  62. /// </summary>
  63. [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
  64. public EntityUid? User;
  65. /// <summary>
  66. /// Marked true if control needs to update UI with latest component state.
  67. /// </summary>
  68. [Access(typeof(SharedGeigerSystem), Other = AccessPermissions.ReadWrite)]
  69. public bool UiUpdateNeeded;
  70. /// <summary>
  71. /// Current stream of geiger counter audio.
  72. /// Played only for current user.
  73. /// </summary>
  74. public EntityUid? Stream;
  75. }
  76. [Serializable, NetSerializable]
  77. public enum GeigerDangerLevel : byte
  78. {
  79. None,
  80. Low,
  81. Med,
  82. High,
  83. Extreme
  84. }
  85. [Serializable, NetSerializable]
  86. public enum GeigerLayers : byte
  87. {
  88. Screen
  89. }
  90. [Serializable, NetSerializable]
  91. public enum GeigerVisuals : byte
  92. {
  93. DangerLevel,
  94. IsEnabled
  95. }