From 17132385d4d787afc1794d453853273db0ce6849 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Wed, 9 Mar 2022 19:40:07 +1300 Subject: [PATCH] Make combat check CanInteract (#7046) --- Content.Server/Interaction/InteractionSystem.cs | 5 +++++ Content.Shared/Administration/AdminFrozenSystem.cs | 3 +-- Content.Shared/Cuffs/SharedCuffableSystem.cs | 6 ------ Content.Shared/Ghost/SharedGhostSystem.cs | 3 +-- Content.Shared/Interaction/Events/AttackAttemptEvent.cs | 9 +++++++-- Content.Shared/MobState/EntitySystems/MobStateSystem.cs | 6 ------ Content.Shared/PAI/SharedPAISystem.cs | 6 ------ Content.Shared/Stunnable/SharedStunSystem.cs | 6 ------ 8 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 575d5f7545..a748a77ffd 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -298,6 +298,11 @@ namespace Content.Server.Interaction if (!ValidateInteractAndFace(user, coordinates)) return; + // Check general interaction blocking. + if (!_actionBlockerSystem.CanInteract(user, target)) + return; + + // Check combat-specific action blocking. if (!_actionBlockerSystem.CanAttack(user, target)) return; diff --git a/Content.Shared/Administration/AdminFrozenSystem.cs b/Content.Shared/Administration/AdminFrozenSystem.cs index 68aad166d3..3eb4629713 100644 --- a/Content.Shared/Administration/AdminFrozenSystem.cs +++ b/Content.Shared/Administration/AdminFrozenSystem.cs @@ -1,4 +1,4 @@ -using Content.Shared.Interaction.Events; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Movement; using Content.Shared.Throwing; @@ -14,7 +14,6 @@ public sealed class AdminFrozenSystem : EntitySystem SubscribeLocalEvent((_, _, args) => args.Cancel()); SubscribeLocalEvent((_, _, args) => args.Cancel()); SubscribeLocalEvent((_, _, args) => args.Cancel()); - SubscribeLocalEvent((_, _, args) => args.Cancel()); SubscribeLocalEvent((_, _, args) => args.Cancel()); SubscribeLocalEvent((_, _, args) => args.Cancel()); } diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index f7b88578dd..79a288d76f 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -20,7 +20,6 @@ namespace Content.Shared.Cuffs SubscribeLocalEvent(OnInteractAttempt); SubscribeLocalEvent(OnEquipAttempt); SubscribeLocalEvent(OnUnequipAttempt); - SubscribeLocalEvent(OnAttackAttempt); SubscribeLocalEvent(OnDropAttempt); SubscribeLocalEvent(OnPickupAttempt); } @@ -75,11 +74,6 @@ namespace Content.Shared.Cuffs CheckAct(uid, component, args); } - private void OnAttackAttempt(EntityUid uid, SharedCuffableComponent component, AttackAttemptEvent args) - { - CheckAct(uid, component, args); - } - private void OnDropAttempt(EntityUid uid, SharedCuffableComponent component, DropAttemptEvent args) { CheckAct(uid, component, args); diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index 0630f09df1..1764993bc3 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Content.Shared.DragDrop; using Content.Shared.Emoting; @@ -21,7 +21,6 @@ namespace Content.Shared.Ghost SubscribeLocalEvent(OnAttempt); SubscribeLocalEvent(OnAttempt); SubscribeLocalEvent(OnAttempt); - SubscribeLocalEvent(OnAttempt); SubscribeLocalEvent(OnAttempt); SubscribeLocalEvent(OnAttempt); } diff --git a/Content.Shared/Interaction/Events/AttackAttemptEvent.cs b/Content.Shared/Interaction/Events/AttackAttemptEvent.cs index c385aaf7e1..014d66d58a 100644 --- a/Content.Shared/Interaction/Events/AttackAttemptEvent.cs +++ b/Content.Shared/Interaction/Events/AttackAttemptEvent.cs @@ -1,7 +1,12 @@ -using Robust.Shared.GameObjects; - namespace Content.Shared.Interaction.Events { + /// + /// Raised Directed at a user to check whether they are allowed to attack a target. + /// + /// + /// Combat will also check the general interaction blockers, so this event should only be used for combat-specific + /// action blocking. + /// public sealed class AttackAttemptEvent : CancellableEntityEventArgs { public EntityUid Uid { get; } diff --git a/Content.Shared/MobState/EntitySystems/MobStateSystem.cs b/Content.Shared/MobState/EntitySystems/MobStateSystem.cs index 9ed89c7f1f..229c70aa29 100644 --- a/Content.Shared/MobState/EntitySystems/MobStateSystem.cs +++ b/Content.Shared/MobState/EntitySystems/MobStateSystem.cs @@ -29,7 +29,6 @@ namespace Content.Shared.MobState.EntitySystems SubscribeLocalEvent(OnEquipAttempt); SubscribeLocalEvent(OnEmoteAttempt); SubscribeLocalEvent(OnUnequipAttempt); - SubscribeLocalEvent(OnAttackAttempt); SubscribeLocalEvent(OnDropAttempt); SubscribeLocalEvent(OnPickupAttempt); SubscribeLocalEvent(OnStartPullAttempt); @@ -96,11 +95,6 @@ namespace Content.Shared.MobState.EntitySystems CheckAct(uid, component, args); } - private void OnAttackAttempt(EntityUid uid, MobStateComponent component, AttackAttemptEvent args) - { - CheckAct(uid, component, args); - } - private void OnDropAttempt(EntityUid uid, MobStateComponent component, DropAttemptEvent args) { CheckAct(uid, component, args); diff --git a/Content.Shared/PAI/SharedPAISystem.cs b/Content.Shared/PAI/SharedPAISystem.cs index 16880900f6..241296942a 100644 --- a/Content.Shared/PAI/SharedPAISystem.cs +++ b/Content.Shared/PAI/SharedPAISystem.cs @@ -24,7 +24,6 @@ namespace Content.Shared.PAI base.Initialize(); SubscribeLocalEvent(OnUseAttempt); SubscribeLocalEvent(OnInteractAttempt); - SubscribeLocalEvent(OnAttackAttempt); SubscribeLocalEvent(OnDropAttempt); SubscribeLocalEvent(OnPickupAttempt); SubscribeLocalEvent(OnMoveAttempt); @@ -54,11 +53,6 @@ namespace Content.Shared.PAI args.Cancel(); } - private void OnAttackAttempt(EntityUid uid, PAIComponent component, AttackAttemptEvent args) - { - args.Cancel(); - } - private void OnDropAttempt(EntityUid uid, PAIComponent component, DropAttemptEvent args) { args.Cancel(); diff --git a/Content.Shared/Stunnable/SharedStunSystem.cs b/Content.Shared/Stunnable/SharedStunSystem.cs index f110714e98..157ceeb7f5 100644 --- a/Content.Shared/Stunnable/SharedStunSystem.cs +++ b/Content.Shared/Stunnable/SharedStunSystem.cs @@ -54,7 +54,6 @@ namespace Content.Shared.Stunnable SubscribeLocalEvent(OnThrowAttempt); SubscribeLocalEvent(OnDropAttempt); SubscribeLocalEvent(OnPickupAttempt); - SubscribeLocalEvent(OnAttackAttempt); SubscribeLocalEvent(OnEquipAttempt); SubscribeLocalEvent(OnUnequipAttempt); } @@ -236,11 +235,6 @@ namespace Content.Shared.Stunnable args.Cancel(); } - private void OnAttackAttempt(EntityUid uid, StunnedComponent stunned, AttackAttemptEvent args) - { - args.Cancel(); - } - private void OnEquipAttempt(EntityUid uid, StunnedComponent stunned, IsEquippingAttemptEvent args) { // is this a self-equip, or are they being stripped?