1
0

ThirstComponent.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using Content.Shared.Alert;
  2. using Content.Shared.Damage;
  3. using Content.Shared.Nutrition.EntitySystems;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  7. namespace Content.Shared.Nutrition.Components;
  8. [RegisterComponent, NetworkedComponent, Access(typeof(ThirstSystem))]
  9. [AutoGenerateComponentState(fieldDeltas: true), AutoGenerateComponentPause]
  10. public sealed partial class ThirstComponent : Component
  11. {
  12. // Base stuff
  13. [ViewVariables(VVAccess.ReadWrite)]
  14. [DataField("baseDecayRate")]
  15. [AutoNetworkedField]
  16. public float BaseDecayRate = 0.15f;
  17. [ViewVariables(VVAccess.ReadWrite)]
  18. [AutoNetworkedField]
  19. public float ActualDecayRate;
  20. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  21. public ThirstThreshold CurrentThirstThreshold;
  22. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  23. public ThirstThreshold LastThirstThreshold;
  24. [ViewVariables(VVAccess.ReadWrite)]
  25. [DataField("startingThirst")]
  26. [AutoNetworkedField]
  27. public float CurrentThirst = -1f;
  28. /// <summary>
  29. /// Damage dealt when your current threshold is at HungerThreshold.Dead
  30. /// </summary>
  31. [DataField("thirstDamage")]
  32. public DamageSpecifier? ThirstDamage;
  33. /// <summary>
  34. /// The time when the hunger will update next.
  35. /// </summary>
  36. [DataField("nextUpdateTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
  37. [AutoNetworkedField]
  38. [AutoPausedField]
  39. public TimeSpan NextUpdateTime;
  40. /// <summary>
  41. /// The time between each update.
  42. /// </summary>
  43. [ViewVariables(VVAccess.ReadWrite)]
  44. [DataField, AutoNetworkedField]
  45. public TimeSpan UpdateRate = TimeSpan.FromSeconds(1);
  46. [DataField("thresholds")]
  47. [AutoNetworkedField]
  48. public Dictionary<ThirstThreshold, float> ThirstThresholds = new()
  49. {
  50. {ThirstThreshold.OverHydrated, 600.0f},
  51. {ThirstThreshold.Okay, 450.0f},
  52. {ThirstThreshold.Thirsty, 300.0f},
  53. {ThirstThreshold.Parched, 150.0f},
  54. {ThirstThreshold.Dead, 0.0f},
  55. };
  56. [DataField]
  57. public ProtoId<AlertCategoryPrototype> ThirstyCategory = "Thirst";
  58. public static readonly Dictionary<ThirstThreshold, ProtoId<AlertPrototype>> ThirstThresholdAlertTypes = new()
  59. {
  60. {ThirstThreshold.Thirsty, "Thirsty"},
  61. {ThirstThreshold.Parched, "Parched"},
  62. {ThirstThreshold.Dead, "Parched"},
  63. };
  64. }
  65. [Flags]
  66. public enum ThirstThreshold : byte
  67. {
  68. // Hydrohomies
  69. Dead = 0,
  70. Parched = 1 << 0,
  71. Thirsty = 1 << 1,
  72. Okay = 1 << 2,
  73. OverHydrated = 1 << 3,
  74. }