ShotAttemptedEvent.cs 881 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Content.Shared.Weapons.Ranged.Components;
  2. namespace Content.Shared.Weapons.Ranged.Events;
  3. /// <summary>
  4. /// Raised on a gun when someone is attempting to shoot it.
  5. /// Cancel this event to prevent it from shooting.
  6. /// </summary>
  7. [ByRefEvent]
  8. public record struct ShotAttemptedEvent
  9. {
  10. /// <summary>
  11. /// The user attempting to shoot the gun.
  12. /// </summary>
  13. public EntityUid User;
  14. /// <summary>
  15. /// The gun being shot.
  16. /// </summary>
  17. public Entity<GunComponent> Used;
  18. public bool Cancelled { get; private set; }
  19. /// </summary>
  20. /// Prevent the gun from shooting
  21. /// </summary>
  22. public void Cancel()
  23. {
  24. Cancelled = true;
  25. }
  26. /// </summary>
  27. /// Allow the gun to shoot again, only use if you know what you are doing
  28. /// </summary>
  29. public void Uncancel()
  30. {
  31. Cancelled = false;
  32. }
  33. }