ScatteringGrenadeComponent.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using Content.Shared.Explosion.EntitySystems;
  2. using Content.Shared.Whitelist;
  3. using Robust.Shared.Containers;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Shared.Explosion.Components;
  7. /// <summary>
  8. /// Use this component if the grenade splits into entities that make use of Timers
  9. /// or if you just want it to throw entities out in the world
  10. /// </summary>
  11. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedScatteringGrenadeSystem))]
  12. public sealed partial class ScatteringGrenadeComponent : Component
  13. {
  14. public Container Container = default!;
  15. [DataField]
  16. public EntityWhitelist? Whitelist;
  17. /// <summary>
  18. /// What we fill our prototype with if we want to pre-spawn with entities.
  19. /// </summary>
  20. [DataField]
  21. public EntProtoId? FillPrototype;
  22. /// <summary>
  23. /// If we have a pre-fill how many more can we spawn.
  24. /// </summary>
  25. [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
  26. public int UnspawnedCount;
  27. /// <summary>
  28. /// Max amount of entities inside the container
  29. /// </summary>
  30. [DataField]
  31. public int Capacity = 3;
  32. /// <summary>
  33. /// Number of grenades currently contained in the cluster (both spawned and unspawned)
  34. /// </summary>
  35. [ViewVariables(VVAccess.ReadOnly)]
  36. public int Count => UnspawnedCount + Container.ContainedEntities.Count;
  37. /// <summary>
  38. /// Decides if contained entities trigger after getting launched
  39. /// </summary>
  40. [DataField]
  41. public bool TriggerContents = true;
  42. #region Trigger time parameters for scattered entities
  43. /// <summary>
  44. /// Minimum delay in seconds before any entities start to be triggered.
  45. /// </summary>
  46. [DataField]
  47. public float DelayBeforeTriggerContents = 1.0f;
  48. /// <summary>
  49. /// Maximum delay in seconds to add between individual entity triggers
  50. /// </summary>
  51. [DataField]
  52. public float IntervalBetweenTriggersMax;
  53. /// <summary>
  54. /// Minimum delay in seconds to add between individual entity triggers
  55. /// </summary>
  56. [DataField]
  57. public float IntervalBetweenTriggersMin;
  58. #endregion
  59. #region Throwing parameters for the scattered entities
  60. /// <summary>
  61. /// Should the angle the entities get thrown at be random
  62. /// instead of uniformly distributed
  63. /// </summary>
  64. [DataField]
  65. public bool RandomAngle;
  66. /// <summary>
  67. /// The speed at which the entities get thrown
  68. /// </summary>
  69. [DataField]
  70. public float Velocity = 5;
  71. /// <summary>
  72. /// Static distance grenades will be thrown to if RandomDistance is false.
  73. /// </summary>
  74. [DataField]
  75. public float Distance = 1f;
  76. /// <summary>
  77. /// Should the distance the entities get thrown be random
  78. /// </summary>
  79. [DataField]
  80. public bool RandomDistance;
  81. /// <summary>
  82. /// Max distance grenades can randomly be thrown to.
  83. /// </summary>
  84. [DataField]
  85. public float RandomThrowDistanceMax = 2.5f;
  86. /// <summary>
  87. /// Minimal distance grenades can randomly be thrown to.
  88. /// </summary>
  89. [DataField]
  90. public float RandomThrowDistanceMin;
  91. #endregion
  92. /// <summary>
  93. /// Whether the main grenade has been triggered or not
  94. /// We need to store this because we are only allowed to spawn and trigger timed entities on the next available frame update
  95. /// </summary>
  96. public bool IsTriggered = false;
  97. }