From 64a25dc8f642a511e15ea393022320159e871898 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 18 Aug 2022 12:32:34 +1000 Subject: [PATCH] Fallback to guncomp on the entity (#10659) --- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 899d6cf249..583376562e 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -154,19 +154,18 @@ public abstract partial class SharedGunSystem : EntitySystem public GunComponent? GetGun(EntityUid entity) { - if (!EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands) || - hands.ActiveHandEntity is not { } held) - { - return null; - } - - if (!EntityManager.TryGetComponent(held, out GunComponent? gun)) - return null; - if (!_combatMode.IsInCombatMode(entity)) return null; - return gun; + if (EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands) && + hands.ActiveHandEntity is { } held && + TryComp(held, out GunComponent? gun)) + { + return gun; + } + + // Last resort is check if the entity itself is a gun. + return !TryComp(entity, out gun) ? null : gun; } private void StopShooting(GunComponent gun)