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

@@ -221,8 +221,13 @@ public abstract partial class SharedGunSystem : EntitySystem
var curTime = Timing.CurTime;
// Maybe Raise an event for this? CanAttack doesn't seem appropriate.
if (TryComp<MeleeWeaponComponent>(gunUid, out var melee) && melee.NextAttack > curTime)
// check if anything wants to prevent shooting
var prevention = new ShotAttemptedEvent
{
User = user
};
RaiseLocalEvent(gunUid, ref prevention);
if (prevention.Cancelled)
return;
// Need to do this to play the clicking sound for empty automatic weapons