From 1afa84e323464b23df53ba2f56490eaa1f14a744 Mon Sep 17 00:00:00 2001 From: Dakamakat <52600490+dakamakat@users.noreply.github.com> Date: Tue, 23 Jan 2024 07:15:00 +0300 Subject: [PATCH] Use can attach check on shot attempt (#24396) refactor(SharedGunSystem): use can attach check on shot attempt (cherry picked from commit 7b2e382929204d4fa39ff599c3365c1b237de2e9) --- Content.Shared/ActionBlocker/ActionBlockerSystem.cs | 12 +++++------- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index a3cd83042e..6dff8161ee 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -162,14 +162,12 @@ namespace Content.Shared.ActionBlocker if (ev.Cancelled) return false; - if (target != null) - { - var tev = new GettingAttackedAttemptEvent(); - RaiseLocalEvent(target.Value, ref tev); - return !tev.Cancelled; - } + if (target == null) + return true; - return true; + var tev = new GettingAttackedAttemptEvent(); + RaiseLocalEvent(target.Value, ref tev); + return !tev.Cancelled; } public bool CanChangeDirection(EntityUid uid) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 9a9b282287..a86e07c772 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -232,7 +232,7 @@ public abstract partial class SharedGunSystem : EntitySystem private void AttemptShoot(EntityUid user, EntityUid gunUid, GunComponent gun) { if (gun.FireRate <= 0f || - !_actionBlockerSystem.CanUseHeldEntity(user)) + !_actionBlockerSystem.CanAttack(user)) return; var toCoordinates = gun.ShootCoordinates;