SharedBeamComponent.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using Robust.Shared.Audio;
  2. using Robust.Shared.Serialization;
  3. namespace Content.Shared.Beam.Components;
  4. /// <summary>
  5. /// Use this as a generic beam. Not for something like a laser gun, more for something continuous like lightning.
  6. /// </summary>
  7. public abstract partial class SharedBeamComponent : Component
  8. {
  9. /// <summary>
  10. /// A unique list of targets that this beam collided with.
  11. /// Useful for code like Arcing in the Lightning Component.
  12. /// </summary>
  13. [DataField("hitTargets")]
  14. public HashSet<EntityUid> HitTargets = new();
  15. /// <summary>
  16. /// The virtual entity representing a beam.
  17. /// </summary>
  18. [DataField("virtualBeamController")]
  19. public EntityUid? VirtualBeamController;
  20. /// <summary>
  21. /// The first beam created, useful for keeping track of chains.
  22. /// </summary>
  23. [DataField("originBeam")]
  24. public EntityUid OriginBeam;
  25. /// <summary>
  26. /// The entity that fired the beam originally
  27. /// </summary>
  28. [DataField("beamShooter")]
  29. public EntityUid BeamShooter;
  30. /// <summary>
  31. /// A unique list of created beams that the controller keeps track of.
  32. /// </summary>
  33. [DataField("createdBeams")]
  34. public HashSet<EntityUid> CreatedBeams = new();
  35. /// <summary>
  36. /// Sound played upon creation
  37. /// </summary>
  38. [ViewVariables(VVAccess.ReadWrite)]
  39. [DataField("sound")]
  40. public SoundSpecifier? Sound;
  41. }
  42. /// <summary>
  43. /// Called where a <see cref="BeamControllerEntity"/> is first created. Stores the originator beam euid and the controller euid.
  44. /// Raised on the <see cref="BeamControllerEntity"/> and broadcast.
  45. /// </summary>
  46. public sealed class BeamControllerCreatedEvent : EntityEventArgs
  47. {
  48. public EntityUid OriginBeam;
  49. public EntityUid BeamControllerEntity;
  50. public BeamControllerCreatedEvent(EntityUid originBeam, EntityUid beamControllerEntity)
  51. {
  52. OriginBeam = originBeam;
  53. BeamControllerEntity = beamControllerEntity;
  54. }
  55. }
  56. /// <summary>
  57. /// Called after TryCreateBeam succeeds.
  58. /// </summary>
  59. public sealed class CreateBeamSuccessEvent : EntityEventArgs
  60. {
  61. public readonly EntityUid User;
  62. public readonly EntityUid Target;
  63. public CreateBeamSuccessEvent(EntityUid user, EntityUid target)
  64. {
  65. User = user;
  66. Target = target;
  67. }
  68. }
  69. /// <summary>
  70. /// Called once the beam is fully created
  71. /// </summary>
  72. public sealed class BeamFiredEvent : EntityEventArgs
  73. {
  74. public readonly EntityUid CreatedBeam;
  75. public BeamFiredEvent(EntityUid createdBeam)
  76. {
  77. CreatedBeam = createdBeam;
  78. }
  79. }
  80. /// <summary>
  81. /// Raised on the new entity created after the <see cref="SharedBeamSystem"/> creates one.
  82. /// Used to get sprite data over to the client.
  83. /// </summary>
  84. [Serializable, NetSerializable]
  85. public sealed class BeamVisualizerEvent : EntityEventArgs
  86. {
  87. public readonly NetEntity Beam;
  88. public readonly float DistanceLength;
  89. public readonly Angle UserAngle;
  90. public readonly string? BodyState;
  91. public readonly string Shader = "unshaded";
  92. public BeamVisualizerEvent(NetEntity beam, float distanceLength, Angle userAngle, string? bodyState = null, string shader = "unshaded")
  93. {
  94. Beam = beam;
  95. DistanceLength = distanceLength;
  96. UserAngle = userAngle;
  97. BodyState = bodyState;
  98. Shader = shader;
  99. }
  100. }