Fallback to guncomp on the entity (#10659)

This commit is contained in:
metalgearsloth
2022-08-18 12:32:34 +10:00
committed by GitHub
parent 5eac94ddf9
commit 64a25dc8f6

View File

@@ -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)