1
0

PressurizedSolutionComponent.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Content.Shared.Nutrition.EntitySystems;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.GameStates;
  4. namespace Content.Shared.Nutrition.Components;
  5. /// <summary>
  6. /// Represents a solution container that can hold the pressure from a solution that
  7. /// gets fizzy when aggitated, and can spray the solution when opened or thrown.
  8. /// Handles simulating the fizziness of the solution, responding to aggitating events,
  9. /// and spraying the solution out when opening or throwing the entity.
  10. /// </summary>
  11. [NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
  12. [RegisterComponent, Access(typeof(PressurizedSolutionSystem))]
  13. public sealed partial class PressurizedSolutionComponent : Component
  14. {
  15. /// <summary>
  16. /// The name of the solution to use.
  17. /// </summary>
  18. [DataField]
  19. public string Solution = "drink";
  20. /// <summary>
  21. /// The sound to play when the solution sprays out of the container.
  22. /// </summary>
  23. [DataField]
  24. public SoundSpecifier SpraySound = new SoundPathSpecifier("/Audio/Items/soda_spray.ogg");
  25. /// <summary>
  26. /// The longest amount of time that the solution can remain fizzy after being aggitated.
  27. /// Put another way, how long the solution will remain fizzy when aggitated the maximum amount.
  28. /// Used to calculate the current fizziness level.
  29. /// </summary>
  30. [DataField]
  31. public TimeSpan FizzinessMaxDuration = TimeSpan.FromSeconds(120);
  32. /// <summary>
  33. /// The time at which the solution will be fully settled after being shaken.
  34. /// </summary>
  35. [DataField, AutoNetworkedField, AutoPausedField]
  36. public TimeSpan FizzySettleTime;
  37. /// <summary>
  38. /// How much to increase the solution's fizziness each time it's shaken.
  39. /// This assumes the solution has maximum fizzability.
  40. /// A value of 1 will maximize it with a single shake, and a value of
  41. /// 0.5 will increase it by half with each shake.
  42. /// </summary>
  43. [DataField]
  44. public float FizzinessAddedOnShake = 1.0f;
  45. /// <summary>
  46. /// How much to increase the solution's fizziness when it lands after being thrown.
  47. /// This assumes the solution has maximum fizzability.
  48. /// </summary>
  49. [DataField]
  50. public float FizzinessAddedOnLand = 0.25f;
  51. /// <summary>
  52. /// How much to modify the chance of spraying when the entity is opened.
  53. /// Increasing this effectively increases the fizziness value when checking if it should spray.
  54. /// </summary>
  55. [DataField]
  56. public float SprayChanceModOnOpened = -0.01f; // Just enough to prevent spraying at 0 fizziness
  57. /// <summary>
  58. /// How much to modify the chance of spraying when the entity is shaken.
  59. /// Increasing this effectively increases the fizziness value when checking if it should spray.
  60. /// </summary>
  61. [DataField]
  62. public float SprayChanceModOnShake = -1; // No spraying when shaken by default
  63. /// <summary>
  64. /// How much to modify the chance of spraying when the entity lands after being thrown.
  65. /// Increasing this effectively increases the fizziness value when checking if it should spray.
  66. /// </summary>
  67. [DataField]
  68. public float SprayChanceModOnLand = 0.25f;
  69. /// <summary>
  70. /// Holds the current randomly-rolled threshold value for spraying.
  71. /// If fizziness exceeds this value when the entity is opened, it will spray.
  72. /// By rolling this value when the entity is aggitated, we can have randomization
  73. /// while still having prediction!
  74. /// </summary>
  75. [DataField, AutoNetworkedField]
  76. public float SprayFizzinessThresholdRoll;
  77. /// <summary>
  78. /// Popup message shown to user when sprayed by the solution.
  79. /// </summary>
  80. [DataField]
  81. public LocId SprayHolderMessageSelf = "pressurized-solution-spray-holder-self";
  82. /// <summary>
  83. /// Popup message shown to others when a user is sprayed by the solution.
  84. /// </summary>
  85. [DataField]
  86. public LocId SprayHolderMessageOthers = "pressurized-solution-spray-holder-others";
  87. /// <summary>
  88. /// Popup message shown above the entity when the solution sprays without a target.
  89. /// </summary>
  90. [DataField]
  91. public LocId SprayGroundMessage = "pressurized-solution-spray-ground";
  92. }