1
0

RespiratorComponent.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Content.Server.Body.Systems;
  2. using Content.Shared.Chat.Prototypes;
  3. using Content.Shared.Damage;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  6. namespace Content.Server.Body.Components
  7. {
  8. [RegisterComponent, Access(typeof(RespiratorSystem))]
  9. public sealed partial class RespiratorComponent : Component
  10. {
  11. /// <summary>
  12. /// The next time that this body will inhale or exhale.
  13. /// </summary>
  14. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  15. public TimeSpan NextUpdate;
  16. /// <summary>
  17. /// The interval between updates. Each update is either inhale or exhale,
  18. /// so a full cycle takes twice as long.
  19. /// </summary>
  20. [DataField]
  21. public TimeSpan UpdateInterval = TimeSpan.FromSeconds(2);
  22. /// <summary>
  23. /// Saturation level. Reduced by UpdateInterval each tick.
  24. /// Can be thought of as 'how many seconds you have until you start suffocating' in this configuration.
  25. /// </summary>
  26. [DataField]
  27. public float Saturation = 5.0f;
  28. /// <summary>
  29. /// At what level of saturation will you begin to suffocate?
  30. /// </summary>
  31. [DataField]
  32. public float SuffocationThreshold;
  33. [DataField]
  34. public float MaxSaturation = 5.0f;
  35. [DataField]
  36. public float MinSaturation = -2.0f;
  37. // TODO HYPEROXIA?
  38. [DataField(required: true)]
  39. [ViewVariables(VVAccess.ReadWrite)]
  40. public DamageSpecifier Damage = default!;
  41. [DataField(required: true)]
  42. [ViewVariables(VVAccess.ReadWrite)]
  43. public DamageSpecifier DamageRecovery = default!;
  44. [DataField]
  45. public TimeSpan GaspEmoteCooldown = TimeSpan.FromSeconds(8);
  46. [ViewVariables]
  47. public TimeSpan LastGaspEmoteTime;
  48. /// <summary>
  49. /// The emote when gasps
  50. /// </summary>
  51. [DataField]
  52. public ProtoId<EmotePrototype> GaspEmote = "Gasp";
  53. /// <summary>
  54. /// How many cycles in a row has the mob been under-saturated?
  55. /// </summary>
  56. [ViewVariables]
  57. public int SuffocationCycles = 0;
  58. /// <summary>
  59. /// How many cycles in a row does it take for the suffocation alert to pop up?
  60. /// </summary>
  61. [ViewVariables]
  62. public int SuffocationCycleThreshold = 3;
  63. [ViewVariables]
  64. public RespiratorStatus Status = RespiratorStatus.Inhaling;
  65. }
  66. }
  67. public enum RespiratorStatus
  68. {
  69. Inhaling,
  70. Exhaling
  71. }