diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index 4f89c2b38e..2425b4802e 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)) + if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid)) return false; //Check if device is powered if (needsPower && !Powered) diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index 1562433aae..0f970eece3 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -218,7 +218,7 @@ namespace Content.Server.Atmos.Components { var user = GetInternalsComponent()?.Owner; - if (user == null || !EntitySystem.Get().CanUse(user)) + if (user == null || !EntitySystem.Get().CanUse(user.Uid)) return; if (IsConnected) diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index 88613e74b0..eaaead26fc 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)) + if (!actionBlocker.CanInteract(playerEntity) || !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 25cbc5017c..f89c93adfb 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)) + if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid)) return false; //Check if device is powered if (needsPower && !Powered) diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index cb22ef244a..252e803090 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -147,7 +147,7 @@ namespace Content.Server.Cuffs.Components { if (_cuffing) return true; - if (eventArgs.Target == null || !EntitySystem.Get().CanUse(eventArgs.User) || !eventArgs.Target.TryGetComponent(out var cuffed)) + if (eventArgs.Target == null || !EntitySystem.Get().CanUse(eventArgs.User.Uid) || !eventArgs.Target.TryGetComponent(out var cuffed)) { return false; } diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index e65864cc40..4a577fcd80 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.AttachedEntity))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !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 101bc1b52a..3e9d77b765 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.AttachedEntity))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !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 9ed5858546..c855d21643 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -97,7 +97,7 @@ namespace Content.Server.Disposal.Unit.Components var actionBlocker = EntitySystem.Get(); if (!actionBlocker.CanInteract(player) || - !actionBlocker.CanUse(player)) + !actionBlocker.CanUse(player.Uid)) { return false; } diff --git a/Content.Server/HandLabeler/HandLabelerSystem.cs b/Content.Server/HandLabeler/HandLabelerSystem.cs index 768e736777..92ab527a46 100644 --- a/Content.Server/HandLabeler/HandLabelerSystem.cs +++ b/Content.Server/HandLabeler/HandLabelerSystem.cs @@ -82,7 +82,7 @@ namespace Content.Server.HandLabeler { if (session.AttachedEntity is not { } entity || !Get().CanInteract(entity) - || !Get().CanUse(entity)) + || !Get().CanUse(entity.Uid)) return false; return true; diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index e728a30a2e..8ed937ad57 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -105,7 +105,7 @@ namespace Content.Server.Light.Components /// True if the light's status was toggled, false otherwise. public bool ToggleStatus(IEntity user) { - if (!EntitySystem.Get().CanUse(user)) return false; + if (!EntitySystem.Get().CanUse(user.Uid)) return false; return Activated ? TurnOff() : TurnOn(user); } diff --git a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs index 669801d4bf..b9b5a3f198 100644 --- a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs +++ b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs @@ -44,7 +44,7 @@ namespace Content.Server.Light.EntitySystems return; // standard interaction checks - if (!_blocker.CanUse(eventArgs.User)) return; + if (!_blocker.CanUse(eventArgs.User.Uid)) return; if (!eventArgs.CanReach) return; // behaviour will depends on target type diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index d7c105f879..d809316622 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -73,7 +73,7 @@ namespace Content.Server.Stunnable private void OnUseInHand(EntityUid uid, StunbatonComponent comp, UseInHandEvent args) { - if (!Get().CanUse(args.User)) + if (!Get().CanUse(args.User.Uid)) return; if (comp.Activated) diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index be6ceafbca..c649746a53 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -43,18 +43,12 @@ namespace Content.Shared.ActionBlocker return CanInteract(EntityManager.GetEntity(uid)); } - public bool CanUse(IEntity entity) - { - var ev = new UseAttemptEvent(entity); - - RaiseLocalEvent(entity.Uid, ev); - - return !ev.Cancelled; - } - public bool CanUse(EntityUid uid) { - return CanUse(EntityManager.GetEntity(uid)); + var ev = new UseAttemptEvent(uid); + RaiseLocalEvent(uid, ev); + + return !ev.Cancelled; } public bool CanThrow(IEntity entity) diff --git a/Content.Shared/Interaction/Events/UseAttemptEvent.cs b/Content.Shared/Interaction/Events/UseAttemptEvent.cs index 12cd6c84bf..06fec96487 100644 --- a/Content.Shared/Interaction/Events/UseAttemptEvent.cs +++ b/Content.Shared/Interaction/Events/UseAttemptEvent.cs @@ -4,11 +4,11 @@ namespace Content.Shared.Interaction.Events { public class UseAttemptEvent : CancellableEntityEventArgs { - public UseAttemptEvent(IEntity entity) + public UseAttemptEvent(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 5819104f15..cf7514a8d6 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -444,7 +444,7 @@ namespace Content.Shared.Interaction delayComponent.BeginDelay(); } - if (!_actionBlockerSystem.CanInteract(user) || !_actionBlockerSystem.CanUse(user)) + if (!_actionBlockerSystem.CanInteract(user) || !_actionBlockerSystem.CanUse(user.Uid)) return; // all activates should only fire when in range / unobstructed @@ -474,7 +474,7 @@ namespace Content.Shared.Interaction /// public void TryUseInteraction(IEntity user, IEntity used, bool altInteract = false) { - if (user != null && used != null && _actionBlockerSystem.CanUse(user)) + if (user != null && used != null && _actionBlockerSystem.CanUse(user.Uid)) { if (altInteract) AltInteract(user, used); diff --git a/Content.Shared/Verbs/VerbEvents.cs b/Content.Shared/Verbs/VerbEvents.cs index 34245c9c14..e84fc5f36c 100644 --- a/Content.Shared/Verbs/VerbEvents.cs +++ b/Content.Shared/Verbs/VerbEvents.cs @@ -166,7 +166,7 @@ namespace Content.Shared.Verbs /// The entity currently being held by the active hand. /// /// - /// This is only ever not null when is true and the user + /// This is only ever not null when is true and the user /// has hands. /// public IEntity? Using; @@ -185,7 +185,7 @@ namespace Content.Shared.Verbs CanInteract = force || actionBlockerSystem.CanInteract(user); if (!user.TryGetComponent(out Hands) || - !actionBlockerSystem.CanUse(user)) + !actionBlockerSystem.CanUse(user.Uid)) return; Hands.TryGetActiveHeldEntity(out Using);