diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index 6cc80feb38..12310ce0f5 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -146,7 +146,8 @@ namespace Content.Shared.ActionBlocker public bool CanAttack(EntityUid uid, EntityUid? target = null) { - if (_container.IsEntityInContainer(uid)) + _container.TryGetOuterContainer(uid, Transform(uid), out var outerContainer); + if (target != null && target != outerContainer?.Owner && _container.IsEntityInContainer(uid)) { var containerEv = new CanAttackFromContainerEvent(uid, target); RaiseLocalEvent(uid, containerEv); diff --git a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs index 00737f7443..4261567fa7 100644 --- a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs +++ b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs @@ -56,6 +56,7 @@ public abstract class SharedMechSystem : EntitySystem SubscribeLocalEvent(OnGetMeleeWeapon); SubscribeLocalEvent(OnCanAttackFromContainer); + SubscribeLocalEvent(OnAttackAttempt); } #region State Handling @@ -451,6 +452,12 @@ public abstract class SharedMechSystem : EntitySystem args.CanAttack = true; } + private void OnAttackAttempt(EntityUid uid, MechPilotComponent component, AttackAttemptEvent args) + { + if (args.Target == component.Mech) + args.Cancel(); + } + private void UpdateAppearance(EntityUid uid, SharedMechComponent ? component = null, AppearanceComponent? appearance = null) { if (!Resolve(uid, ref component, ref appearance, false))