diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index 352135be22..6cc80feb38 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -156,7 +156,17 @@ namespace Content.Shared.ActionBlocker var ev = new AttackAttemptEvent(uid, target); RaiseLocalEvent(uid, ev); - return !ev.Cancelled; + if (ev.Cancelled) + return false; + + if (target != null) + { + var tev = new GettingAttackedAttemptEvent(); + RaiseLocalEvent(target.Value, ref tev); + return !tev.Cancelled; + } + + return true; } public bool CanChangeDirection(EntityUid uid) diff --git a/Content.Shared/Interaction/Events/GettingAttackedAttemptEvent.cs b/Content.Shared/Interaction/Events/GettingAttackedAttemptEvent.cs new file mode 100644 index 0000000000..ed7379fd72 --- /dev/null +++ b/Content.Shared/Interaction/Events/GettingAttackedAttemptEvent.cs @@ -0,0 +1,7 @@ +namespace Content.Shared.Interaction.Events; + +/// +/// Raised directed on the target entity when being attacked. +/// +[ByRefEvent] +public record struct GettingAttackedAttemptEvent(bool Cancelled); diff --git a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs index 87951475a4..33f42efd99 100644 --- a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs +++ b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs @@ -31,6 +31,13 @@ namespace Content.Shared.SubFloor // Like 80% sure this doesn't need to handle re-anchoring. SubscribeLocalEvent(HandleAnchorChanged); SubscribeLocalEvent(OnInteractionAttempt); + SubscribeLocalEvent(OnAttackAttempt); + } + + private void OnAttackAttempt(EntityUid uid, SubFloorHideComponent component, ref GettingAttackedAttemptEvent args) + { + if (component.BlockInteractions && component.IsUnderCover) + args.Cancelled = true; } private void OnInteractionAttempt(EntityUid uid, SubFloorHideComponent component, GettingInteractedWithAttemptEvent args) diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 9340407f8b..4db68335d9 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -295,8 +295,21 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem if (!CombatMode.IsInCombatMode(user)) return; - if (!Blocker.CanAttack(user)) - return; + switch (attack) + { + case LightAttackEvent light: + if (!Blocker.CanAttack(user, light.Target)) + return; + break; + case DisarmAttackEvent disarm: + if (!Blocker.CanAttack(user, disarm.Target)) + return; + break; + default: + if (!Blocker.CanAttack(user)) + return; + break; + } // Windup time checked elsewhere.