From 9b8185db2349213f7c23944f49c525f9bf2826bf Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sat, 19 Jun 2021 10:03:24 +0200 Subject: [PATCH] Deprecate IActionBlocker in favour of cancellable events (#4193) * Deprecate IActionBlocker in favour of cancellable events * Bring back old speech/emoting component restrictions * Rename action blocker listener methods * Use Entity System public methods instead of extension methods Co-authored-by: Vera Aguilera Puerto --- .../Physics/Controllers/MoverController.cs | 3 +- .../Tests/Buckle/BuckleTest.cs | 23 +- .../AI/Steering/AiSteeringSystem.cs | 3 +- .../ActionBlocker/CanMoveCon.cs | 4 +- .../AME/Components/AMEControllerComponent.cs | 7 +- .../Components/IdCardConsoleComponent.cs | 6 +- .../Actions/Actions/DisarmAction.cs | 4 +- .../Actions/Actions/ScreamAction.cs | 4 +- .../Actions/ServerActionsComponent.cs | 3 +- .../Components/BlockGameArcadeComponent.cs | 14 +- .../Components/SpaceVillainArcadeComponent.cs | 11 +- .../Surgery/Components/SurgeryToolSystem.cs | 3 +- .../Botany/Components/LogComponent.cs | 3 +- .../Botany/Components/PlantHolderComponent.cs | 6 +- .../Buckle/Components/BuckleComponent.cs | 8 +- .../Buckle/Components/StrapComponent.cs | 3 +- .../Cabinet/ItemCabinetComponent.cs | 5 +- Content.Server/Chat/Managers/ChatManager.cs | 8 +- .../Components/ChemMasterComponent.cs | 9 +- .../Components/ReagentDispenserComponent.cs | 9 +- .../Climbing/Components/ClimbableComponent.cs | 6 +- .../Clothing/Components/MagbootsComponent.cs | 3 +- .../Components/ConstructionComponent.Verbs.cs | 4 +- .../Construction/ConstructionSystem.cs | 6 +- .../Cuffs/Components/CuffableComponent.cs | 6 +- .../Cuffs/Components/HandcuffComponent.cs | 4 +- .../Mailing/DisposalMailingUnitComponent.cs | 12 +- .../Components/DisposalRouterComponent.cs | 5 +- .../Components/DisposalTaggerComponent.cs | 5 +- .../Unit/Components/DisposalUnitComponent.cs | 12 +- .../Fluids/Components/SpillableComponent.cs | 4 +- .../Fluids/Components/SprayComponent.cs | 6 +- .../Components/Atmos/FlammableComponent.cs | 5 +- .../Components/Atmos/GasCanisterComponent.cs | 10 +- .../Components/Atmos/GasTankComponent.cs | 8 +- .../BaseComputerUserInterfaceComponent.cs | 3 +- .../Hands/Components/HandsComponent.cs | 9 +- .../Instruments/InstrumentComponent.cs | 6 +- .../Interaction/InteractionSystem.cs | 24 +- .../Components/InventoryComponent.cs | 6 +- Content.Server/Items/ItemComponent.cs | 3 +- .../Components/ExpendableLightComponent.cs | 3 +- .../Components/HandheldLightComponent.cs | 8 +- .../EntitySystems/LightReplacerSystem.cs | 5 +- .../Components/SignalSwitchComponent.cs | 4 +- .../Medical/Components/HealingComponent.cs | 3 +- .../Components/MedicalScannerComponent.cs | 6 +- .../Metabolism/MetabolismComponent.cs | 8 +- .../BodyBagEntityStorageComponent.cs | 4 +- .../CrematoriumEntityStorageComponent.cs | 4 +- Content.Server/PDA/PDAComponent.cs | 8 +- .../ParticleAcceleratorControlBoxComponent.cs | 3 +- .../Physics/Controllers/MoverController.cs | 3 +- .../Pointing/EntitySystems/PointingSystem.cs | 6 +- .../Power/Components/BaseCharger.cs | 6 +- .../Components/PowerCellSlotComponent.cs | 3 +- .../Rotation/Components/FlippableComponent.cs | 4 +- .../Rotation/Components/RotatableComponent.cs | 6 +- .../Components/EntityStorageComponent.cs | 4 +- .../SecureEntityStorageComponent.cs | 4 +- Content.Server/Strip/StrippableComponent.cs | 12 +- Content.Server/Stunnable/StunbatonSystem.cs | 10 +- .../Tools/Components/ToolComponent.cs | 3 +- .../Ammunition/Components/AmmoBoxComponent.cs | 4 +- .../Components/BoltActionBarrelComponent.cs | 6 +- .../Components/RevolverBarrelComponent.cs | 4 +- .../ServerBatteryBarrelComponent.cs | 3 +- .../ServerMagazineBarrelComponent.cs | 8 +- .../Ranged/ServerRangedWeaponComponent.cs | 4 +- .../ActionBlocker/ActionBlockerExtensions.cs | 78 ------ .../ActionBlocker/ActionBlockerSystem.cs | 240 ++++++++++++------ .../ActionBlocker/IActionBlocker.cs | 16 ++ Content.Shared/DragDrop/DropAttemptEvent.cs | 14 + Content.Shared/Emoting/EmoteAttemptEvent.cs | 14 + Content.Shared/Emoting/EmoteSystem.cs | 22 ++ .../SharedTileFrictionController.cs | 5 +- .../TileFrictionModifier.cs | 2 +- .../Interaction/Events/AttackAttemptEvent.cs | 14 + .../Events/ChangeDirectionAttemptEvent.cs | 14 + .../Events/InteractionAttemptEvent.cs | 14 + .../Interaction/Events/UseAttemptEvent.cs | 14 + .../Inventory/Events/EquipAttemptEvent.cs | 14 + .../Inventory/Events/UnequipAttemptEvent.cs | 14 + Content.Shared/Item/PickupAttemptEvent.cs | 14 + Content.Shared/Item/SharedItemComponent.cs | 2 +- .../Metabolism/Events/ShiverAttemptEvent.cs | 14 + .../Metabolism/Events/SweatAttemptEvent.cs | 14 + .../SharedMobMoverSystem.cs | 2 +- .../{ => EntitySystems}/SharedMoverSystem.cs | 2 +- .../Movement/MovementAttemptEvent.cs | 14 + .../SharedMoverController.cs | 4 +- .../Components/SharedPullableComponent.cs | 3 +- Content.Shared/Speech/SpeakAttemptEvent.cs | 14 + Content.Shared/Speech/SpeechSystem.cs | 22 ++ .../Storage/SharedStorageComponent.cs | 3 +- .../Components/SharedStrippableComponent.cs | 3 +- Content.Shared/Throwing/ThrowAttemptEvent.cs | 14 + SpaceStation14.sln.DotSettings | 1 + 98 files changed, 669 insertions(+), 361 deletions(-) delete mode 100644 Content.Shared/ActionBlocker/ActionBlockerExtensions.cs create mode 100644 Content.Shared/DragDrop/DropAttemptEvent.cs create mode 100644 Content.Shared/Emoting/EmoteAttemptEvent.cs create mode 100644 Content.Shared/Emoting/EmoteSystem.cs rename Content.Shared/{Physics/Controllers => Friction}/SharedTileFrictionController.cs (98%) rename Content.Shared/{Movement/Components => Friction}/TileFrictionModifier.cs (97%) create mode 100644 Content.Shared/Interaction/Events/AttackAttemptEvent.cs create mode 100644 Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs create mode 100644 Content.Shared/Interaction/Events/InteractionAttemptEvent.cs create mode 100644 Content.Shared/Interaction/Events/UseAttemptEvent.cs create mode 100644 Content.Shared/Inventory/Events/EquipAttemptEvent.cs create mode 100644 Content.Shared/Inventory/Events/UnequipAttemptEvent.cs create mode 100644 Content.Shared/Item/PickupAttemptEvent.cs create mode 100644 Content.Shared/Metabolism/Events/ShiverAttemptEvent.cs create mode 100644 Content.Shared/Metabolism/Events/SweatAttemptEvent.cs rename Content.Shared/Movement/{ => EntitySystems}/SharedMobMoverSystem.cs (96%) rename Content.Shared/Movement/{ => EntitySystems}/SharedMoverSystem.cs (98%) create mode 100644 Content.Shared/Movement/MovementAttemptEvent.cs rename Content.Shared/{Physics/Controllers => Movement}/SharedMoverController.cs (98%) create mode 100644 Content.Shared/Speech/SpeakAttemptEvent.cs create mode 100644 Content.Shared/Speech/SpeechSystem.cs create mode 100644 Content.Shared/Throwing/ThrowAttemptEvent.cs diff --git a/Content.Client/Physics/Controllers/MoverController.cs b/Content.Client/Physics/Controllers/MoverController.cs index e7fef24c906..7b2d05aa502 100644 --- a/Content.Client/Physics/Controllers/MoverController.cs +++ b/Content.Client/Physics/Controllers/MoverController.cs @@ -1,10 +1,9 @@ #nullable enable +using Content.Shared.Movement; using Content.Shared.Movement.Components; -using Content.Shared.Physics.Controllers; using Robust.Client.Player; using Robust.Shared.GameObjects; using Robust.Shared.IoC; -using Robust.Shared.Physics.Dynamics; namespace Content.Client.Physics.Controllers { diff --git a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs index 6029e2572a0..513d9cd9f8a 100644 --- a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs +++ b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs @@ -9,6 +9,8 @@ using Content.Shared.Buckle.Components; using Content.Shared.Coordinates; using Content.Shared.EffectBlocker; +using Content.Shared.Interaction.Events; +using Content.Shared.Movement; using NUnit.Framework; using Robust.Server.Player; using Robust.Shared.GameObjects; @@ -66,6 +68,7 @@ await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve(); var entityManager = IoCManager.Resolve(); + var actionBlocker = EntitySystem.Get(); var gridId = new GridId(1); var grid = mapManager.GetGrid(gridId); @@ -79,8 +82,8 @@ await server.WaitAssertion(() => Assert.NotNull(buckle); Assert.Null(buckle.BuckledTo); Assert.False(buckle.Buckled); - Assert.True(ActionBlockerSystem.CanMove(human)); - Assert.True(ActionBlockerSystem.CanChangeDirection(human)); + Assert.True(actionBlocker.CanMove(human)); + Assert.True(actionBlocker.CanChangeDirection(human)); Assert.True(EffectBlockerSystem.CanFall(human)); // Default state, no buckled entities, strap @@ -96,8 +99,8 @@ await server.WaitAssertion(() => var player = IoCManager.Resolve().GetAllPlayers().Single(); Assert.True(((BuckleComponentState) buckle.GetComponentState(player)).Buckled); - Assert.False(ActionBlockerSystem.CanMove(human)); - Assert.False(ActionBlockerSystem.CanChangeDirection(human)); + Assert.False(actionBlocker.CanMove(human)); + Assert.False(actionBlocker.CanChangeDirection(human)); Assert.False(EffectBlockerSystem.CanFall(human)); Assert.That(human.Transform.WorldPosition, Is.EqualTo(chair.Transform.WorldPosition)); @@ -120,6 +123,8 @@ await server.WaitAssertion(() => await server.WaitAssertion(() => { + var actionBlocker = EntitySystem.Get(); + // Still buckled Assert.True(buckle.Buckled); @@ -127,8 +132,8 @@ await server.WaitAssertion(() => Assert.True(buckle.TryUnbuckle(human)); Assert.Null(buckle.BuckledTo); Assert.False(buckle.Buckled); - Assert.True(ActionBlockerSystem.CanMove(human)); - Assert.True(ActionBlockerSystem.CanChangeDirection(human)); + Assert.True(actionBlocker.CanMove(human)); + Assert.True(actionBlocker.CanChangeDirection(human)); Assert.True(EffectBlockerSystem.CanFall(human)); // Unbuckle, strap @@ -153,6 +158,8 @@ await server.WaitAssertion(() => await server.WaitAssertion(() => { + var actionBlocker = EntitySystem.Get(); + // Still buckled Assert.True(buckle.Buckled); @@ -182,8 +189,8 @@ await server.WaitAssertion(() => // Force unbuckle Assert.True(buckle.TryUnbuckle(human, true)); Assert.False(buckle.Buckled); - Assert.True(ActionBlockerSystem.CanMove(human)); - Assert.True(ActionBlockerSystem.CanChangeDirection(human)); + Assert.True(actionBlocker.CanMove(human)); + Assert.True(actionBlocker.CanChangeDirection(human)); Assert.True(EffectBlockerSystem.CanFall(human)); // Re-buckle diff --git a/Content.Server/AI/Steering/AiSteeringSystem.cs b/Content.Server/AI/Steering/AiSteeringSystem.cs index 6bae1b1c549..7db0a973490 100644 --- a/Content.Server/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/AI/Steering/AiSteeringSystem.cs @@ -10,6 +10,7 @@ using Content.Server.CPUJob.JobQueues; using Content.Shared.ActionBlocker; using Content.Shared.Interaction.Helpers; +using Content.Shared.Movement; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; @@ -249,7 +250,7 @@ private SteeringStatus Steer(IEntity entity, IAiSteeringRequest steeringRequest, // Main optimisation to be done below is the redundant calls and adding more variables if (entity.Deleted || !entity.TryGetComponent(out AiControllerComponent? controller) || - !ActionBlockerSystem.CanMove(entity) || + !EntitySystem.Get().CanMove(entity) || !entity.Transform.GridID.IsValid()) { return SteeringStatus.NoPath; diff --git a/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs b/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs index ad708db647b..18ffa4ac79c 100644 --- a/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs +++ b/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs @@ -1,6 +1,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Shared.ActionBlocker; +using Content.Shared.Movement; +using Robust.Shared.GameObjects; namespace Content.Server.AI.Utility.Considerations.ActionBlocker { @@ -10,7 +12,7 @@ protected override float GetScore(Blackboard context) { var self = context.GetState().GetValue(); - if (self == null || !ActionBlockerSystem.CanMove(self)) + if (self == null || !EntitySystem.Get().CanMove(self)) { return 0.0f; } diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index f861ed6a554..000d47df693 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -9,7 +9,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.AME; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -157,8 +157,11 @@ private bool PlayerCanUseController(IEntity playerEntity, bool needsPower = true //Need player entity to check if they are still able to use the dispenser if (playerEntity == null) return false; + + var actionBlocker = EntitySystem.Get(); + //Check if player can interact in their current state - if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity)) + if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity)) return false; //Check if device is powered if (needsPower && !Powered) diff --git a/Content.Server/Access/Components/IdCardConsoleComponent.cs b/Content.Server/Access/Components/IdCardConsoleComponent.cs index c3d18c1c3ba..dad601ac8f3 100644 --- a/Content.Server/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Server/Access/Components/IdCardConsoleComponent.cs @@ -10,7 +10,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Acts; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -259,7 +259,7 @@ public sealed class EjectPrivilegedIDVerb : Verb { protected override void GetData(IEntity user, IdCardConsoleComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -284,7 +284,7 @@ public sealed class EjectTargetIDVerb : Verb { protected override void GetData(IEntity user, IdCardConsoleComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Actions/Actions/DisarmAction.cs b/Content.Server/Actions/Actions/DisarmAction.cs index 84b1f78e2fa..36635964643 100644 --- a/Content.Server/Actions/Actions/DisarmAction.cs +++ b/Content.Server/Actions/Actions/DisarmAction.cs @@ -11,8 +11,8 @@ using Content.Shared.Actions.Components; using Content.Shared.Audio; using Content.Shared.Cooldown; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -57,7 +57,7 @@ public void DoTargetEntityAction(TargetEntityActionEventArgs args) } if (!args.Performer.TryGetComponent(out var actions)) return; - if (args.Target == args.Performer || !args.Performer.CanAttack()) return; + if (args.Target == args.Performer || !EntitySystem.Get().CanAttack(args.Performer)) return; var random = IoCManager.Resolve(); var audio = EntitySystem.Get(); diff --git a/Content.Server/Actions/Actions/ScreamAction.cs b/Content.Server/Actions/Actions/ScreamAction.cs index 544b064843a..0f1fa8cfdb2 100644 --- a/Content.Server/Actions/Actions/ScreamAction.cs +++ b/Content.Server/Actions/Actions/ScreamAction.cs @@ -8,8 +8,10 @@ using Content.Shared.Audio; using Content.Shared.CharacterAppearance; using Content.Shared.Cooldown; +using Content.Shared.Speech; using JetBrains.Annotations; using Robust.Shared.Audio; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Player; using Robust.Shared.Random; @@ -40,7 +42,7 @@ public ScreamAction() public void DoInstantAction(InstantActionEventArgs args) { - if (!ActionBlockerSystem.CanSpeak(args.Performer)) return; + if (!EntitySystem.Get().CanSpeak(args.Performer)) return; if (!args.Performer.TryGetComponent(out var humanoid)) return; if (!args.Performer.TryGetComponent(out var actions)) return; diff --git a/Content.Server/Actions/ServerActionsComponent.cs b/Content.Server/Actions/ServerActionsComponent.cs index 4760efb3e49..ab89458458d 100644 --- a/Content.Server/Actions/ServerActionsComponent.cs +++ b/Content.Server/Actions/ServerActionsComponent.cs @@ -4,6 +4,7 @@ using Content.Shared.Actions; using Content.Shared.Actions.Components; using Content.Shared.Actions.Prototypes; +using Content.Shared.Interaction.Events; using Robust.Server.GameObjects; using Robust.Server.GameStates; using Robust.Shared.GameObjects; @@ -186,7 +187,7 @@ private bool CheckRangeAndSetFacing(EntityCoordinates target, IEntity player) return false; } - if (!ActionBlockerSystem.CanChangeDirection(player)) return true; + if (!EntitySystem.Get().CanChangeDirection(player)) return true; // don't set facing unless they clicked far enough away var diff = targetWorldPos - player.Transform.WorldPosition; diff --git a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs index f0faf10fa1e..2530be6f1bc 100644 --- a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs +++ b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Arcade; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; using Robust.Server.GameObjects; using Robust.Server.Player; @@ -49,15 +50,11 @@ public override void HandleMessage(ComponentMessage message, IComponent? compone void IActivate.Activate(ActivateEventArgs eventArgs) { - if(!eventArgs.User.TryGetComponent(out ActorComponent? actor)) - { + if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) return; - } - if (!Powered) - { + + if(!EntitySystem.Get().CanInteract(eventArgs.User)) return; - } - if(!ActionBlockerSystem.CanInteract(actor.PlayerSession.AttachedEntity)) return; UserInterface?.Toggle(actor.PlayerSession); RegisterPlayerSession(actor.PlayerSession); @@ -134,7 +131,8 @@ private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage obj case BlockGameMessages.BlockGamePlayerActionMessage playerActionMessage: if (obj.Session != _player) break; - if (!ActionBlockerSystem.CanInteract(Owner)) + // TODO: Should this check if the Owner can interact...? + if (!EntitySystem.Get().CanInteract(Owner)) { DeactivePlayer(obj.Session); break; diff --git a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs index 878cc6911e2..e5fac0f427b 100644 --- a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Arcade; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Wires; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -58,15 +59,11 @@ public class SpaceVillainArcadeComponent : SharedSpaceVillainArcadeComponent, IA void IActivate.Activate(ActivateEventArgs eventArgs) { - if(!eventArgs.User.TryGetComponent(out ActorComponent? actor)) - { + if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) return; - } - if (!Powered) - { + + if(!EntitySystem.Get().CanInteract(eventArgs.User)) return; - } - if(!ActionBlockerSystem.CanInteract(actor.PlayerSession.AttachedEntity)) return; _game ??= new SpaceVillainGame(this); diff --git a/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs b/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs index 3a8ef516656..36f3eb743c6 100644 --- a/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs +++ b/Content.Server/Body/Surgery/Components/SurgeryToolSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Body.Surgery.Messages; using Content.Shared.ActionBlocker; using Content.Shared.GameTicking; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using JetBrains.Annotations; using Robust.Shared.GameObjects; @@ -52,7 +53,7 @@ public override void Update(float frameTime) continue; } - if (!ActionBlockerSystem.CanInteract(tool.PerformerCache) || + if (!Get().CanInteract(tool.PerformerCache) || !tool.PerformerCache.InRangeUnobstructed(tool.BodyCache)) { tool.CloseAllSurgeryUIs(); diff --git a/Content.Server/Botany/Components/LogComponent.cs b/Content.Server/Botany/Components/LogComponent.cs index f8b066c7083..7f079ee9703 100644 --- a/Content.Server/Botany/Components/LogComponent.cs +++ b/Content.Server/Botany/Components/LogComponent.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Random.Helpers; using Content.Shared.Tag; using Robust.Shared.GameObjects; @@ -14,7 +15,7 @@ public class LogComponent : Component, IInteractUsing async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) return false; if (eventArgs.Using.HasTag("BotanySharp")) diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index a7a1e28ae59..610e8d16fbc 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -15,7 +15,7 @@ using Content.Shared.Chemistry.Solution.Components; using Content.Shared.Examine; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Random.Helpers; using Content.Shared.Tag; @@ -420,7 +420,7 @@ private void CheckLevelSanity() public bool DoHarvest(IEntity user) { - if (Seed == null || user.Deleted || !ActionBlockerSystem.CanInteract(user)) + if (Seed == null || user.Deleted || !EntitySystem.Get().CanInteract(user)) return false; if (Harvest && !Dead) @@ -645,7 +645,7 @@ async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) var user = eventArgs.User; var usingItem = eventArgs.Using; - if (usingItem == null || usingItem.Deleted || !ActionBlockerSystem.CanInteract(user)) + if (usingItem == null || usingItem.Deleted || !EntitySystem.Get().CanInteract(user)) 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 7ff1d3a3e43..9459bc2b85e 100644 --- a/Content.Server/Buckle/Components/BuckleComponent.cs +++ b/Content.Server/Buckle/Components/BuckleComponent.cs @@ -10,8 +10,8 @@ using Content.Shared.ActionBlocker; using Content.Shared.Alert; using Content.Shared.Buckle.Components; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -161,7 +161,7 @@ private bool CanBuckle(IEntity? user, IEntity to, [NotNullWhen(true)] out StrapC return false; } - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { user.PopupMessage(Loc.GetString("You can't do that!")); return false; @@ -314,7 +314,7 @@ public bool TryUnbuckle(IEntity user, bool force = false) return false; } - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { user.PopupMessage(Loc.GetString("You can't do that!")); return false; @@ -439,7 +439,7 @@ private sealed class BuckleVerb : Verb { protected override void GetData(IEntity user, BuckleComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || !component.Buckled) + if (!EntitySystem.Get().CanInteract(user) || !component.Buckled) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Buckle/Components/StrapComponent.cs b/Content.Server/Buckle/Components/StrapComponent.cs index e668d7bc99a..da4575a8952 100644 --- a/Content.Server/Buckle/Components/StrapComponent.cs +++ b/Content.Server/Buckle/Components/StrapComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.Buckle.Components; using Content.Shared.DragDrop; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -179,7 +180,7 @@ protected override void GetData(IEntity user, StrapComponent component, VerbData { data.Visibility = VerbVisibility.Invisible; - if (!ActionBlockerSystem.CanInteract(component.Owner) || + if (!EntitySystem.Get().CanInteract(component.Owner) || !user.TryGetComponent(out var buckle) || buckle.BuckledTo != null && buckle.BuckledTo != component || user == component.Owner) diff --git a/Content.Server/Cabinet/ItemCabinetComponent.cs b/Content.Server/Cabinet/ItemCabinetComponent.cs index 486bd7d7d70..f85f311ce22 100644 --- a/Content.Server/Cabinet/ItemCabinetComponent.cs +++ b/Content.Server/Cabinet/ItemCabinetComponent.cs @@ -1,4 +1,5 @@ using Content.Shared.ActionBlocker; +using Content.Shared.Interaction.Events; using Content.Shared.Verbs; using Content.Shared.Whitelist; using Robust.Shared.Containers; @@ -54,7 +55,7 @@ public sealed class EjectItemFromCabinetVerb : Verb { protected override void GetData(IEntity user, ItemCabinetComponent component, VerbData data) { - if (component.ItemContainer.ContainedEntity == null || !component.Opened || !ActionBlockerSystem.CanInteract(user)) + if (component.ItemContainer.ContainedEntity == null || !component.Opened || !EntitySystem.Get().CanInteract(user)) data.Visibility = VerbVisibility.Invisible; else { @@ -75,7 +76,7 @@ public sealed class ToggleItemCabinetVerb : Verb { protected override void GetData(IEntity user, ItemCabinetComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) data.Visibility = VerbVisibility.Invisible; else { diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 68fca92a0b1..5825181494f 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -8,14 +8,14 @@ using Content.Server.MoMMI; using Content.Server.Preferences.Managers; using Content.Server.Radio.EntitySystems; -using Content.Shared; using Content.Shared.ActionBlocker; using Content.Shared.Administration; using Content.Shared.CCVar; using Content.Shared.Chat; +using Content.Shared.Emoting; using Content.Shared.Inventory; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; +using Content.Shared.Speech; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Configuration; @@ -122,7 +122,7 @@ public void DispatchServerMessage(IPlayerSession player, string message) public void EntitySay(IEntity source, string message) { - if (!ActionBlockerSystem.CanSpeak(source)) + if (!EntitySystem.Get().CanSpeak(source)) { return; } @@ -195,7 +195,7 @@ public void EntitySay(IEntity source, string message) public void EntityMe(IEntity source, string action) { - if (!ActionBlockerSystem.CanEmote(source)) + if (!EntitySystem.Get().CanEmote(source)) { return; } diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index 499b49a70dd..1ffae1e5606 100644 --- a/Content.Server/Chemistry/Components/ChemMasterComponent.cs +++ b/Content.Server/Chemistry/Components/ChemMasterComponent.cs @@ -12,7 +12,7 @@ using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Solution; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Random.Helpers; using Content.Shared.Verbs; @@ -144,8 +144,11 @@ private bool PlayerCanUseChemMaster(IEntity? playerEntity, bool needsPower = tru //Need player entity to check if they are still able to use the chem master if (playerEntity == null) return false; + + var actionBlocker = EntitySystem.Get(); + //Check if player can interact in their current state - if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity)) + if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity)) return false; //Check if device is powered if (needsPower && !Powered) @@ -423,7 +426,7 @@ public sealed class EjectBeakerVerb : Verb { protected override void GetData(IEntity user, ChemMasterComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index 5b85dd799d4..829870108fa 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -13,7 +13,7 @@ using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Solution; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using JetBrains.Annotations; @@ -194,8 +194,11 @@ private bool PlayerCanUseDispenser(IEntity? playerEntity, bool needsPower = true //Need player entity to check if they are still able to use the dispenser if (playerEntity == null) return false; + + var actionBlocker = EntitySystem.Get(); + //Check if player can interact in their current state - if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity)) + if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity)) return false; //Check if device is powered if (needsPower && !Powered) @@ -365,7 +368,7 @@ public sealed class EjectBeakerVerb : Verb { protected override void GetData(IEntity user, ReagentDispenserComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Climbing/Components/ClimbableComponent.cs b/Content.Server/Climbing/Components/ClimbableComponent.cs index 1d5cfae5fe9..d864612009e 100644 --- a/Content.Server/Climbing/Components/ClimbableComponent.cs +++ b/Content.Server/Climbing/Components/ClimbableComponent.cs @@ -6,8 +6,8 @@ using Content.Shared.Body.Part; using Content.Shared.Climbing; using Content.Shared.DragDrop; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Shared.GameObjects; @@ -68,7 +68,7 @@ public override bool CanDragDropOn(DragDropEvent eventArgs) /// private bool CanVault(IEntity user, IEntity target, out string reason) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { reason = Loc.GetString("comp-climbable-cant-interact"); return false; @@ -108,7 +108,7 @@ private bool CanVault(IEntity user, IEntity target, out string reason) /// private bool CanVault(IEntity user, IEntity dragged, IEntity target, out string reason) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { reason = Loc.GetString("comp-climbable-cant-interact"); return false; diff --git a/Content.Server/Clothing/Components/MagbootsComponent.cs b/Content.Server/Clothing/Components/MagbootsComponent.cs index 32ee8babc98..f4dd5c8012f 100644 --- a/Content.Server/Clothing/Components/MagbootsComponent.cs +++ b/Content.Server/Clothing/Components/MagbootsComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Alert; using Content.Shared.Clothing; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Inventory; using Content.Shared.Verbs; using JetBrains.Annotations; @@ -125,7 +126,7 @@ public sealed class ToggleMagbootsVerb : Verb { protected override void GetData(IEntity user, MagbootsComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Construction/Components/ConstructionComponent.Verbs.cs b/Content.Server/Construction/Components/ConstructionComponent.Verbs.cs index 1a6f9d5b8c1..d73658a728b 100644 --- a/Content.Server/Construction/Components/ConstructionComponent.Verbs.cs +++ b/Content.Server/Construction/Components/ConstructionComponent.Verbs.cs @@ -1,5 +1,5 @@ using Content.Shared.ActionBlocker; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Shared.GameObjects; @@ -14,7 +14,7 @@ public sealed class DeconstructibleVerb : Verb { protected override void GetData(IEntity user, ConstructionComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Construction/ConstructionSystem.cs b/Content.Server/Construction/ConstructionSystem.cs index e173305795c..6f8b4d07e63 100644 --- a/Content.Server/Construction/ConstructionSystem.cs +++ b/Content.Server/Construction/ConstructionSystem.cs @@ -15,8 +15,8 @@ using Content.Shared.Construction.Prototypes; using Content.Shared.Construction.Steps; using Content.Shared.Coordinates; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using JetBrains.Annotations; using Robust.Shared.Containers; @@ -305,7 +305,7 @@ private async void HandleStartItemConstruction(TryStartItemConstructionMessage e var user = args.SenderSession.AttachedEntity; - if (user == null || !ActionBlockerSystem.CanInteract(user)) return; + if (user == null || !Get().CanInteract(user)) return; if (!user.TryGetComponent(out HandsComponent? hands)) return; @@ -399,7 +399,7 @@ void Cleanup() } if (user == null - || !ActionBlockerSystem.CanInteract(user) + || !Get().CanInteract(user) || !user.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand == null || !user.InRangeUnobstructed(ev.Location, ignoreInsideBlocker:constructionPrototype.CanBuildInImpassable)) { diff --git a/Content.Server/Cuffs/Components/CuffableComponent.cs b/Content.Server/Cuffs/Components/CuffableComponent.cs index 15d187f1d81..787982da1a2 100644 --- a/Content.Server/Cuffs/Components/CuffableComponent.cs +++ b/Content.Server/Cuffs/Components/CuffableComponent.cs @@ -8,8 +8,8 @@ using Content.Shared.ActionBlocker; using Content.Shared.Alert; using Content.Shared.Cuffs.Components; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -209,7 +209,7 @@ public async void TryUncuff(IEntity user, IEntity? cuffsToRemove = null) } // TODO: Make into an event and instead have a system check for owner. - if (!isOwner && !ActionBlockerSystem.CanInteract(user)) + if (!isOwner && !EntitySystem.Get().CanInteract(user)) { user.PopupMessage(Loc.GetString("You can't do that!")); return; @@ -322,7 +322,7 @@ private sealed class UncuffVerb : Verb { protected override void GetData(IEntity user, CuffableComponent component, VerbData data) { - if ((user != component.Owner && !ActionBlockerSystem.CanInteract(user)) || component.CuffedHandCount == 0) + if ((user != component.Owner && !EntitySystem.Get().CanInteract(user)) || component.CuffedHandCount == 0) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index f0003e97d53..546de4ab156 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -7,8 +7,8 @@ using Content.Shared.ActionBlocker; using Content.Shared.Cuffs.Components; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -146,7 +146,7 @@ async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) { if (_cuffing) return true; - if (eventArgs.Target == null || !ActionBlockerSystem.CanUse(eventArgs.User) || !eventArgs.Target.TryGetComponent(out var cuffed)) + if (eventArgs.Target == null || !EntitySystem.Get().CanUse(eventArgs.User) || !eventArgs.Target.TryGetComponent(out var cuffed)) { return false; } diff --git a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs index 032163788ef..6f4992adb01 100644 --- a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs +++ b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs @@ -397,8 +397,10 @@ private bool PlayerCanUse(IEntity? player) return false; } - if (!ActionBlockerSystem.CanInteract(player) || - !ActionBlockerSystem.CanUse(player)) + var actionBlocker = EntitySystem.Get(); + + if (!actionBlocker.CanInteract(player) || + !actionBlocker.CanUse(player)) { return false; } @@ -659,7 +661,7 @@ private void OnReceiveNetMessage(int frequency, string sender, IReadOnlyDictiona private bool IsValidInteraction(ITargetedInteractEventArgs eventArgs) { - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("You can't do that!")); return false; @@ -746,7 +748,7 @@ protected override void GetData(IEntity user, DisposalMailingUnitComponent compo { data.Visibility = VerbVisibility.Invisible; - if (!ActionBlockerSystem.CanInteract(user) || + if (!EntitySystem.Get().CanInteract(user) || component.ContainedEntities.Contains(user)) { return; @@ -769,7 +771,7 @@ protected override void GetData(IEntity user, DisposalMailingUnitComponent compo { data.Visibility = VerbVisibility.Invisible; - if (!ActionBlockerSystem.CanInteract(user) || + if (!EntitySystem.Get().CanInteract(user) || component.ContainedEntities.Contains(user)) { return; diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index e5450d1f9c8..5621cbdbe5b 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -7,7 +7,7 @@ using Content.Server.UserInterface; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.Console; @@ -108,9 +108,10 @@ private bool PlayerCanUseDisposalTagger(IPlayerSession session) if (!Anchored) return false; + var actionBlocker = EntitySystem.Get(); var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!groupController.CanAdminMenu(session) && (!ActionBlockerSystem.CanInteract(session.AttachedEntity) || !ActionBlockerSystem.CanUse(session.AttachedEntity))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity))) return false; return true; diff --git a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs index 0f4aad0d485..a90087b5957 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs @@ -4,7 +4,7 @@ using Content.Server.UserInterface; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.Console; @@ -90,9 +90,10 @@ private bool PlayerCanUseDisposalTagger(IPlayerSession session) if (!Anchored) return false; + var actionBlocker = EntitySystem.Get(); var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!groupController.CanAdminMenu(session) && (!ActionBlockerSystem.CanInteract(session.AttachedEntity) || !ActionBlockerSystem.CanUse(session.AttachedEntity))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity))) return false; return true; diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index be34120c286..0c292a5042f 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -340,8 +340,10 @@ private bool PlayerCanUse(IEntity? player) return false; } - if (!ActionBlockerSystem.CanInteract(player) || - !ActionBlockerSystem.CanUse(player)) + var actionBlocker = EntitySystem.Get(); + + if (!actionBlocker.CanInteract(player) || + !actionBlocker.CanUse(player)) { return false; } @@ -556,7 +558,7 @@ public override void HandleMessage(ComponentMessage message, IComponent? compone bool IsValidInteraction(ITargetedInteractEventArgs eventArgs) { - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("You can't do that!")); return false; @@ -649,7 +651,7 @@ protected override void GetData(IEntity user, DisposalUnitComponent component, V { data.Visibility = VerbVisibility.Invisible; - if (!ActionBlockerSystem.CanInteract(user) || + if (!EntitySystem.Get().CanInteract(user) || component.ContainedEntities.Contains(user)) { return; @@ -672,7 +674,7 @@ protected override void GetData(IEntity user, DisposalUnitComponent component, V { data.Visibility = VerbVisibility.Invisible; - if (!ActionBlockerSystem.CanInteract(user) || + if (!EntitySystem.Get().CanInteract(user) || component.ContainedEntities.Contains(user)) { return; diff --git a/Content.Server/Fluids/Components/SpillableComponent.cs b/Content.Server/Fluids/Components/SpillableComponent.cs index d32cebdf8de..b5956c6525a 100644 --- a/Content.Server/Fluids/Components/SpillableComponent.cs +++ b/Content.Server/Fluids/Components/SpillableComponent.cs @@ -2,7 +2,7 @@ using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Solution.Components; using Content.Shared.DragDrop; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Shared.GameObjects; @@ -23,7 +23,7 @@ private sealed class SpillTargetVerb : Verb { protected override void GetData(IEntity user, SpillableComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || + if (!EntitySystem.Get().CanInteract(user) || !component.Owner.TryGetComponent(out ISolutionInteractionsComponent? solutionComponent) || !solutionComponent.CanDrain) { diff --git a/Content.Server/Fluids/Components/SprayComponent.cs b/Content.Server/Fluids/Components/SprayComponent.cs index 45dd21b2da3..7a63f147694 100644 --- a/Content.Server/Fluids/Components/SprayComponent.cs +++ b/Content.Server/Fluids/Components/SprayComponent.cs @@ -8,7 +8,7 @@ using Content.Shared.DragDrop; using Content.Shared.Fluids; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Vapor; using Robust.Server.GameObjects; @@ -96,7 +96,7 @@ public override void Initialize() async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) { - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) return false; if (_hasSafety && _safety) @@ -207,7 +207,7 @@ private void ToggleSafety(IEntity user) private void SetSafety(IEntity user, bool state) { - if (!ActionBlockerSystem.CanInteract(user) || !_hasSafety) + if (!EntitySystem.Get().CanInteract(user) || !_hasSafety) return; _safety = state; diff --git a/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs b/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs index 318f13206b6..e2aaee838bc 100644 --- a/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs @@ -8,12 +8,11 @@ using Content.Shared.ActionBlocker; using Content.Shared.Alert; using Content.Shared.Atmos; -using Content.Shared.Chemistry; using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.GameObjects.Components.Atmos; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Temperature; using Robust.Server.GameObjects; @@ -193,7 +192,7 @@ public void FireAct(float temperature, float volume) // This needs some improvements... public void Resist() { - if (!OnFire || !ActionBlockerSystem.CanInteract(Owner) || _resisting || !Owner.TryGetComponent(out StunnableComponent? stunnable)) return; + if (!OnFire || !EntitySystem.Get().CanInteract(Owner) || _resisting || !Owner.TryGetComponent(out StunnableComponent? stunnable)) return; _resisting = true; diff --git a/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs b/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs index 70107ee86b4..7219af5b143 100644 --- a/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs @@ -1,6 +1,5 @@ #nullable enable using System; -using System.Collections.Generic; using System.Linq; using Content.Server.Atmos; using Content.Server.GameObjects.Components.Atmos.Piping; @@ -10,13 +9,14 @@ using Content.Shared.Atmos; using Content.Shared.GameObjects.Components.Atmos; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; +using Robust.Shared.Physics; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; -using Robust.Shared.Physics; namespace Content.Server.GameObjects.Components.Atmos { @@ -267,8 +267,10 @@ private bool PlayerCanUse(IEntity? player) return false; } - if (!ActionBlockerSystem.CanInteract(player) || - !ActionBlockerSystem.CanUse(player)) + var actionBlocker = EntitySystem.Get(); + + if (!actionBlocker.CanInteract(player) || + !actionBlocker.CanUse(player)) { return false; } diff --git a/Content.Server/GameObjects/Components/Atmos/GasTankComponent.cs b/Content.Server/GameObjects/Components/Atmos/GasTankComponent.cs index 9eb7525ca87..92dcc446911 100644 --- a/Content.Server/GameObjects/Components/Atmos/GasTankComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GasTankComponent.cs @@ -15,8 +15,8 @@ using Content.Shared.DragDrop; using Content.Shared.Examine; using Content.Shared.GameObjects.Components.Atmos.GasTank; -using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -218,7 +218,11 @@ private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage mes internal void ToggleInternals() { - if (!ActionBlockerSystem.CanUse(GetInternalsComponent()?.Owner)) return; + var user = GetInternalsComponent()?.Owner; + + if (user == null || !EntitySystem.Get().CanUse(user)) + return; + if (IsConnected) { DisconnectFromInternals(); diff --git a/Content.Server/GameObjects/Components/BaseComputerUserInterfaceComponent.cs b/Content.Server/GameObjects/Components/BaseComputerUserInterfaceComponent.cs index ef06727697c..a9a1d2e5096 100644 --- a/Content.Server/GameObjects/Components/BaseComputerUserInterfaceComponent.cs +++ b/Content.Server/GameObjects/Components/BaseComputerUserInterfaceComponent.cs @@ -2,6 +2,7 @@ using Content.Server.UserInterface; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; @@ -63,7 +64,7 @@ protected void OnReceiveUnfilteredUserInterfaceMessage(ServerBoundUserInterfaceM return; // Not powered, so this computer should probably do nothing. } // Can we interact? - if (!ActionBlockerSystem.CanInteract(sessionEntity)) + if (!EntitySystem.Get().CanInteract(sessionEntity)) { sessionEntity.PopupMessageCursor(Loc.GetString("base-computer-ui-component-cannot-interact")); return; diff --git a/Content.Server/Hands/Components/HandsComponent.cs b/Content.Server/Hands/Components/HandsComponent.cs index 764cf561e9e..219a37b563f 100644 --- a/Content.Server/Hands/Components/HandsComponent.cs +++ b/Content.Server/Hands/Components/HandsComponent.cs @@ -11,8 +11,9 @@ using Content.Shared.ActionBlocker; using Content.Shared.Audio; using Content.Shared.Body.Part; +using Content.Shared.DragDrop; using Content.Shared.Hands.Components; -using Content.Shared.Notification; +using Content.Shared.Item; using Content.Shared.Notification.Managers; using Content.Shared.Physics.Pull; using Content.Shared.Pulling.Components; @@ -224,7 +225,7 @@ private static void DropAtFeet(IEntity mob, ItemComponent item) public bool CanPutInHand(ItemComponent item, bool mobCheck = true) { - if (mobCheck && !ActionBlockerSystem.CanPickup(Owner)) + if (mobCheck && !EntitySystem.Get().CanPickup(Owner)) return false; foreach (var handName in ActivePriorityEnumerable()) @@ -241,7 +242,7 @@ public bool CanPutInHand(ItemComponent item, bool mobCheck = true) public bool CanPutInHand(ItemComponent item, string index, bool mobCheck = true) { - if (mobCheck && !ActionBlockerSystem.CanPickup(Owner)) + if (mobCheck && !EntitySystem.Get().CanPickup(Owner)) return false; var hand = GetHand(index); @@ -445,7 +446,7 @@ public bool CanDrop(string name, bool mobCheck = true) { var hand = GetHand(name); - if (mobCheck && !ActionBlockerSystem.CanDrop(Owner)) + if (mobCheck && !EntitySystem.Get().CanDrop(Owner)) return false; if (hand?.Entity == null) diff --git a/Content.Server/Instruments/InstrumentComponent.cs b/Content.Server/Instruments/InstrumentComponent.cs index 9eaa37ec9a2..4f4ba29d4cf 100644 --- a/Content.Server/Instruments/InstrumentComponent.cs +++ b/Content.Server/Instruments/InstrumentComponent.cs @@ -9,7 +9,7 @@ using Content.Shared.Hands; using Content.Shared.Instruments; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Throwing; using Robust.Server.GameObjects; @@ -334,7 +334,9 @@ public override void Update(float delta) var maxMidiLaggedBatches = _instrumentSystem.MaxMidiLaggedBatches; var maxMidiBatchDropped = _instrumentSystem.MaxMidiBatchesDropped; - if (_instrumentPlayer != null && !ActionBlockerSystem.CanInteract(_instrumentPlayer.AttachedEntity)) + if (_instrumentPlayer != null + && (_instrumentPlayer.AttachedEntity == null + || !EntitySystem.Get().CanInteract(_instrumentPlayer.AttachedEntity))) { InstrumentPlayer = null; Clean(); diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 9743761e500..6baeadffc10 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -14,9 +14,9 @@ using Content.Shared.Hands.Components; using Content.Shared.Input; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Content.Shared.Inventory; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Rotatable; using Content.Shared.Throwing; @@ -175,10 +175,12 @@ public void TryInteractionActivate(IEntity? user, IEntity? used) private void InteractionActivate(IEntity user, IEntity used) { - if (!ActionBlockerSystem.CanInteract(user) || ! ActionBlockerSystem.CanUse(user)) + var actionBlocker = Get(); + + if (!actionBlocker.CanInteract(user) || ! actionBlocker.CanUse(user)) return; - // all activates should only fire when in range / unbostructed + // all activates should only fire when in range / unobstructed if (!InRangeUnobstructed(user, used, ignoreInsideBlocker: true, popup: true)) return; @@ -273,7 +275,7 @@ public async void UserInteraction(IEntity user, EntityCoordinates coordinates, E if (!ValidateInteractAndFace(user, coordinates)) return; - if (!ActionBlockerSystem.CanInteract(user)) + if (!Get().CanInteract(user)) return; // Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null @@ -342,7 +344,7 @@ private void FaceClickCoordinates(IEntity user, EntityCoordinates coordinates) if (diff.LengthSquared <= 0.01f) return; var diffAngle = Angle.FromWorldVec(diff); - if (ActionBlockerSystem.CanChangeDirection(user)) + if (Get().CanChangeDirection(user)) { user.Transform.WorldRotation = diffAngle; } @@ -392,7 +394,7 @@ private async Task InteractDoAfter(IEntity user, IEntity used, IEntity? ta /// public async Task InteractUsing(IEntity user, IEntity used, IEntity target, EntityCoordinates clickLocation) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!Get().CanInteract(user)) return; // all interactions should only happen when in range / unobstructed, so no range check is needed @@ -422,7 +424,7 @@ public async Task InteractUsing(IEntity user, IEntity used, IEntity target, Enti /// public void InteractHand(IEntity user, IEntity target) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!Get().CanInteract(user)) return; // all interactions should only happen when in range / unobstructed, so no range check is needed @@ -455,7 +457,7 @@ public void InteractHand(IEntity user, IEntity target) /// public void TryUseInteraction(IEntity user, IEntity used) { - if (user != null && used != null && ActionBlockerSystem.CanUse(user)) + if (user != null && used != null && Get().CanUse(user)) { UseInteraction(user, used); } @@ -499,7 +501,7 @@ public void UseInteraction(IEntity user, IEntity used) /// public bool TryThrowInteraction(IEntity user, IEntity item) { - if (user == null || item == null || !ActionBlockerSystem.CanThrow(user)) return false; + if (user == null || item == null || !Get().CanThrow(user)) return false; ThrownInteraction(user, item); return true; @@ -616,7 +618,7 @@ public void UnequippedHandInteraction(IEntity user, IEntity item, SharedHand han /// public bool TryDroppedInteraction(IEntity user, IEntity item, bool intentional) { - if (user == null || item == null || !ActionBlockerSystem.CanDrop(user)) return false; + if (user == null || item == null || !Get().CanDrop(user)) return false; DroppedInteraction(user, item, intentional); return true; @@ -724,7 +726,7 @@ public void DoAttack(IEntity user, EntityCoordinates coordinates, bool wideAttac if (!ValidateInteractAndFace(user, coordinates)) return; - if (!ActionBlockerSystem.CanAttack(user)) + if (!Get().CanAttack(user)) return; IEntity? targetEnt = null; diff --git a/Content.Server/Inventory/Components/InventoryComponent.cs b/Content.Server/Inventory/Components/InventoryComponent.cs index 470fa841520..b7113eb0e5c 100644 --- a/Content.Server/Inventory/Components/InventoryComponent.cs +++ b/Content.Server/Inventory/Components/InventoryComponent.cs @@ -13,8 +13,8 @@ using Content.Shared.Acts; using Content.Shared.EffectBlocker; using Content.Shared.Inventory; +using Content.Shared.Inventory.Events; using Content.Shared.Movement.Components; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.Console; @@ -291,7 +291,7 @@ public bool CanEquip(Slots slot, ItemComponent item, bool mobCheck, [NotNullWhen var pass = false; reason = null; - if (mobCheck && !ActionBlockerSystem.CanEquip(Owner)) + if (mobCheck && !EntitySystem.Get().CanEquip(Owner)) { reason = Loc.GetString("You can't equip this!"); return false; @@ -417,7 +417,7 @@ public void ForceUnequip(Slots slot) /// public bool CanUnequip(Slots slot, bool mobCheck = true) { - if (mobCheck && !ActionBlockerSystem.CanUnequip(Owner)) + if (mobCheck && !EntitySystem.Get().CanUnequip(Owner)) return false; var inventorySlot = _slotContainers[slot]; diff --git a/Content.Server/Items/ItemComponent.cs b/Content.Server/Items/ItemComponent.cs index 3024b3fdbc9..fd179626ec7 100644 --- a/Content.Server/Items/ItemComponent.cs +++ b/Content.Server/Items/ItemComponent.cs @@ -1,6 +1,7 @@ #nullable enable using Content.Server.Hands.Components; using Content.Shared.ActionBlocker; +using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -52,7 +53,7 @@ public sealed class PickUpVerb : Verb { protected override void GetData(IEntity user, ItemComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || + if (!EntitySystem.Get().CanInteract(user) || component.Owner.IsInContainer() || !component.CanPickup(user)) { diff --git a/Content.Server/Light/Components/ExpendableLightComponent.cs b/Content.Server/Light/Components/ExpendableLightComponent.cs index fb25d315ea2..755fbe8e7aa 100644 --- a/Content.Server/Light/Components/ExpendableLightComponent.cs +++ b/Content.Server/Light/Components/ExpendableLightComponent.cs @@ -3,6 +3,7 @@ using Content.Server.Sound; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Light.Component; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -192,7 +193,7 @@ public sealed class ActivateVerb : Verb { protected override void GetData(IEntity user, ExpendableLightComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index b1fe18ea89a..975ca2d9a46 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -9,8 +9,8 @@ using Content.Shared.Actions.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Light.Component; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Rounding; using Content.Shared.Verbs; @@ -75,7 +75,7 @@ public override void OnRemove() async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) return false; + if (!EntitySystem.Get().CanInteract(eventArgs.User)) return false; if (!_cellSlot.InsertCell(eventArgs.Using)) return false; Dirty(); return true; @@ -104,7 +104,7 @@ bool IUse.UseEntity(UseEntityEventArgs eventArgs) /// True if the light's status was toggled, false otherwise. public bool ToggleStatus(IEntity user) { - if (!ActionBlockerSystem.CanUse(user)) return false; + if (!EntitySystem.Get().CanUse(user)) return false; return Activated ? TurnOff() : TurnOn(user); } @@ -250,7 +250,7 @@ public sealed class ToggleLightVerb : Verb { protected override void GetData(IEntity user, HandheldLightComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs index d707e9c1621..fa7aa3c5ad8 100644 --- a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs +++ b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs @@ -3,6 +3,7 @@ using Content.Server.Storage.Components; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using JetBrains.Annotations; using Robust.Shared.GameObjects; @@ -22,7 +23,7 @@ public override void Initialize() private void HandleAfterInteract(EntityUid uid, LightReplacerComponent component, AfterInteractEvent eventArgs) { // standard interaction checks - if (!ActionBlockerSystem.CanUse(eventArgs.User)) return; + if (!EntitySystem.Get().CanUse(eventArgs.User)) return; if (!eventArgs.CanReach) return; // behaviour will depends on target type @@ -40,7 +41,7 @@ private void HandleAfterInteract(EntityUid uid, LightReplacerComponent component private void HandleInteract(EntityUid uid, LightReplacerComponent component, InteractUsingEvent eventArgs) { // standard interaction checks - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) return; + if (!Get().CanInteract(eventArgs.User)) return; if (eventArgs.Used != null) { diff --git a/Content.Server/MachineLinking/Components/SignalSwitchComponent.cs b/Content.Server/MachineLinking/Components/SignalSwitchComponent.cs index da6c1539a10..12ba0370e03 100644 --- a/Content.Server/MachineLinking/Components/SignalSwitchComponent.cs +++ b/Content.Server/MachineLinking/Components/SignalSwitchComponent.cs @@ -1,7 +1,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.MachineLinking; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -72,7 +72,7 @@ protected override void Activate(IEntity user, SignalSwitchComponent component) protected override void GetData(IEntity user, SignalSwitchComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Medical/Components/HealingComponent.cs b/Content.Server/Medical/Components/HealingComponent.cs index 58558e7f78c..2d523bec285 100644 --- a/Content.Server/Medical/Components/HealingComponent.cs +++ b/Content.Server/Medical/Components/HealingComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; using Content.Shared.Stacks; using Robust.Shared.GameObjects; @@ -31,7 +32,7 @@ async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) return true; } - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) { return true; } diff --git a/Content.Server/Medical/Components/MedicalScannerComponent.cs b/Content.Server/Medical/Components/MedicalScannerComponent.cs index 1b067af2c22..0638f622bde 100644 --- a/Content.Server/Medical/Components/MedicalScannerComponent.cs +++ b/Content.Server/Medical/Components/MedicalScannerComponent.cs @@ -81,7 +81,7 @@ public override void HandleMessage(ComponentMessage message, IComponent? compone { case RelayMovementEntityMessage msg: { - if (ActionBlockerSystem.CanInteract(msg.Entity)) + if (EntitySystem.Get().CanInteract(msg.Entity)) { if (_gameTiming.CurTime < _lastInternalOpenAttempt + InternalOpenAttemptDelay) @@ -210,7 +210,7 @@ public sealed class EnterVerb : Verb { protected override void GetData(IEntity user, MedicalScannerComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -231,7 +231,7 @@ public sealed class EjectVerb : Verb { protected override void GetData(IEntity user, MedicalScannerComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Metabolism/MetabolismComponent.cs b/Content.Server/Metabolism/MetabolismComponent.cs index 7fbb8296fa4..2e0bc2f94e2 100644 --- a/Content.Server/Metabolism/MetabolismComponent.cs +++ b/Content.Server/Metabolism/MetabolismComponent.cs @@ -13,8 +13,8 @@ using Content.Shared.Body.Components; using Content.Shared.Damage; using Content.Shared.Damage.Components; +using Content.Shared.Metabolism.Events; using Content.Shared.MobState; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -271,9 +271,11 @@ private void ProcessThermalRegulation(float frameTime) } + var actionBlocker = EntitySystem.Get(); + if (temperatureComponent.CurrentTemperature > NormalBodyTemperature) { - if (!ActionBlockerSystem.CanSweat(Owner)) return; + if (!actionBlocker.CanSweat(Owner)) return; if (!_isSweating) { Owner.PopupMessage(Loc.GetString("You are sweating")); @@ -288,7 +290,7 @@ private void ProcessThermalRegulation(float frameTime) } else { - if (!ActionBlockerSystem.CanShiver(Owner)) return; + if (!actionBlocker.CanShiver(Owner)) return; if (!_isShivering) { Owner.PopupMessage(Loc.GetString("You are shivering")); diff --git a/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs b/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs index ac64b1b9adc..1231273140a 100644 --- a/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/BodyBagEntityStorageComponent.cs @@ -9,8 +9,8 @@ using Content.Shared.Body.Components; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Morgue; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Server.GameObjects; @@ -107,7 +107,7 @@ private sealed class RemoveLabelVerb : Verb { protected override void GetData(IEntity user, BodyBagEntityStorageComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || component.LabelContainer?.ContainedEntity == null) + if (!EntitySystem.Get().CanInteract(user) || component.LabelContainer?.ContainedEntity == null) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs index 5c1ca7e9368..cc0753483e5 100644 --- a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs @@ -9,8 +9,8 @@ using Content.Shared.ActionBlocker; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Morgue; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Standing; using Content.Shared.Verbs; @@ -152,7 +152,7 @@ private sealed class CremateVerb : Verb { protected override void GetData(IEntity user, CrematoriumEntityStorageComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || component.Cooking || component.Open) + if (!EntitySystem.Get().CanInteract(user) || component.Cooking || component.Open) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/PDA/PDAComponent.cs b/Content.Server/PDA/PDAComponent.cs index f4bddd439f2..4f1713ce266 100644 --- a/Content.Server/PDA/PDAComponent.cs +++ b/Content.Server/PDA/PDAComponent.cs @@ -11,7 +11,7 @@ using Content.Server.UserInterface; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.PDA; using Content.Shared.Tag; @@ -370,7 +370,7 @@ public sealed class EjectIDVerb : Verb { protected override void GetData(IEntity user, PDAComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -392,7 +392,7 @@ public sealed class EjectPenVerb : Verb { protected override void GetData(IEntity user, PDAComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -414,7 +414,7 @@ public sealed class ToggleFlashlightVerb : Verb { protected override void GetData(IEntity user, PDAComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index b4afe2ab346..931c3fa87ba 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -11,6 +11,7 @@ using Content.Server.Wires.Components; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Singularity.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; @@ -150,7 +151,7 @@ private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage obj if (obj.Session.AttachedEntity == null || - !ActionBlockerSystem.CanInteract(obj.Session.AttachedEntity)) + !EntitySystem.Get().CanInteract(obj.Session.AttachedEntity)) { return; } diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index f4c1e0b8915..e3f24a800f4 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -1,6 +1,5 @@ #nullable enable using System.Collections.Generic; -using Content.Server.Actions; using Content.Server.Inventory.Components; using Content.Server.Items; using Content.Server.Movement.Components; @@ -8,8 +7,8 @@ using Content.Shared.Audio; using Content.Shared.Inventory; using Content.Shared.Maps; +using Content.Shared.Movement; using Content.Shared.Movement.Components; -using Content.Shared.Physics.Controllers; using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Shared.Audio; diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 0fa783f2643..6ce69a2f5ba 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -7,8 +7,8 @@ using Content.Server.Visible; using Content.Shared.ActionBlocker; using Content.Shared.Input; +using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Helpers; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -112,7 +112,7 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUi return false; } - if (ActionBlockerSystem.CanChangeDirection(player)) + if (EntitySystem.Get().CanChangeDirection(player)) { var diff = coords.ToMapPos(EntityManager) - player.Transform.MapPosition.Position; if (diff.LengthSquared > 0.01f) @@ -137,7 +137,7 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUi if (ent is null || (!ent.TryGetComponent(out var eyeComp) || (eyeComp.VisibilityMask & layer) != 0)) return false; - + return ent.Transform.MapPosition.InRange(player.Transform.MapPosition, PointingRange); }); diff --git a/Content.Server/Power/Components/BaseCharger.cs b/Content.Server/Power/Components/BaseCharger.cs index 71be0a02ddf..92c2a1813e0 100644 --- a/Content.Server/Power/Components/BaseCharger.cs +++ b/Content.Server/Power/Components/BaseCharger.cs @@ -7,7 +7,7 @@ using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Power; using Content.Shared.Verbs; @@ -121,7 +121,7 @@ private sealed class InsertVerb : Verb { protected override void GetData(IEntity user, BaseCharger component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -166,7 +166,7 @@ private sealed class EjectVerb : Verb { protected override void GetData(IEntity user, BaseCharger component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs index 8f0e8f16e0c..5a47895fd39 100644 --- a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Audio; using Content.Shared.Examine; +using Content.Shared.Interaction.Events; using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -180,7 +181,7 @@ public sealed class EjectCellVerb : Verb { protected override void GetData(IEntity user, PowerCellSlotComponent component, VerbData data) { - if (!component.ShowVerb || !ActionBlockerSystem.CanInteract(user)) + if (!component.ShowVerb || !EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Rotation/Components/FlippableComponent.cs b/Content.Server/Rotation/Components/FlippableComponent.cs index f1b11e1cee7..8a21e85f303 100644 --- a/Content.Server/Rotation/Components/FlippableComponent.cs +++ b/Content.Server/Rotation/Components/FlippableComponent.cs @@ -1,6 +1,6 @@ #nullable enable using Content.Shared.ActionBlocker; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Robust.Shared.GameObjects; @@ -44,7 +44,7 @@ private sealed class FlippableVerb : Verb { protected override void GetData(IEntity user, FlippableComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Rotation/Components/RotatableComponent.cs b/Content.Server/Rotation/Components/RotatableComponent.cs index 5c91279a54c..c2679fa90e4 100644 --- a/Content.Server/Rotation/Components/RotatableComponent.cs +++ b/Content.Server/Rotation/Components/RotatableComponent.cs @@ -1,6 +1,6 @@ #nullable enable using Content.Shared.ActionBlocker; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Rotatable; using Content.Shared.Verbs; @@ -34,7 +34,7 @@ public sealed class RotateVerb : Verb { protected override void GetData(IEntity user, RotatableComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysBody? physics) && physics.BodyType == BodyType.Static)) + if (!EntitySystem.Get().CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysBody? physics) && physics.BodyType == BodyType.Static)) { data.Visibility = VerbVisibility.Invisible; return; @@ -56,7 +56,7 @@ public sealed class RotateCounterVerb : Verb { protected override void GetData(IEntity user, RotatableComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysBody? physics) && physics.BodyType == BodyType.Static)) + if (!EntitySystem.Get().CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysBody? physics) && physics.BodyType == BodyType.Static)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index 60589c739bc..d91bd1ce6cc 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -447,7 +447,7 @@ private sealed class OpenToggleVerb : Verb { protected override void GetData(IEntity user, EntityStorageComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -465,7 +465,7 @@ protected override void Activate(IEntity user, EntityStorageComponent component) protected virtual void OpenVerbGetData(IEntity user, EntityStorageComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Storage/Components/SecureEntityStorageComponent.cs b/Content.Server/Storage/Components/SecureEntityStorageComponent.cs index 0f01a44ed73..840026e6c3f 100644 --- a/Content.Server/Storage/Components/SecureEntityStorageComponent.cs +++ b/Content.Server/Storage/Components/SecureEntityStorageComponent.cs @@ -1,7 +1,7 @@ using Content.Server.Access.Components; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Storage; using Content.Shared.Verbs; @@ -130,7 +130,7 @@ private sealed class ToggleLockVerb : Verb { protected override void GetData(IEntity user, SecureEntityStorageComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || component.Open) + if (!EntitySystem.Get().CanInteract(user) || component.Open) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Strip/StrippableComponent.cs b/Content.Server/Strip/StrippableComponent.cs index fb3ba9a38a6..7c933e2775e 100644 --- a/Content.Server/Strip/StrippableComponent.cs +++ b/Content.Server/Strip/StrippableComponent.cs @@ -9,7 +9,7 @@ using Content.Server.UserInterface; using Content.Shared.ActionBlocker; using Content.Shared.DragDrop; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Strip.Components; using Content.Shared.Verbs; @@ -29,7 +29,7 @@ public sealed class StrippableComponent : SharedStrippableComponent public const float StripDelay = 2f; [ViewVariables] - private BoundUserInterface? UserInterface => Owner.GetUIOrNull(StrippingUiKey.Key); + private BoundUserInterface? UserInterface => Owner.GetUIOrNull(StrippingUiKey.Key); public override void Initialize() { @@ -152,7 +152,7 @@ private async void PlaceActiveHandItemInInventory(IEntity user, Slots slot) bool Check() { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) return false; if (item == null) @@ -217,7 +217,7 @@ private async void PlaceActiveHandItemInHands(IEntity user, string hand) bool Check() { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) return false; if (item == null) @@ -280,7 +280,7 @@ private async void TakeItemFromInventory(IEntity user, Slots slot) bool Check() { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) return false; if (!inventory.HasSlot(slot)) @@ -336,7 +336,7 @@ private async void TakeItemFromHands(IEntity user, string hand) bool Check() { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) return false; if (!hands.HasHand(hand)) diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index 95bd066ff55..683d44ebfb4 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -7,7 +7,7 @@ using Content.Shared.Audio; using Content.Shared.Examine; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Throwing; using Robust.Server.GameObjects; @@ -68,7 +68,9 @@ private void OnMeleeInteract(EntityUid uid, StunbatonComponent comp, MeleeIntera private void OnUseInHand(EntityUid uid, StunbatonComponent comp, UseInHandEvent args) { - if (!ActionBlockerSystem.CanUse(args.User)) return; + if (!Get().CanUse(args.User)) + return; + if (comp.Activated) { TurnOff(comp); @@ -97,7 +99,9 @@ private void OnPowerCellChanged(EntityUid uid, StunbatonComponent comp, PowerCel private void OnInteractUsing(EntityUid uid, StunbatonComponent comp, InteractUsingEvent args) { - if (!ActionBlockerSystem.CanInteract(args.User)) return; + if (!Get().CanInteract(args.User)) + return; + if (ComponentManager.TryGetComponent(uid, out var cellslot)) cellslot.InsertCell(args.Used); } diff --git a/Content.Server/Tools/Components/ToolComponent.cs b/Content.Server/Tools/Components/ToolComponent.cs index a224166199f..63e13453283 100644 --- a/Content.Server/Tools/Components/ToolComponent.cs +++ b/Content.Server/Tools/Components/ToolComponent.cs @@ -3,6 +3,7 @@ using Content.Server.DoAfter; using Content.Shared.ActionBlocker; using Content.Shared.Audio; +using Content.Shared.Interaction.Events; using Content.Shared.Tool; using Robust.Shared.Audio; using Robust.Shared.GameObjects; @@ -67,7 +68,7 @@ public bool HasQuality(ToolQuality quality) public virtual async Task UseTool(IEntity user, IEntity? target, float doAfterDelay, ToolQuality toolQualityNeeded, Func? doAfterCheck = null) { - if (!HasQuality(toolQualityNeeded) || !ActionBlockerSystem.CanInteract(user)) + if (!HasQuality(toolQualityNeeded) || !EntitySystem.Get().CanInteract(user)) return false; if (doAfterDelay > 0f) diff --git a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs index 6de341f7b4c..c3bf31b83fc 100644 --- a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs +++ b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs @@ -7,7 +7,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Examine; using Content.Shared.Interaction; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; @@ -222,7 +222,7 @@ private sealed class DumpVerb : Verb { protected override void GetData(IEntity user, AmmoBoxComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs index 71d957829d7..b540a59328a 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs @@ -4,8 +4,8 @@ using Content.Shared.ActionBlocker; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; @@ -354,7 +354,7 @@ private sealed class OpenBoltVerb : Verb { protected override void GetData(IEntity user, BoltActionBarrelComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -375,7 +375,7 @@ private sealed class CloseBoltVerb : Verb { protected override void GetData(IEntity user, BoltActionBarrelComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs index 9f2a1433d01..bed6955dd14 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs @@ -3,8 +3,8 @@ using Content.Server.Weapon.Ranged.Ammunition.Components; using Content.Shared.ActionBlocker; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; @@ -283,7 +283,7 @@ private sealed class SpinRevolverVerb : Verb { protected override void GetData(IEntity user, RevolverBarrelComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs index 8e69d38b3ec..aa99dec5cc6 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs @@ -8,6 +8,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Damage; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Barrels.Components; @@ -295,7 +296,7 @@ public sealed class EjectCellVerb : Verb { protected override void GetData(IEntity user, ServerBatteryBarrelComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user) || !component._powerCellRemovable) + if (!EntitySystem.Get().CanInteract(user) || !component._powerCellRemovable) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs index ed7fe68fd85..877e9154478 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs @@ -7,8 +7,8 @@ using Content.Shared.ActionBlocker; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged; @@ -453,7 +453,7 @@ private sealed class EjectMagazineVerb : Verb { protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -483,7 +483,7 @@ private sealed class OpenBoltVerb : Verb { protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; @@ -504,7 +504,7 @@ private sealed class CloseBoltVerb : Verb { protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs index b50d22e4fd6..05306696ff1 100644 --- a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -9,7 +9,7 @@ using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.Hands; -using Content.Shared.Notification; +using Content.Shared.Interaction.Events; using Content.Shared.Notification.Managers; using Content.Shared.Weapons.Ranged.Components; using Robust.Shared.Audio; @@ -78,7 +78,7 @@ private bool WeaponCanFire() private bool UserCanFire(IEntity user) { - return (UserCanFireHandler == null || UserCanFireHandler(user)) && ActionBlockerSystem.CanAttack(user); + return (UserCanFireHandler == null || UserCanFireHandler(user)) && EntitySystem.Get().CanInteract(user); } /// diff --git a/Content.Shared/ActionBlocker/ActionBlockerExtensions.cs b/Content.Shared/ActionBlocker/ActionBlockerExtensions.cs deleted file mode 100644 index 53acf763ea1..00000000000 --- a/Content.Shared/ActionBlocker/ActionBlockerExtensions.cs +++ /dev/null @@ -1,78 +0,0 @@ -#nullable enable -using Robust.Shared.GameObjects; - -namespace Content.Shared.ActionBlocker -{ - public static class ActionBlockerExtensions - { - public static bool CanMove(this IEntity entity) - { - return ActionBlockerSystem.CanMove(entity); - } - - public static bool CanInteract(this IEntity entity) - { - return ActionBlockerSystem.CanInteract(entity); - } - - public static bool CanUse(this IEntity entity) - { - return ActionBlockerSystem.CanUse(entity); - } - - public static bool CanThrow(this IEntity entity) - { - return ActionBlockerSystem.CanThrow(entity); - } - - public static bool CanSpeak(this IEntity entity) - { - return ActionBlockerSystem.CanSpeak(entity); - } - - public static bool CanDrop(this IEntity entity) - { - return ActionBlockerSystem.CanDrop(entity); - } - - public static bool CanPickup(this IEntity entity) - { - return ActionBlockerSystem.CanPickup(entity); - } - - public static bool CanEmote(this IEntity entity) - { - return ActionBlockerSystem.CanEmote(entity); - } - - public static bool CanAttack(this IEntity entity) - { - return ActionBlockerSystem.CanAttack(entity); - } - - public static bool CanEquip(this IEntity entity) - { - return ActionBlockerSystem.CanEquip(entity); - } - - public static bool CanUnequip(this IEntity entity) - { - return ActionBlockerSystem.CanUnequip(entity); - } - - public static bool CanChangeDirection(this IEntity entity) - { - return ActionBlockerSystem.CanChangeDirection(entity); - } - - public static bool CanShiver(this IEntity entity) - { - return ActionBlockerSystem.CanShiver(entity); - } - - public static bool CanSweat(this IEntity entity) - { - return ActionBlockerSystem.CanSweat(entity); - } - } -} diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index 9f01bc92349..b0a7dd0580c 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -1,8 +1,14 @@ #nullable enable -using System.Diagnostics.CodeAnalysis; +using Content.Shared.DragDrop; using Content.Shared.EffectBlocker; using Content.Shared.Emoting; +using Content.Shared.Interaction.Events; +using Content.Shared.Inventory.Events; +using Content.Shared.Item; +using Content.Shared.Metabolism.Events; +using Content.Shared.Movement; using Content.Shared.Speech; +using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.GameObjects; @@ -15,184 +21,254 @@ namespace Content.Shared.ActionBlocker [UsedImplicitly] public class ActionBlockerSystem : EntitySystem { - public static bool CanMove(IEntity entity) + public bool CanMove(IEntity entity) { - var canMove = true; + var ev = new MovementAttemptEvent(entity); + + RaiseLocalEvent(entity.Uid, ev); foreach (var blocker in entity.GetAllComponents()) { - canMove &= blocker.CanMove(); // Sets var to false if false + if (!blocker.CanMove()) + { + ev.Cancel(); + break; + } } - return canMove; + return !ev.Cancelled; } - public static bool CanInteract([NotNullWhen(true)] IEntity? entity) + public bool CanInteract(IEntity entity) { - if (entity == null) - { - return false; - } + var ev = new InteractionAttemptEvent(entity); - var canInteract = true; + RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in entity.GetAllComponents()) + foreach (var blocker in ev.Entity.GetAllComponents()) { - canInteract &= blocker.CanInteract(); + if (!blocker.CanInteract()) + { + ev.Cancel(); + break; + } } - return canInteract; + return !ev.Cancelled; } - public static bool CanUse([NotNullWhen(true)] IEntity? entity) + public bool CanUse(IEntity entity) { - if (entity == null) - { - return false; - } + var ev = new UseAttemptEvent(entity); - var canUse = true; + RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in entity.GetAllComponents()) + foreach (var blocker in ev.Entity.GetAllComponents()) { - canUse &= blocker.CanUse(); + if (!blocker.CanUse()) + { + ev.Cancel(); + break; + } } - return canUse; + return !ev.Cancelled; } - public static bool CanThrow(IEntity entity) + public bool CanThrow(IEntity entity) { - var canThrow = true; + var ev = new ThrowAttemptEvent(entity); - foreach (var blocker in entity.GetAllComponents()) + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canThrow &= blocker.CanThrow(); + if (!blocker.CanThrow()) + { + ev.Cancel(); + break; + } } - return canThrow; + return !ev.Cancelled; } - public static bool CanSpeak(IEntity entity) + public bool CanSpeak(IEntity entity) { - if (!entity.HasComponent()) - return false; + var ev = new SpeakAttemptEvent(entity); - var canSpeak = true; + RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in entity.GetAllComponents()) + foreach (var blocker in ev.Entity.GetAllComponents()) { - canSpeak &= blocker.CanSpeak(); + if (!blocker.CanSpeak()) + { + ev.Cancel(); + break; + } } - return canSpeak; + return !ev.Cancelled; } - public static bool CanDrop(IEntity entity) + public bool CanDrop(IEntity entity) { - var canDrop = true; + var ev = new DropAttemptEvent(entity); - foreach (var blocker in entity.GetAllComponents()) + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canDrop &= blocker.CanDrop(); + if (!blocker.CanDrop()) + { + ev.Cancel(); + break; + } } - return canDrop; + return !ev.Cancelled; } - public static bool CanPickup(IEntity entity) + public bool CanPickup(IEntity entity) { - var canPickup = true; + var ev = new PickupAttemptEvent(entity); - foreach (var blocker in entity.GetAllComponents()) + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canPickup &= blocker.CanPickup(); + if (!blocker.CanPickup()) + { + ev.Cancel(); + break; + } } - return canPickup; + return !ev.Cancelled; } - public static bool CanEmote(IEntity entity) + public bool CanEmote(IEntity entity) { - if (!entity.HasComponent()) - return false; + var ev = new EmoteAttemptEvent(entity); - var canEmote = true; + RaiseLocalEvent(entity.Uid, ev); - foreach (var blocker in entity.GetAllComponents()) + foreach (var blocker in ev.Entity.GetAllComponents()) { - canEmote &= blocker.CanEmote(); + if (!blocker.CanEmote()) + { + ev.Cancel(); + break; + } } - return canEmote; + return !ev.Cancelled; } - public static bool CanAttack(IEntity entity) + public bool CanAttack(IEntity entity) { - var canAttack = true; + var ev = new AttackAttemptEvent(entity); - foreach (var blocker in entity.GetAllComponents()) + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canAttack &= blocker.CanAttack(); + if (!blocker.CanAttack()) + { + ev.Cancel(); + break; + } } - return canAttack; + return !ev.Cancelled; } - public static bool CanEquip(IEntity entity) + public bool CanEquip(IEntity entity) { - var canEquip = true; + var ev = new EquipAttemptEvent(entity); - foreach (var blocker in entity.GetAllComponents()) + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canEquip &= blocker.CanEquip(); + if (!blocker.CanEquip()) + { + ev.Cancel(); + break; + } } - return canEquip; + return !ev.Cancelled; } - public static bool CanUnequip(IEntity entity) + public bool CanUnequip(IEntity entity) { - var canUnequip = true; + var ev = new UnequipAttemptEvent(entity); - foreach (var blocker in entity.GetAllComponents()) + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canUnequip &= blocker.CanUnequip(); + if (!blocker.CanUnequip()) + { + ev.Cancel(); + break; + } } - return canUnequip; + return !ev.Cancelled; } - public static bool CanChangeDirection(IEntity entity) + public bool CanChangeDirection(IEntity entity) { - var canChangeDirection = true; + var ev = new ChangeDirectionAttemptEvent(entity); - foreach (var blocker in entity.GetAllComponents()) + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canChangeDirection &= blocker.CanChangeDirection(); + if (!blocker.CanChangeDirection()) + { + ev.Cancel(); + break; + } } - return canChangeDirection; + return !ev.Cancelled; } - public static bool CanShiver(IEntity entity) + public bool CanShiver(IEntity entity) { - var canShiver = true; - foreach (var component in entity.GetAllComponents()) + var ev = new ShiverAttemptEvent(entity); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canShiver &= component.CanShiver(); + if (!blocker.CanShiver()) + { + ev.Cancel(); + break; + } } - return canShiver; + + return !ev.Cancelled; } - public static bool CanSweat(IEntity entity) + public bool CanSweat(IEntity entity) { - var canSweat = true; - foreach (var component in entity.GetAllComponents()) + var ev = new SweatAttemptEvent(entity); + + RaiseLocalEvent(entity.Uid, ev); + + foreach (var blocker in ev.Entity.GetAllComponents()) { - canSweat &= component.CanSweat(); + if (!blocker.CanSweat()) + { + ev.Cancel(); + break; + } } - return canSweat; + + return !ev.Cancelled; } } } diff --git a/Content.Shared/ActionBlocker/IActionBlocker.cs b/Content.Shared/ActionBlocker/IActionBlocker.cs index 6e69f3395bc..5415fb43acb 100644 --- a/Content.Shared/ActionBlocker/IActionBlocker.cs +++ b/Content.Shared/ActionBlocker/IActionBlocker.cs @@ -1,4 +1,5 @@ #nullable enable +using System; using Content.Shared.EffectBlocker; namespace Content.Shared.ActionBlocker @@ -7,34 +8,49 @@ namespace Content.Shared.ActionBlocker /// This interface gives components the ability to block certain actions from /// being done by the owning entity. For effects see /// + [Obsolete("Use events instead")] public interface IActionBlocker { + [Obsolete("Use MoveAttemptEvent instead")] bool CanMove() => true; + [Obsolete("Use InteractAttemptEvent instead")] bool CanInteract() => true; + [Obsolete("Use UseAttemptEvent instead")] bool CanUse() => true; + [Obsolete("Use ThrowAttemptEvent instead")] bool CanThrow() => true; + [Obsolete("Use SpeakAttemptEvent instead")] bool CanSpeak() => true; + [Obsolete("Use DropAttemptEvent instead")] bool CanDrop() => true; + [Obsolete("Use PickupAttemptEvent instead")] bool CanPickup() => true; + [Obsolete("Use EmoteAttemptEvent instead")] bool CanEmote() => true; + [Obsolete("Use AttackAttemptEvent instead")] bool CanAttack() => true; + [Obsolete("Use EquipAttemptEvent instead")] bool CanEquip() => true; + [Obsolete("Use UnequipAttemptEvent instead")] bool CanUnequip() => true; + [Obsolete("Use ChangeDirectionAttemptEvent instead")] bool CanChangeDirection() => true; + [Obsolete("Use ShiverAttemptEvent instead")] bool CanShiver() => true; + [Obsolete("Use SweatAttemptEvent instead")] bool CanSweat() => true; } } diff --git a/Content.Shared/DragDrop/DropAttemptEvent.cs b/Content.Shared/DragDrop/DropAttemptEvent.cs new file mode 100644 index 00000000000..564093bafd8 --- /dev/null +++ b/Content.Shared/DragDrop/DropAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.DragDrop +{ + public class DropAttemptEvent : CancellableEntityEventArgs + { + public DropAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Emoting/EmoteAttemptEvent.cs b/Content.Shared/Emoting/EmoteAttemptEvent.cs new file mode 100644 index 00000000000..d2a749dee6a --- /dev/null +++ b/Content.Shared/Emoting/EmoteAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Emoting +{ + public class EmoteAttemptEvent : CancellableEntityEventArgs + { + public EmoteAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Emoting/EmoteSystem.cs b/Content.Shared/Emoting/EmoteSystem.cs new file mode 100644 index 00000000000..ef97cbf500e --- /dev/null +++ b/Content.Shared/Emoting/EmoteSystem.cs @@ -0,0 +1,22 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Emoting +{ + public class EmoteSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnEmoteAttempt); + } + + private void OnEmoteAttempt(EmoteAttemptEvent ev) + { + if (!ev.Entity.HasComponent()) + { + ev.Cancel(); + } + } + } +} diff --git a/Content.Shared/Physics/Controllers/SharedTileFrictionController.cs b/Content.Shared/Friction/SharedTileFrictionController.cs similarity index 98% rename from Content.Shared/Physics/Controllers/SharedTileFrictionController.cs rename to Content.Shared/Friction/SharedTileFrictionController.cs index 78f8b0511e9..3f7017232b7 100644 --- a/Content.Shared/Physics/Controllers/SharedTileFrictionController.cs +++ b/Content.Shared/Friction/SharedTileFrictionController.cs @@ -1,20 +1,19 @@ using System; using Content.Shared.CCVar; +using Content.Shared.Movement; using Content.Shared.Movement.Components; using JetBrains.Annotations; -using Robust.Shared; using Robust.Shared.Configuration; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; -using Robust.Shared.Physics; using Robust.Shared.Physics.Broadphase; using Robust.Shared.Physics.Controllers; using Robust.Shared.Physics.Dynamics; #nullable enable -namespace Content.Shared.Physics.Controllers +namespace Content.Shared.Friction { public sealed class SharedTileFrictionController : VirtualController { diff --git a/Content.Shared/Movement/Components/TileFrictionModifier.cs b/Content.Shared/Friction/TileFrictionModifier.cs similarity index 97% rename from Content.Shared/Movement/Components/TileFrictionModifier.cs rename to Content.Shared/Friction/TileFrictionModifier.cs index ad6affe8acc..922a795d71b 100644 --- a/Content.Shared/Movement/Components/TileFrictionModifier.cs +++ b/Content.Shared/Friction/TileFrictionModifier.cs @@ -8,7 +8,7 @@ using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; -namespace Content.Shared.Movement.Components +namespace Content.Shared.Friction { [RegisterComponent] public class SharedTileFrictionModifier : Component diff --git a/Content.Shared/Interaction/Events/AttackAttemptEvent.cs b/Content.Shared/Interaction/Events/AttackAttemptEvent.cs new file mode 100644 index 00000000000..0e1ed1a04ed --- /dev/null +++ b/Content.Shared/Interaction/Events/AttackAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Interaction.Events +{ + public class AttackAttemptEvent : CancellableEntityEventArgs + { + public AttackAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs b/Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs new file mode 100644 index 00000000000..0570cd7daf3 --- /dev/null +++ b/Content.Shared/Interaction/Events/ChangeDirectionAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Interaction.Events +{ + public class ChangeDirectionAttemptEvent : CancellableEntityEventArgs + { + public ChangeDirectionAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Interaction/Events/InteractionAttemptEvent.cs b/Content.Shared/Interaction/Events/InteractionAttemptEvent.cs new file mode 100644 index 00000000000..e5f41fb1a1e --- /dev/null +++ b/Content.Shared/Interaction/Events/InteractionAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Interaction.Events +{ + public class InteractionAttemptEvent : CancellableEntityEventArgs + { + public InteractionAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Interaction/Events/UseAttemptEvent.cs b/Content.Shared/Interaction/Events/UseAttemptEvent.cs new file mode 100644 index 00000000000..12cd6c84bfc --- /dev/null +++ b/Content.Shared/Interaction/Events/UseAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Interaction.Events +{ + public class UseAttemptEvent : CancellableEntityEventArgs + { + public UseAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Inventory/Events/EquipAttemptEvent.cs b/Content.Shared/Inventory/Events/EquipAttemptEvent.cs new file mode 100644 index 00000000000..4715489c26f --- /dev/null +++ b/Content.Shared/Inventory/Events/EquipAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Inventory.Events +{ + public class EquipAttemptEvent : CancellableEntityEventArgs + { + public EquipAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Inventory/Events/UnequipAttemptEvent.cs b/Content.Shared/Inventory/Events/UnequipAttemptEvent.cs new file mode 100644 index 00000000000..3e1592e75e8 --- /dev/null +++ b/Content.Shared/Inventory/Events/UnequipAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Inventory.Events +{ + public class UnequipAttemptEvent : CancellableEntityEventArgs + { + public UnequipAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Item/PickupAttemptEvent.cs b/Content.Shared/Item/PickupAttemptEvent.cs new file mode 100644 index 00000000000..d8e3164a3c7 --- /dev/null +++ b/Content.Shared/Item/PickupAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Item +{ + public class PickupAttemptEvent : CancellableEntityEventArgs + { + public PickupAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Item/SharedItemComponent.cs b/Content.Shared/Item/SharedItemComponent.cs index 9c17f8c7111..89112852749 100644 --- a/Content.Shared/Item/SharedItemComponent.cs +++ b/Content.Shared/Item/SharedItemComponent.cs @@ -112,7 +112,7 @@ public override void HandleComponentState(ComponentState? curState, ComponentSta /// public bool CanPickup(IEntity user) { - if (!ActionBlockerSystem.CanPickup(user)) + if (!EntitySystem.Get().CanPickup(user)) return false; if (user.Transform.MapID != Owner.Transform.MapID) diff --git a/Content.Shared/Metabolism/Events/ShiverAttemptEvent.cs b/Content.Shared/Metabolism/Events/ShiverAttemptEvent.cs new file mode 100644 index 00000000000..da05d74ffde --- /dev/null +++ b/Content.Shared/Metabolism/Events/ShiverAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Metabolism.Events +{ + public class ShiverAttemptEvent : CancellableEntityEventArgs + { + public ShiverAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Metabolism/Events/SweatAttemptEvent.cs b/Content.Shared/Metabolism/Events/SweatAttemptEvent.cs new file mode 100644 index 00000000000..b920639aff6 --- /dev/null +++ b/Content.Shared/Metabolism/Events/SweatAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Metabolism.Events +{ + public class SweatAttemptEvent : CancellableEntityEventArgs + { + public SweatAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Movement/SharedMobMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs similarity index 96% rename from Content.Shared/Movement/SharedMobMoverSystem.cs rename to Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs index 11293b30055..8a8cea08ab5 100644 --- a/Content.Shared/Movement/SharedMobMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs @@ -6,7 +6,7 @@ using Robust.Shared.Physics.Collision; using Robust.Shared.Physics.Dynamics; -namespace Content.Shared.Movement +namespace Content.Shared.Movement.EntitySystems { public sealed class SharedMobMoverSystem : EntitySystem { diff --git a/Content.Shared/Movement/SharedMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs similarity index 98% rename from Content.Shared/Movement/SharedMoverSystem.cs rename to Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs index 1ecf252ea11..86843d8ef33 100644 --- a/Content.Shared/Movement/SharedMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs @@ -9,7 +9,7 @@ using Robust.Shared.Maths; using Robust.Shared.Players; -namespace Content.Shared.Movement +namespace Content.Shared.Movement.EntitySystems { /// /// Handles converting inputs into movement. diff --git a/Content.Shared/Movement/MovementAttemptEvent.cs b/Content.Shared/Movement/MovementAttemptEvent.cs new file mode 100644 index 00000000000..058e3e40003 --- /dev/null +++ b/Content.Shared/Movement/MovementAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Movement +{ + public class MovementAttemptEvent : CancellableEntityEventArgs + { + public MovementAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Physics/Controllers/SharedMoverController.cs b/Content.Shared/Movement/SharedMoverController.cs similarity index 98% rename from Content.Shared/Physics/Controllers/SharedMoverController.cs rename to Content.Shared/Movement/SharedMoverController.cs index 179c1c83512..114000f3285 100644 --- a/Content.Shared/Physics/Controllers/SharedMoverController.cs +++ b/Content.Shared/Movement/SharedMoverController.cs @@ -11,7 +11,7 @@ using Robust.Shared.Physics.Broadphase; using Robust.Shared.Physics.Controllers; -namespace Content.Shared.Physics.Controllers +namespace Content.Shared.Movement { /// /// Handles player and NPC mob movement. @@ -105,7 +105,7 @@ public static bool UseMobMovement(SharedBroadPhaseSystem broadPhaseSystem, Physi { return (body.BodyStatus == BodyStatus.OnGround) & body.Owner.HasComponent() && - ActionBlockerSystem.CanMove(body.Owner) && + EntitySystem.Get().CanMove(body.Owner) && (!body.Owner.IsWeightless(body, mapManager: mapManager) || body.Owner.TryGetComponent(out SharedPlayerMobMoverComponent? mover) && IsAroundCollider(broadPhaseSystem, body.Owner.Transform, mover, body)); diff --git a/Content.Shared/Pulling/Components/SharedPullableComponent.cs b/Content.Shared/Pulling/Components/SharedPullableComponent.cs index 988b67b8f84..22180840c25 100644 --- a/Content.Shared/Pulling/Components/SharedPullableComponent.cs +++ b/Content.Shared/Pulling/Components/SharedPullableComponent.cs @@ -2,6 +2,7 @@ using System; using Content.Shared.ActionBlocker; using Content.Shared.Alert; +using Content.Shared.Movement; using Content.Shared.Movement.Components; using Content.Shared.NetIDs; using Content.Shared.Physics.Pull; @@ -365,7 +366,7 @@ public override void OnRemove() void IRelayMoveInput.MoveInputPressed(ICommonSession session) { var entity = session.AttachedEntity; - if (entity == null || !ActionBlockerSystem.CanMove(entity)) return; + if (entity == null || !EntitySystem.Get().CanMove(entity)) return; TryStopPull(); } } diff --git a/Content.Shared/Speech/SpeakAttemptEvent.cs b/Content.Shared/Speech/SpeakAttemptEvent.cs new file mode 100644 index 00000000000..7863781c1f4 --- /dev/null +++ b/Content.Shared/Speech/SpeakAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Speech +{ + public class SpeakAttemptEvent : CancellableEntityEventArgs + { + public SpeakAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/Content.Shared/Speech/SpeechSystem.cs b/Content.Shared/Speech/SpeechSystem.cs new file mode 100644 index 00000000000..3f0b1b32f5f --- /dev/null +++ b/Content.Shared/Speech/SpeechSystem.cs @@ -0,0 +1,22 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Speech +{ + public class SpeechSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnSpeakAttempt); + } + + private void OnSpeakAttempt(SpeakAttemptEvent ev) + { + if (!ev.Entity.HasComponent()) + { + ev.Cancel(); + } + } + } +} diff --git a/Content.Shared/Storage/SharedStorageComponent.cs b/Content.Shared/Storage/SharedStorageComponent.cs index b6d8ba66b54..52b9b0d2b1d 100644 --- a/Content.Shared/Storage/SharedStorageComponent.cs +++ b/Content.Shared/Storage/SharedStorageComponent.cs @@ -4,6 +4,7 @@ using System.Linq; using Content.Shared.ActionBlocker; using Content.Shared.DragDrop; +using Content.Shared.Interaction.Events; using Content.Shared.NetIDs; using Content.Shared.Placeable; using Robust.Shared.GameObjects; @@ -34,7 +35,7 @@ bool IDraggable.CanDrop(CanDropEvent args) bool IDraggable.Drop(DragDropEvent eventArgs) { - if (!ActionBlockerSystem.CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) { return false; } diff --git a/Content.Shared/Strip/Components/SharedStrippableComponent.cs b/Content.Shared/Strip/Components/SharedStrippableComponent.cs index 354b7539fd5..8a6e11d266e 100644 --- a/Content.Shared/Strip/Components/SharedStrippableComponent.cs +++ b/Content.Shared/Strip/Components/SharedStrippableComponent.cs @@ -4,6 +4,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.DragDrop; using Content.Shared.Hands.Components; +using Content.Shared.Interaction.Events; using Robust.Shared.GameObjects; using Robust.Shared.Serialization; using static Content.Shared.Inventory.EquipmentSlotDefines; @@ -18,7 +19,7 @@ public bool CanBeStripped(IEntity by) { return by != Owner && by.HasComponent() - && ActionBlockerSystem.CanInteract(by); + && EntitySystem.Get().CanInteract(by); } bool IDraggable.CanDrop(CanDropEvent args) diff --git a/Content.Shared/Throwing/ThrowAttemptEvent.cs b/Content.Shared/Throwing/ThrowAttemptEvent.cs new file mode 100644 index 00000000000..a862a8a82ed --- /dev/null +++ b/Content.Shared/Throwing/ThrowAttemptEvent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Throwing +{ + public class ThrowAttemptEvent : CancellableEntityEventArgs + { + public ThrowAttemptEvent(IEntity entity) + { + Entity = entity; + } + + public IEntity Entity { get; } + } +} diff --git a/SpaceStation14.sln.DotSettings b/SpaceStation14.sln.DotSettings index c3d5c9d7d92..53475c1f5ba 100644 --- a/SpaceStation14.sln.DotSettings +++ b/SpaceStation14.sln.DotSettings @@ -129,6 +129,7 @@ True True True + True True True True