From 48f8dd228466b227b0dbd84127c559ddebebdb74 Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Tue, 9 Nov 2021 14:54:00 +0100 Subject: [PATCH] ActionBlocker CanInteract uses EntityUid exclusively ActionBlockerSystem fully uses EntityUid now! --- Content.Client/DragDrop/DragDropSystem.cs | 2 +- .../AME/Components/AMEControllerComponent.cs | 2 +- Content.Server/Actions/Spells/GiveItemSpell.cs | 2 +- Content.Server/Alert/Click/StopBeingPulled.cs | 2 +- .../Components/BlockGameArcadeComponent.cs | 4 ++-- .../Components/SpaceVillainArcadeComponent.cs | 2 +- .../BaseComputerUserInterfaceComponent.cs | 2 +- .../Atmos/EntitySystems/FlammableSystem.cs | 2 +- .../Binary/EntitySystems/GasValveSystem.cs | 2 +- .../Surgery/Components/SurgeryToolSystem.cs | 2 +- .../Botany/Components/LogComponent.cs | 2 +- .../Botany/Components/PlantHolderComponent.cs | 4 ++-- .../Buckle/Components/BuckleComponent.cs | 4 ++-- .../Chemistry/Components/ChemMasterComponent.cs | 2 +- .../Components/ReagentDispenserComponent.cs | 2 +- .../Climbing/Components/ClimbableComponent.cs | 4 ++-- .../Construction/ConstructionSystem.Initial.cs | 4 ++-- Content.Server/Cuffs/CuffableSystem.cs | 2 +- .../Tube/Components/DisposalRouterComponent.cs | 2 +- .../Tube/Components/DisposalTaggerComponent.cs | 2 +- .../Unit/Components/DisposalUnitComponent.cs | 2 +- .../Unit/EntitySystems/DisposalUnitSystem.cs | 2 +- .../Extinguisher/FireExtinguisherComponent.cs | 2 +- .../Fluids/Components/SprayComponent.cs | 2 +- Content.Server/HandLabeler/HandLabelerSystem.cs | 6 +++--- .../Instruments/InstrumentComponent.cs | 6 +++--- Content.Server/Interaction/InteractionSystem.cs | 6 +++--- .../Light/Components/HandheldLightComponent.cs | 2 +- .../Light/EntitySystems/LightReplacerSystem.cs | 2 +- .../Medical/Components/HealingComponent.cs | 2 +- Content.Server/Medical/MedicalScannerSystem.cs | 2 +- .../ParticleAcceleratorControlBoxComponent.cs | 4 ++-- .../Power/Components/CablePlacerComponent.cs | 2 +- Content.Server/Shuttles/ShuttleConsoleSystem.cs | 4 ++-- Content.Server/Strip/StrippableComponent.cs | 8 ++++---- Content.Server/Stunnable/StunbatonSystem.cs | 2 +- Content.Server/Tabletop/TabletopSystem.cs | 2 +- .../Ranged/ServerRangedWeaponComponent.cs | 2 +- .../ActionBlocker/ActionBlockerSystem.cs | 17 ++++------------- .../Events/InteractionAttemptEvent.cs | 6 +++--- .../Interaction/SharedInteractionSystem.cs | 4 ++-- .../Storage/SharedStorageComponent.cs | 2 +- .../Components/SharedStrippableComponent.cs | 2 +- Content.Shared/Verbs/VerbEvents.cs | 2 +- 44 files changed, 66 insertions(+), 75 deletions(-) diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index 16a1c09540..f65a4d3c44 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -415,7 +415,7 @@ namespace Content.Client.DragDrop /// null if the target doesn't support IDragDropOn private bool? ValidDragDrop(DragDropEvent eventArgs) { - if (!_actionBlockerSystem.CanInteract(eventArgs.User)) + if (!_actionBlockerSystem.CanInteract(eventArgs.User.Uid)) { return false; } diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index 2425b4802e..a4656b89f4 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -174,7 +174,7 @@ namespace Content.Server.AME.Components var actionBlocker = EntitySystem.Get(); //Check if player can interact in their current state - if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid)) + if (!actionBlocker.CanInteract(playerEntity.Uid) || !actionBlocker.CanUse(playerEntity.Uid)) return false; //Check if device is powered if (needsPower && !Powered) diff --git a/Content.Server/Actions/Spells/GiveItemSpell.cs b/Content.Server/Actions/Spells/GiveItemSpell.cs index c8a3a1b593..e87656cbbe 100644 --- a/Content.Server/Actions/Spells/GiveItemSpell.cs +++ b/Content.Server/Actions/Spells/GiveItemSpell.cs @@ -42,7 +42,7 @@ namespace Content.Server.Actions.Spells return; } - if (!EntitySystem.Get().CanInteract(caster)) return; + if (!EntitySystem.Get().CanInteract(caster.Uid)) return; // TODO: Nix when we get EntityPrototype serializers if (!IoCManager.Resolve().HasIndex(ItemProto)) diff --git a/Content.Server/Alert/Click/StopBeingPulled.cs b/Content.Server/Alert/Click/StopBeingPulled.cs index a1dcdedb65..f69fe44661 100644 --- a/Content.Server/Alert/Click/StopBeingPulled.cs +++ b/Content.Server/Alert/Click/StopBeingPulled.cs @@ -17,7 +17,7 @@ namespace Content.Server.Alert.Click { public void AlertClicked(ClickAlertEventArgs args) { - if (!EntitySystem.Get().CanInteract(args.Player)) + if (!EntitySystem.Get().CanInteract(args.Player.Uid)) return; if (args.Player.TryGetComponent(out var playerPullable)) diff --git a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs index d69742447b..27ac673c3d 100644 --- a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs +++ b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs @@ -52,7 +52,7 @@ namespace Content.Server.Arcade.Components if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) return; - if(!EntitySystem.Get().CanInteract(eventArgs.User)) + if(!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) return; UserInterface?.Toggle(actor.PlayerSession); @@ -131,7 +131,7 @@ namespace Content.Server.Arcade.Components if (obj.Session != _player) break; // TODO: Should this check if the Owner can interact...? - if (!EntitySystem.Get().CanInteract(Owner)) + if (!EntitySystem.Get().CanInteract(OwnerUid)) { DeactivePlayer(obj.Session); break; diff --git a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs index 7b17a5941e..b3b82cc276 100644 --- a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs @@ -77,7 +77,7 @@ namespace Content.Server.Arcade.Components if (!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) return; - if (!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) return; _game ??= new SpaceVillainGame(this); diff --git a/Content.Server/Atmos/Components/BaseComputerUserInterfaceComponent.cs b/Content.Server/Atmos/Components/BaseComputerUserInterfaceComponent.cs index ad039ca917..5d03b258b5 100644 --- a/Content.Server/Atmos/Components/BaseComputerUserInterfaceComponent.cs +++ b/Content.Server/Atmos/Components/BaseComputerUserInterfaceComponent.cs @@ -64,7 +64,7 @@ namespace Content.Server.GameObjects.Components return; // Not powered, so this computer should probably do nothing. } // Can we interact? - if (!EntitySystem.Get().CanInteract(sessionEntity)) + if (!EntitySystem.Get().CanInteract(sessionEntity.Uid)) { sessionEntity.PopupMessageCursor(Loc.GetString("base-computer-ui-component-cannot-interact")); return; diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index 1ab30f95ce..28f756e860 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -160,7 +160,7 @@ namespace Content.Server.Atmos.EntitySystems if (!Resolve(uid, ref flammable, ref alerts)) return; - if (!flammable.OnFire || !_actionBlockerSystem.CanInteract(flammable.Owner) || flammable.Resisting) + if (!flammable.OnFire || !_actionBlockerSystem.CanInteract(flammable.Owner.Uid) || flammable.Resisting) return; flammable.Resisting = true; diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs index ea64ed6940..d4d4465d39 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs @@ -48,7 +48,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args) { - if (args.User.InRangeUnobstructed(args.Target) && Get().CanInteract(args.User)) + if (args.User.InRangeUnobstructed(args.Target) && Get().CanInteract(args.User.Uid)) { Toggle(uid, component); SoundSystem.Play(Filter.Pvs(component.Owner), component._valveSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.25f)); diff --git a/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs b/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs index 5e95ace8be..63e6ce0242 100644 --- a/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs +++ b/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs @@ -57,7 +57,7 @@ namespace Content.Server.Body.Surgery.Components continue; } - if (!_actionBlockerSystem.CanInteract(tool.PerformerCache) || + if (!_actionBlockerSystem.CanInteract(tool.PerformerCache.Uid) || !tool.PerformerCache.InRangeUnobstructed(tool.BodyCache)) { tool.CloseAllSurgeryUIs(); diff --git a/Content.Server/Botany/Components/LogComponent.cs b/Content.Server/Botany/Components/LogComponent.cs index 7f079ee970..b12205d205 100644 --- a/Content.Server/Botany/Components/LogComponent.cs +++ b/Content.Server/Botany/Components/LogComponent.cs @@ -15,7 +15,7 @@ namespace Content.Server.Botany.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) return false; if (eventArgs.Using.HasTag("BotanySharp")) diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index 8c6d2660b0..03c7d760da 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -421,7 +421,7 @@ namespace Content.Server.Botany.Components public bool DoHarvest(IEntity user) { - if (Seed == null || user.Deleted || !EntitySystem.Get().CanInteract(user)) + if (Seed == null || user.Deleted || !EntitySystem.Get().CanInteract(user.Uid)) return false; if (Harvest && !Dead) @@ -651,7 +651,7 @@ namespace Content.Server.Botany.Components var user = eventArgs.User; var usingItem = eventArgs.Using; - if (usingItem.Deleted || !EntitySystem.Get().CanInteract(user)) + if (usingItem.Deleted || !EntitySystem.Get().CanInteract(user.Uid)) return false; if (usingItem.TryGetComponent(out SeedComponent? seeds)) diff --git a/Content.Server/Buckle/Components/BuckleComponent.cs b/Content.Server/Buckle/Components/BuckleComponent.cs index 50791f55db..679f111d4c 100644 --- a/Content.Server/Buckle/Components/BuckleComponent.cs +++ b/Content.Server/Buckle/Components/BuckleComponent.cs @@ -148,7 +148,7 @@ namespace Content.Server.Buckle.Components return false; } - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) { user.PopupMessage(Loc.GetString("buckle-component-cannot-do-that-message")); return false; @@ -303,7 +303,7 @@ namespace Content.Server.Buckle.Components return false; } - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) { user.PopupMessage(Loc.GetString("buckle-component-cannot-do-that-message")); return false; diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index eaaead26fc..9148b8c316 100644 --- a/Content.Server/Chemistry/Components/ChemMasterComponent.cs +++ b/Content.Server/Chemistry/Components/ChemMasterComponent.cs @@ -165,7 +165,7 @@ namespace Content.Server.Chemistry.Components var actionBlocker = EntitySystem.Get(); //Check if player can interact in their current state - if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid)) + if (!actionBlocker.CanInteract(playerEntity.Uid) || !actionBlocker.CanUse(playerEntity.Uid)) return false; //Check if device is powered if (needsPower && !Powered) diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index f89c93adfb..2464f6071b 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -218,7 +218,7 @@ namespace Content.Server.Chemistry.Components var actionBlocker = EntitySystem.Get(); //Check if player can interact in their current state - if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid)) + if (!actionBlocker.CanInteract(playerEntity.Uid) || !actionBlocker.CanUse(playerEntity.Uid)) return false; //Check if device is powered if (needsPower && !Powered) diff --git a/Content.Server/Climbing/Components/ClimbableComponent.cs b/Content.Server/Climbing/Components/ClimbableComponent.cs index 2891b38c76..7a9e209243 100644 --- a/Content.Server/Climbing/Components/ClimbableComponent.cs +++ b/Content.Server/Climbing/Components/ClimbableComponent.cs @@ -67,7 +67,7 @@ namespace Content.Server.Climbing.Components /// private bool CanVault(IEntity user, IEntity target, out string reason) { - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) { reason = Loc.GetString("comp-climbable-cant-interact"); return false; @@ -107,7 +107,7 @@ namespace Content.Server.Climbing.Components /// private bool CanVault(IEntity user, IEntity dragged, IEntity target, out string reason) { - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) { reason = Loc.GetString("comp-climbable-cant-interact"); return false; diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index df2692eccd..1b1bf6d632 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -297,7 +297,7 @@ namespace Content.Server.Construction var user = args.SenderSession.AttachedEntity; - if (user == null || !Get().CanInteract(user)) return; + if (user == null || !Get().CanInteract(user.Uid)) return; if (!user.TryGetComponent(out HandsComponent? hands)) return; @@ -398,7 +398,7 @@ namespace Content.Server.Construction } if (user == null - || !Get().CanInteract(user) + || !Get().CanInteract(user.Uid) || !user.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand == null || !user.InRangeUnobstructed(ev.Location, ignoreInsideBlocker:constructionPrototype.CanBuildInImpassable)) { diff --git a/Content.Server/Cuffs/CuffableSystem.cs b/Content.Server/Cuffs/CuffableSystem.cs index ce3df12fcb..aaced49f5b 100644 --- a/Content.Server/Cuffs/CuffableSystem.cs +++ b/Content.Server/Cuffs/CuffableSystem.cs @@ -83,7 +83,7 @@ namespace Content.Server.Cuffs else { // Check if the user can interact. - if (!_actionBlockerSystem.CanInteract(userEntity)) + if (!_actionBlockerSystem.CanInteract(userEntity.Uid)) { args.Cancel(); } diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index 4a577fcd80..524d386406 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -112,7 +112,7 @@ namespace Content.Server.Disposal.Tube.Components var actionBlocker = EntitySystem.Get(); var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntityUid!.Value))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntityUid!.Value) || !actionBlocker.CanUse(session.AttachedEntityUid!.Value))) return false; return true; diff --git a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs index 3e9d77b765..9c88780bfa 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs @@ -94,7 +94,7 @@ namespace Content.Server.Disposal.Tube.Components var actionBlocker = EntitySystem.Get(); var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntityUid!.Value))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntityUid!.Value) || !actionBlocker.CanUse(session.AttachedEntityUid!.Value))) return false; return true; diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index c855d21643..72f0be5e07 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -96,7 +96,7 @@ namespace Content.Server.Disposal.Unit.Components var actionBlocker = EntitySystem.Get(); - if (!actionBlocker.CanInteract(player) || + if (!actionBlocker.CanInteract(player.Uid) || !actionBlocker.CanUse(player.Uid)) { return false; diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index fb08bfa801..97580c1c0b 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -379,7 +379,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems private bool IsValidInteraction(ITargetedInteractEventArgs eventArgs) { - if (!Get().CanInteract(eventArgs.User)) + if (!Get().CanInteract(eventArgs.User.Uid)) { eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("ui-disposal-unit-is-valid-interaction-cannot=interact")); return false; diff --git a/Content.Server/Extinguisher/FireExtinguisherComponent.cs b/Content.Server/Extinguisher/FireExtinguisherComponent.cs index 982e0fa889..ed5f6282de 100644 --- a/Content.Server/Extinguisher/FireExtinguisherComponent.cs +++ b/Content.Server/Extinguisher/FireExtinguisherComponent.cs @@ -99,7 +99,7 @@ namespace Content.Server.Extinguisher private void SetSafety(IEntity user, bool state) { - if (!EntitySystem.Get().CanInteract(user) || !_hasSafety) + if (!EntitySystem.Get().CanInteract(user.Uid) || !_hasSafety) return; _safety = state; diff --git a/Content.Server/Fluids/Components/SprayComponent.cs b/Content.Server/Fluids/Components/SprayComponent.cs index 7f3e7f651b..da81ff0246 100644 --- a/Content.Server/Fluids/Components/SprayComponent.cs +++ b/Content.Server/Fluids/Components/SprayComponent.cs @@ -86,7 +86,7 @@ namespace Content.Server.Fluids.Components async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) { - if (!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) return false; if (CurrentVolume <= 0) diff --git a/Content.Server/HandLabeler/HandLabelerSystem.cs b/Content.Server/HandLabeler/HandLabelerSystem.cs index 92ab527a46..aad30f03b2 100644 --- a/Content.Server/HandLabeler/HandLabelerSystem.cs +++ b/Content.Server/HandLabeler/HandLabelerSystem.cs @@ -80,9 +80,9 @@ namespace Content.Server.HandLabeler private bool CheckInteract(ICommonSession session) { - if (session.AttachedEntity is not { } entity - || !Get().CanInteract(entity) - || !Get().CanUse(entity.Uid)) + if (session.AttachedEntityUid is not { } uid + || !Get().CanInteract(uid) + || !Get().CanUse(uid)) return false; return true; diff --git a/Content.Server/Instruments/InstrumentComponent.cs b/Content.Server/Instruments/InstrumentComponent.cs index bfc9c7ab66..77bcf6eea2 100644 --- a/Content.Server/Instruments/InstrumentComponent.cs +++ b/Content.Server/Instruments/InstrumentComponent.cs @@ -319,7 +319,7 @@ namespace Content.Server.Instruments if ((!Handheld && InstrumentPlayer != null) || (Handheld && actor.PlayerSession != InstrumentPlayer) - || !EntitySystem.Get().CanInteract(user)) return; + || !EntitySystem.Get().CanInteract(user.Uid)) return; InstrumentPlayer = actor.PlayerSession; OpenUserInterface(InstrumentPlayer); @@ -351,8 +351,8 @@ namespace Content.Server.Instruments var maxMidiBatchDropped = _instrumentSystem.MaxMidiBatchesDropped; if (_instrumentPlayer != null - && (_instrumentPlayer.AttachedEntity == null - || !EntitySystem.Get().CanInteract(_instrumentPlayer.AttachedEntity))) + && (_instrumentPlayer.AttachedEntityUid == null + || !EntitySystem.Get().CanInteract(_instrumentPlayer.AttachedEntityUid.Value))) { InstrumentPlayer = null; Clean(); diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 54425b880e..c8fa063026 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -133,7 +133,7 @@ namespace Content.Server.Interaction return; } - if (!_actionBlockerSystem.CanInteract(userEntity)) + if (!_actionBlockerSystem.CanInteract(userEntity.Uid)) return; if (!EntityManager.TryGetEntity(msg.Dropped, out var dropped)) @@ -293,7 +293,7 @@ namespace Content.Server.Interaction if (!ValidateInteractAndFace(user, coordinates)) return; - if (!_actionBlockerSystem.CanInteract(user)) + if (!_actionBlockerSystem.CanInteract(user.Uid)) return; // Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null @@ -367,7 +367,7 @@ namespace Content.Server.Interaction /// public void InteractHand(IEntity user, IEntity target) { - if (!_actionBlockerSystem.CanInteract(user)) + if (!_actionBlockerSystem.CanInteract(user.Uid)) return; // all interactions should only happen when in range / unobstructed, so no range check is needed diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index 8ed937ad57..0eabc03b51 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -76,7 +76,7 @@ namespace Content.Server.Light.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!EntitySystem.Get().CanInteract(eventArgs.User)) return false; + if (!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) return false; if (!_cellSlot.InsertCell(eventArgs.Using)) return false; Dirty(); return true; diff --git a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs index b9b5a3f198..5c0424a579 100644 --- a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs +++ b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs @@ -67,7 +67,7 @@ namespace Content.Server.Light.EntitySystems return; // standard interaction checks - if (!_blocker.CanInteract(eventArgs.User)) return; + if (!_blocker.CanInteract(eventArgs.User.Uid)) return; if (eventArgs.Used != null) { diff --git a/Content.Server/Medical/Components/HealingComponent.cs b/Content.Server/Medical/Components/HealingComponent.cs index f03333c57e..9b2f2fe6b0 100644 --- a/Content.Server/Medical/Components/HealingComponent.cs +++ b/Content.Server/Medical/Components/HealingComponent.cs @@ -32,7 +32,7 @@ namespace Content.Server.Medical.Components return true; } - if (!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) { return true; } diff --git a/Content.Server/Medical/MedicalScannerSystem.cs b/Content.Server/Medical/MedicalScannerSystem.cs index f749464338..06cd9eaa12 100644 --- a/Content.Server/Medical/MedicalScannerSystem.cs +++ b/Content.Server/Medical/MedicalScannerSystem.cs @@ -75,7 +75,7 @@ namespace Content.Server.Medical private void OnRelayMovement(EntityUid uid, MedicalScannerComponent component, RelayMovementEntityEvent args) { - if (_blocker.CanInteract(args.Entity)) + if (_blocker.CanInteract(args.Entity.Uid)) { if (_gameTiming.CurTime < component.LastInternalOpenAttempt + MedicalScannerComponent.InternalOpenAttemptDelay) diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index f3e59f2cd3..d890de6857 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -153,8 +153,8 @@ namespace Content.Server.ParticleAccelerator.Components } - if (obj.Session.AttachedEntity == null || - !EntitySystem.Get().CanInteract(obj.Session.AttachedEntity)) + if (obj.Session.AttachedEntityUid == null || + !EntitySystem.Get().CanInteract(obj.Session.AttachedEntityUid.Value)) { return; } diff --git a/Content.Server/Power/Components/CablePlacerComponent.cs b/Content.Server/Power/Components/CablePlacerComponent.cs index d738449aaf..62bc4ec85a 100644 --- a/Content.Server/Power/Components/CablePlacerComponent.cs +++ b/Content.Server/Power/Components/CablePlacerComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.Power.Components /// async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) { - if (!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) return false; if (_cablePrototypeID == null) diff --git a/Content.Server/Shuttles/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/ShuttleConsoleSystem.cs index 63c04ac6e5..c899549fce 100644 --- a/Content.Server/Shuttles/ShuttleConsoleSystem.cs +++ b/Content.Server/Shuttles/ShuttleConsoleSystem.cs @@ -38,7 +38,7 @@ namespace Content.Server.Shuttles { if (comp.Console == null) continue; - if (!_blocker.CanInteract(comp.Owner)) + if (!_blocker.CanInteract(comp.OwnerUid)) { toRemove.Add(comp); } @@ -122,7 +122,7 @@ namespace Content.Server.Shuttles public void AddPilot(IEntity entity, ShuttleConsoleComponent component) { - if (!_blocker.CanInteract(entity) || + if (!_blocker.CanInteract(entity.Uid) || !entity.TryGetComponent(out PilotComponent? pilotComponent) || component.SubscribedPilots.Contains(pilotComponent)) { diff --git a/Content.Server/Strip/StrippableComponent.cs b/Content.Server/Strip/StrippableComponent.cs index 3a4f6deab0..00f36eda42 100644 --- a/Content.Server/Strip/StrippableComponent.cs +++ b/Content.Server/Strip/StrippableComponent.cs @@ -160,7 +160,7 @@ namespace Content.Server.Strip bool Check() { - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) return false; if (item == null) @@ -225,7 +225,7 @@ namespace Content.Server.Strip bool Check() { - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) return false; if (item == null) @@ -290,7 +290,7 @@ namespace Content.Server.Strip bool Check() { - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) return false; if (!inventory.HasSlot(slot)) @@ -346,7 +346,7 @@ namespace Content.Server.Strip bool Check() { - if (!EntitySystem.Get().CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user.Uid)) return false; if (!hands.HasHand(hand)) diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index d809316622..ba4a2cb30e 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -104,7 +104,7 @@ namespace Content.Server.Stunnable private void OnInteractUsing(EntityUid uid, StunbatonComponent comp, InteractUsingEvent args) { - if (!Get().CanInteract(args.User)) + if (!Get().CanInteract(args.User.Uid)) return; if (EntityManager.TryGetComponent(uid, out var cellslot)) diff --git a/Content.Server/Tabletop/TabletopSystem.cs b/Content.Server/Tabletop/TabletopSystem.cs index c683e3f1bd..f278639445 100644 --- a/Content.Server/Tabletop/TabletopSystem.cs +++ b/Content.Server/Tabletop/TabletopSystem.cs @@ -59,7 +59,7 @@ namespace Content.Server.Tabletop return; // Check that the entity can interact with the game board. - if(_actionBlockerSystem.CanInteract(args.User)) + if(_actionBlockerSystem.CanInteract(args.User.Uid)) OpenSessionFor(actor.PlayerSession, uid); } diff --git a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs index f3d7da9151..bc46a3edfc 100644 --- a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -89,7 +89,7 @@ namespace Content.Server.Weapon.Ranged private bool UserCanFire(IEntity user) { - return (UserCanFireHandler == null || UserCanFireHandler(user)) && EntitySystem.Get().CanInteract(user); + return (UserCanFireHandler == null || UserCanFireHandler(user)) && EntitySystem.Get().CanInteract(user.Uid); } /// diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index b3a3dbf36e..31ad5bc183 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -18,9 +18,6 @@ namespace Content.Shared.ActionBlocker [UsedImplicitly] public class ActionBlockerSystem : EntitySystem { - // TODO: Make the EntityUid the main overload for all these methods. - // TODO: Move each of these to their relevant EntitySystems? - public bool CanMove(EntityUid uid) { var ev = new MovementAttemptEvent(uid); @@ -29,18 +26,12 @@ namespace Content.Shared.ActionBlocker return !ev.Cancelled; } - public bool CanInteract(IEntity entity) - { - var ev = new InteractionAttemptEvent(entity); - - RaiseLocalEvent(entity.Uid, ev); - - return !ev.Cancelled; - } - public bool CanInteract(EntityUid uid) { - return CanInteract(EntityManager.GetEntity(uid)); + var ev = new InteractionAttemptEvent(uid); + RaiseLocalEvent(uid, ev); + + return !ev.Cancelled; } public bool CanUse(EntityUid uid) diff --git a/Content.Shared/Interaction/Events/InteractionAttemptEvent.cs b/Content.Shared/Interaction/Events/InteractionAttemptEvent.cs index e5f41fb1a1..a8186e9878 100644 --- a/Content.Shared/Interaction/Events/InteractionAttemptEvent.cs +++ b/Content.Shared/Interaction/Events/InteractionAttemptEvent.cs @@ -4,11 +4,11 @@ namespace Content.Shared.Interaction.Events { public class InteractionAttemptEvent : CancellableEntityEventArgs { - public InteractionAttemptEvent(IEntity entity) + public InteractionAttemptEvent(EntityUid uid) { - Entity = entity; + Uid = uid; } - public IEntity Entity { get; } + public EntityUid Uid { get; } } } diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 179e0535cc..8c047e53f9 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -373,7 +373,7 @@ namespace Content.Shared.Interaction /// public async Task InteractUsing(IEntity user, IEntity used, IEntity target, EntityCoordinates clickLocation) { - if (!_actionBlockerSystem.CanInteract(user)) + if (!_actionBlockerSystem.CanInteract(user.Uid)) return; if (InteractDoBefore(user, used, target, clickLocation, true)) @@ -444,7 +444,7 @@ namespace Content.Shared.Interaction delayComponent.BeginDelay(); } - if (!_actionBlockerSystem.CanInteract(user) || !_actionBlockerSystem.CanUse(user.Uid)) + if (!_actionBlockerSystem.CanInteract(user.Uid) || !_actionBlockerSystem.CanUse(user.Uid)) return; // all activates should only fire when in range / unobstructed diff --git a/Content.Shared/Storage/SharedStorageComponent.cs b/Content.Shared/Storage/SharedStorageComponent.cs index 0e86706903..068149d962 100644 --- a/Content.Shared/Storage/SharedStorageComponent.cs +++ b/Content.Shared/Storage/SharedStorageComponent.cs @@ -34,7 +34,7 @@ namespace Content.Shared.Storage bool IDraggable.Drop(DragDropEvent eventArgs) { - if (!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) { return false; } diff --git a/Content.Shared/Strip/Components/SharedStrippableComponent.cs b/Content.Shared/Strip/Components/SharedStrippableComponent.cs index ec781591fb..ab369ede20 100644 --- a/Content.Shared/Strip/Components/SharedStrippableComponent.cs +++ b/Content.Shared/Strip/Components/SharedStrippableComponent.cs @@ -17,7 +17,7 @@ namespace Content.Shared.Strip.Components { return by != Owner && by.HasComponent() - && EntitySystem.Get().CanInteract(by); + && EntitySystem.Get().CanInteract(by.Uid); } bool IDraggable.CanDrop(CanDropEvent args) diff --git a/Content.Shared/Verbs/VerbEvents.cs b/Content.Shared/Verbs/VerbEvents.cs index e84fc5f36c..72375e124f 100644 --- a/Content.Shared/Verbs/VerbEvents.cs +++ b/Content.Shared/Verbs/VerbEvents.cs @@ -182,7 +182,7 @@ namespace Content.Shared.Verbs // A large number of verbs need to check action blockers. Instead of repeatedly having each system individually // call ActionBlocker checks, just cache it for the verb request. var actionBlockerSystem = EntitySystem.Get(); - CanInteract = force || actionBlockerSystem.CanInteract(user); + CanInteract = force || actionBlockerSystem.CanInteract(user.Uid); if (!user.TryGetComponent(out Hands) || !actionBlockerSystem.CanUse(user.Uid))