1
0

GasTankComponent.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using Content.Shared.Atmos;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  5. namespace Content.Server.Atmos.Components
  6. {
  7. [RegisterComponent]
  8. public sealed partial class GasTankComponent : Component, IGasMixtureHolder
  9. {
  10. public const float MaxExplosionRange = 26f;
  11. private const float DefaultLowPressure = 0f;
  12. private const float DefaultOutputPressure = Atmospherics.OneAtmosphere;
  13. public int Integrity = 3;
  14. public bool IsLowPressure => (Air?.Pressure ?? 0F) <= TankLowPressure;
  15. [ViewVariables(VVAccess.ReadWrite), DataField("ruptureSound")]
  16. public SoundSpecifier RuptureSound = new SoundPathSpecifier("/Audio/Effects/spray.ogg");
  17. [ViewVariables(VVAccess.ReadWrite), DataField("connectSound")]
  18. public SoundSpecifier? ConnectSound =
  19. new SoundPathSpecifier("/Audio/Effects/internals.ogg")
  20. {
  21. Params = AudioParams.Default.WithVolume(5f),
  22. };
  23. [ViewVariables(VVAccess.ReadWrite), DataField("disconnectSound")]
  24. public SoundSpecifier? DisconnectSound;
  25. // Cancel toggles sounds if we re-toggle again.
  26. public EntityUid? ConnectStream;
  27. public EntityUid? DisconnectStream;
  28. [DataField("air"), ViewVariables(VVAccess.ReadWrite)]
  29. public GasMixture Air { get; set; } = new();
  30. /// <summary>
  31. /// Pressure at which tank should be considered 'low' such as for internals.
  32. /// </summary>
  33. [DataField("tankLowPressure"), ViewVariables(VVAccess.ReadWrite)]
  34. public float TankLowPressure = DefaultLowPressure;
  35. /// <summary>
  36. /// Distributed pressure.
  37. /// </summary>
  38. [DataField("outputPressure"), ViewVariables(VVAccess.ReadWrite)]
  39. public float OutputPressure = DefaultOutputPressure;
  40. /// <summary>
  41. /// The maximum allowed output pressure.
  42. /// </summary>
  43. [DataField("maxOutputPressure"), ViewVariables(VVAccess.ReadWrite)]
  44. public float MaxOutputPressure = 3 * DefaultOutputPressure;
  45. /// <summary>
  46. /// Tank is connected to internals.
  47. /// </summary>
  48. [ViewVariables]
  49. public bool IsConnected => User != null;
  50. [ViewVariables]
  51. public EntityUid? User;
  52. /// <summary>
  53. /// True if this entity was recently moved out of a container. This might have been a hand -> inventory
  54. /// transfer, or it might have been the user dropping the tank. This indicates the tank needs to be checked.
  55. /// </summary>
  56. [ViewVariables]
  57. public bool CheckUser;
  58. /// <summary>
  59. /// Pressure at which tanks start leaking.
  60. /// </summary>
  61. [DataField("tankLeakPressure"), ViewVariables(VVAccess.ReadWrite)]
  62. public float TankLeakPressure = 30 * Atmospherics.OneAtmosphere;
  63. /// <summary>
  64. /// Pressure at which tank spills all contents into atmosphere.
  65. /// </summary>
  66. [DataField("tankRupturePressure"), ViewVariables(VVAccess.ReadWrite)]
  67. public float TankRupturePressure = 40 * Atmospherics.OneAtmosphere;
  68. /// <summary>
  69. /// Base 3x3 explosion.
  70. /// </summary>
  71. [DataField("tankFragmentPressure"), ViewVariables(VVAccess.ReadWrite)]
  72. public float TankFragmentPressure = 50 * Atmospherics.OneAtmosphere;
  73. /// <summary>
  74. /// Increases explosion for each scale kPa above threshold.
  75. /// </summary>
  76. [DataField("tankFragmentScale"), ViewVariables(VVAccess.ReadWrite)]
  77. public float TankFragmentScale = 2 * Atmospherics.OneAtmosphere;
  78. [DataField("toggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
  79. public string ToggleAction = "ActionToggleInternals";
  80. [DataField("toggleActionEntity")] public EntityUid? ToggleActionEntity;
  81. /// <summary>
  82. /// Valve to release gas from tank
  83. /// </summary>
  84. [DataField("isValveOpen"), ViewVariables(VVAccess.ReadWrite)]
  85. public bool IsValveOpen = false;
  86. /// <summary>
  87. /// Gas release rate in L/s
  88. /// </summary>
  89. [DataField("valveOutputRate"), ViewVariables(VVAccess.ReadWrite)]
  90. public float ValveOutputRate = 100f;
  91. [DataField("valveSound"), ViewVariables(VVAccess.ReadWrite)]
  92. public SoundSpecifier ValveSound =
  93. new SoundCollectionSpecifier("valveSqueak")
  94. {
  95. Params = AudioParams.Default.WithVolume(-5f),
  96. };
  97. }
  98. }