add an event to prevent gun shooting (#17104)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-06-08 02:15:39 +00:00
committed by GitHub
parent 3ddf2f1580
commit 25763e4ace
3 changed files with 47 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
namespace Content.Shared.Weapons.Ranged.Events;
/// <summary>
/// Raised on a gun when someone is attempting to shoot it.
/// Cancel this event to prevent it from shooting.
/// </summary>
[ByRefEvent]
public record struct ShotAttemptedEvent
{
/// <summary>
/// The user attempting to shoot the gun.
/// </summary>
public EntityUid User;
public bool Cancelled { get; private set; }
/// </summary>
/// Prevent the gun from shooting
/// </summary>
public void Cancel()
{
Cancelled = true;
}
/// </summary>
/// Allow the gun to shoot again, only use if you know what you are doing
/// </summary>
public void Uncancel()
{
Cancelled = false;
}
}