StaminaComponent.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using Content.Shared.Alert;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  5. namespace Content.Shared.Damage.Components;
  6. /// <summary>
  7. /// Add to an entity to paralyze it whenever it reaches critical amounts of Stamina DamageType.
  8. /// </summary>
  9. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), AutoGenerateComponentPause]
  10. public sealed partial class StaminaComponent : Component
  11. {
  12. /// <summary>
  13. /// Have we reached peak stamina damage and been paralyzed?
  14. /// </summary>
  15. [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
  16. public bool Critical;
  17. /// <summary>
  18. /// How much stamina reduces per second.
  19. /// </summary>
  20. [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
  21. public float Decay = 3f;
  22. [DataField, AutoNetworkedField]
  23. public float DecayModifier = 1f; // stalker-changes
  24. /// <summary>
  25. /// How much time after receiving damage until stamina starts decreasing.
  26. /// </summary>
  27. [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
  28. public float Cooldown = 3f;
  29. /// <summary>
  30. /// How much stamina damage this entity has taken.
  31. /// </summary>
  32. [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
  33. public float StaminaDamage;
  34. /// <summary>
  35. /// How much stamina damage is required to entire stam crit.
  36. /// </summary>
  37. [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
  38. public float CritThreshold = 100f;
  39. [DataField, AutoNetworkedField]
  40. public float CritThresholdModifier = 1f; // stalker-changes
  41. /// <summary>
  42. /// A dictionary of active stamina drains, with the key being the source of the drain,
  43. /// DrainRate how much it changes per tick, and ModifiesSpeed if it should slow down the user.
  44. /// </summary>
  45. [DataField, AutoNetworkedField]
  46. public Dictionary<EntityUid, (float DrainRate, bool ModifiesSpeed)> ActiveDrains = new();
  47. /// <summary>
  48. /// How long will this mob be stunned for?
  49. /// </summary>
  50. [ViewVariables(VVAccess.ReadWrite), DataField]
  51. public TimeSpan StunTime = TimeSpan.FromSeconds(6);
  52. /// <summary>
  53. /// To avoid continuously updating our data we track the last time we updated so we can extrapolate our current stamina.
  54. /// </summary>
  55. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
  56. [AutoPausedField]
  57. public TimeSpan NextUpdate = TimeSpan.Zero;
  58. [DataField]
  59. public ProtoId<AlertPrototype> StaminaAlert = "Stamina";
  60. // stalker-changes-start
  61. /// <summary>
  62. /// How much stamina damage is required to entire stam crit.
  63. /// </summary>
  64. [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
  65. public float SlowdownThreshold = 50f; // CritThreshold / 2
  66. // stalker-changes-end
  67. /// <summary>
  68. /// When the last "gasp" message was sent
  69. /// </summary>
  70. [DataField("lastMessageTime"), AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  71. public TimeSpan LastMessageTime { get; set; } = TimeSpan.Zero;
  72. }