From dc9f1022380213c6016ad621d8026d93f18ca1e0 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Fri, 31 May 2024 16:26:19 -0400 Subject: [PATCH 1/3] Decouple interactions from hands, cleanup old events, add new fears (#28393) * ok basic shit * second part * pretend it isn't real it can't hurt you. * :eye: :eye: * shadowcommander review --- Content.Client/Guidebook/GuidebookSystem.cs | 2 +- .../Tests/Buckle/BuckleTest.cs | 1 + .../Components/ActionBlocking/HandCuffTest.cs | 1 + .../Click/InteractionSystemTests.cs | 4 + .../Tests/Interaction/InteractionTest.cs | 1 + .../Tests/VendingMachineRestockTest.cs | 1 + .../Actions/ActionOnInteractSystem.cs | 2 +- .../Atmos/EntitySystems/FlammableSystem.cs | 2 +- .../Atmos/Monitor/Systems/AirAlarmSystem.cs | 3 + .../EntitySystems/GasPressurePumpSystem.cs | 3 + .../Binary/EntitySystems/GasValveSystem.cs | 4 + .../EntitySystems/GasVolumePumpSystem.cs | 3 + .../Trinary/EntitySystems/GasFilterSystem.cs | 3 + .../Trinary/EntitySystems/GasMixerSystem.cs | 3 + .../Unary/EntitySystems/GasCanisterSystem.cs | 3 + .../EntitySystems/GasOutletInjectorSystem.cs | 4 + .../CardboardBox/CardboardBoxSystem.cs | 19 ++- .../Systems/SignalSwitchSystem.cs | 2 +- .../Disposal/Mailing/MailingUnitSystem.cs | 3 + .../Unit/EntitySystems/DisposalUnitSystem.cs | 3 + Content.Server/Doors/Systems/AirlockSystem.cs | 3 + .../Explosion/EntitySystems/TriggerSystem.cs | 3 + .../Fluids/EntitySystems/AbsorbentSystem.cs | 8 +- Content.Server/Gatherable/GatherableSystem.cs | 8 +- .../Interaction/InteractionPopupSystem.cs | 3 + .../EntitySystems/HandheldLightSystem.cs | 2 +- .../EntitySystems/MechGrabberSystem.cs | 7 +- .../EntitySystems/SmokingSystem.Cigar.cs | 2 +- Content.Server/Pinpointer/PinpointerSystem.cs | 5 + .../Radiation/Systems/GeigerSystem.cs | 2 +- .../Radio/EntitySystems/JammerSystem.cs | 3 + .../Radio/EntitySystems/RadioDeviceSystem.cs | 6 + .../EntitySystems/RevenantSystem.Abilities.cs | 13 +- .../Shuttles/Systems/ThrusterSystem.cs | 5 + Content.Server/Tabletop/TabletopSystem.cs | 3 + .../Zombies/ZombieSystem.Transform.cs | 2 + .../ActionBlocker/ActionBlockerSystem.cs | 4 +- Content.Shared/Burial/BurialSystem.cs | 3 +- .../SharedSolutionContainerMixerSystem.cs | 4 + .../Systems/TwoWayLeverSystem.cs | 2 +- .../Doors/Systems/SharedDoorSystem.cs | 2 +- .../SharedHandsSystem.Interactions.cs | 14 ++ .../Interaction/ActivateInWorldEvent.cs | 37 +++++- .../Components/ComplexInteractionComponent.cs | 9 ++ .../Interaction/Events/UseAttemptEvent.cs | 9 +- Content.Shared/Interaction/InteractHand.cs | 54 -------- .../Interaction/SharedInteractionSystem.cs | 125 +++++++++++++----- Content.Shared/Lock/LockSystem.cs | 2 +- .../Mech/EntitySystems/SharedMechSystem.cs | 4 +- .../Projectiles/SharedProjectileSystem.cs | 2 +- .../SharedEntityStorageSystem.cs | 2 +- .../EntitySystems/SharedStorageSystem.cs | 2 +- .../Strip/SharedStrippableSystem.cs | 12 +- .../SubFloor/SharedTrayScannerSystem.cs | 4 + .../Systems/SwapTeleporterSystem.cs | 4 + .../Toilet/Systems/SharedToiletSystem.cs | 2 +- .../Systems/SharedToolSystem.MultipleTool.cs | 2 +- .../UserInterface/ActivatableUISystem.cs | 2 +- Content.Shared/Verbs/SharedVerbSystem.cs | 24 +--- .../Weapons/Misc/SharedGrapplingGunSystem.cs | 2 +- .../Misc/SharedTetherGunSystem.Force.cs | 3 + .../Weapons/Misc/SharedTetherGunSystem.cs | 3 + .../Systems/BatteryWeaponFireModesSystem.cs | 3 + .../Ranged/Systems/RechargeCycleAmmoSystem.cs | 3 + .../SharedGunSystem.ChamberMagazine.cs | 2 +- .../Mobs/Cyborgs/base_borg_chassis.yml | 1 + .../Prototypes/Entities/Mobs/NPCs/animals.yml | 1 + .../Prototypes/Entities/Mobs/NPCs/mimic.yml | 1 - .../Prototypes/Entities/Mobs/NPCs/xeno.yml | 1 + .../Entities/Mobs/Player/admin_ghost.yml | 1 + .../Entities/Mobs/Player/guardian.yml | 1 + .../Prototypes/Entities/Mobs/Species/base.yml | 3 + 72 files changed, 325 insertions(+), 167 deletions(-) create mode 100644 Content.Shared/Interaction/Components/ComplexInteractionComponent.cs diff --git a/Content.Client/Guidebook/GuidebookSystem.cs b/Content.Client/Guidebook/GuidebookSystem.cs index 0aa2c85142e..86dcf769424 100644 --- a/Content.Client/Guidebook/GuidebookSystem.cs +++ b/Content.Client/Guidebook/GuidebookSystem.cs @@ -148,7 +148,7 @@ private void OnGuidebookControlsTestInteractHand(EntityUid uid, GuidebookControl public void FakeClientActivateInWorld(EntityUid activated) { - var activateMsg = new ActivateInWorldEvent(GetGuidebookUser(), activated); + var activateMsg = new ActivateInWorldEvent(GetGuidebookUser(), activated, true); RaiseLocalEvent(activated, activateMsg); } diff --git a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs index 94572da4989..1b31fe38c28 100644 --- a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs +++ b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs @@ -29,6 +29,7 @@ public sealed partial class BuckleTest components: - type: Buckle - type: Hands + - type: ComplexInteraction - type: InputMover - type: Body prototype: Human diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs index 02245c783e8..2570e2246a6 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs @@ -22,6 +22,7 @@ public sealed class HandCuffTest components: - type: Cuffable - type: Hands + - type: ComplexInteraction - type: Body prototype: Human diff --git a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs index 456df3b2f31..6ac40e92a1e 100644 --- a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs +++ b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs @@ -4,6 +4,7 @@ using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; +using Content.Shared.Interaction.Components; using Content.Shared.Item; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -60,6 +61,7 @@ await server.WaitAssertion(() => { user = sEntities.SpawnEntity(null, coords); sEntities.EnsureComponent(user); + sEntities.EnsureComponent(user); handSys.AddHand(user, "hand", HandLocation.Left); target = sEntities.SpawnEntity(null, coords); item = sEntities.SpawnEntity(null, coords); @@ -193,6 +195,7 @@ await server.WaitAssertion(() => { user = sEntities.SpawnEntity(null, coords); sEntities.EnsureComponent(user); + sEntities.EnsureComponent(user); handSys.AddHand(user, "hand", HandLocation.Left); target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange - 0.1f, 0), mapId)); item = sEntities.SpawnEntity(null, coords); @@ -327,6 +330,7 @@ await server.WaitAssertion(() => { user = sEntities.SpawnEntity(null, coords); sEntities.EnsureComponent(user); + sEntities.EnsureComponent(user); handSys.AddHand(user, "hand", HandLocation.Left); target = sEntities.SpawnEntity(null, coords); item = sEntities.SpawnEntity(null, coords); diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs index f07f23d84c8..457d3e31920 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs @@ -139,6 +139,7 @@ public abstract partial class InteractionTest prototype: Aghost - type: DoAfter - type: Hands + - type: ComplexInteraction - type: MindContainer - type: Stripping - type: Puller diff --git a/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs b/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs index 5bfebfbd530..e067a27854f 100644 --- a/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs +++ b/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs @@ -27,6 +27,7 @@ public sealed class VendingMachineRestockTest : EntitySystem id: HumanVendingDummy components: - type: Hands + - type: ComplexInteraction - type: Body prototype: Human diff --git a/Content.Server/Actions/ActionOnInteractSystem.cs b/Content.Server/Actions/ActionOnInteractSystem.cs index b6eec0ce0f6..28685858592 100644 --- a/Content.Server/Actions/ActionOnInteractSystem.cs +++ b/Content.Server/Actions/ActionOnInteractSystem.cs @@ -39,7 +39,7 @@ private void OnMapInit(EntityUid uid, ActionOnInteractComponent component, MapIn private void OnActivate(EntityUid uid, ActionOnInteractComponent component, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; if (component.ActionEntities is not {} actionEnts) diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index cf6287d7001..0f6ce0780e4 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -156,7 +156,7 @@ private void OnInteractUsing(EntityUid uid, FlammableComponent flammable, Intera private void OnExtinguishActivateInWorld(EntityUid uid, ExtinguishOnInteractComponent component, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; if (!TryComp(uid, out FlammableComponent? flammable)) diff --git a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs index 04a9023c1dd..2f56142aa60 100644 --- a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs +++ b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs @@ -246,6 +246,9 @@ private void OnShutdown(EntityUid uid, AirAlarmComponent component, ComponentShu private void OnActivate(EntityUid uid, AirAlarmComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + if (TryComp(uid, out var panel) && panel.Open) { args.Handled = false; diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs index 83b7b67ba46..871c84e0588 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs @@ -103,6 +103,9 @@ private void OnPumpLeaveAtmosphere(EntityUid uid, GasPressurePumpComponent pump, private void OnPumpActivate(EntityUid uid, GasPressurePumpComponent pump, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs index ed7567428e1..4aeba2f8fe2 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs @@ -52,8 +52,12 @@ private void OnStartup(EntityUid uid, GasValveComponent component, ComponentStar private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + Toggle(uid, component); _audio.PlayPvs(component.ValveSound, uid, AudioParams.Default.WithVariation(0.25f)); + args.Handled = true; } public void Set(EntityUid uid, GasValveComponent component, bool value) diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs index cbcd1f4fa3b..d9fbeb474e2 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs @@ -133,6 +133,9 @@ private void OnVolumePumpLeaveAtmosphere(EntityUid uid, GasVolumePumpComponent p private void OnPumpActivate(EntityUid uid, GasVolumePumpComponent pump, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs index 007d304e98e..752d1e9eb83 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs @@ -99,6 +99,9 @@ private void OnFilterLeaveAtmosphere(EntityUid uid, GasFilterComponent filter, r private void OnFilterActivate(EntityUid uid, GasFilterComponent filter, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs index 4ab8572843b..178caeaa4a9 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs @@ -139,6 +139,9 @@ private void OnMixerLeaveAtmosphere(EntityUid uid, GasMixerComponent mixer, ref private void OnMixerActivate(EntityUid uid, GasMixerComponent mixer, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index 60ae230b1ba..29d00388b06 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -211,6 +211,9 @@ private void OnCanisterUpdated(EntityUid uid, GasCanisterComponent canister, ref private void OnCanisterActivate(EntityUid uid, GasCanisterComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + if (!TryComp(args.User, out var actor)) return; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs index 834a1dfb0b7..62039185170 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs @@ -33,8 +33,12 @@ private void OnMapInit(EntityUid uid, GasOutletInjectorComponent component, MapI private void OnActivate(EntityUid uid, GasOutletInjectorComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + component.Enabled = !component.Enabled; UpdateAppearance(uid, component); + args.Handled = true; } public void UpdateAppearance(EntityUid uid, GasOutletInjectorComponent component, AppearanceComponent? appearance = null) diff --git a/Content.Server/CardboardBox/CardboardBoxSystem.cs b/Content.Server/CardboardBox/CardboardBoxSystem.cs index b9c9427d5c8..836dc485d92 100644 --- a/Content.Server/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Server/CardboardBox/CardboardBoxSystem.cs @@ -36,7 +36,6 @@ public override void Initialize() SubscribeLocalEvent(AfterStorageClosed); SubscribeLocalEvent(OnGetAdditionalAccess); SubscribeLocalEvent(OnInteracted); - SubscribeLocalEvent(OnNoHandInteracted); SubscribeLocalEvent(OnEntInserted); SubscribeLocalEvent(OnEntRemoved); @@ -45,9 +44,18 @@ public override void Initialize() private void OnInteracted(EntityUid uid, CardboardBoxComponent component, ActivateInWorldEvent args) { + if (args.Handled) + return; + if (!TryComp(uid, out var box)) return; + if (!args.Complex) + { + if (box.Open || !box.Contents.Contains(args.User)) + return; + } + args.Handled = true; _storage.ToggleOpen(args.User, uid, box); @@ -58,15 +66,6 @@ private void OnInteracted(EntityUid uid, CardboardBoxComponent component, Activa } } - private void OnNoHandInteracted(EntityUid uid, CardboardBoxComponent component, InteractedNoHandEvent args) - { - //Free the mice please - if (!TryComp(uid, out var box) || box.Open || !box.Contents.Contains(args.User)) - return; - - _storage.OpenStorage(uid); - } - private void OnGetAdditionalAccess(EntityUid uid, CardboardBoxComponent component, ref GetAdditionalAccessEvent args) { if (component.Mover == null) diff --git a/Content.Server/DeviceLinking/Systems/SignalSwitchSystem.cs b/Content.Server/DeviceLinking/Systems/SignalSwitchSystem.cs index f6469d68b93..67fad29d934 100644 --- a/Content.Server/DeviceLinking/Systems/SignalSwitchSystem.cs +++ b/Content.Server/DeviceLinking/Systems/SignalSwitchSystem.cs @@ -26,7 +26,7 @@ private void OnInit(EntityUid uid, SignalSwitchComponent comp, ComponentInit arg private void OnActivated(EntityUid uid, SignalSwitchComponent comp, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; comp.State = !comp.State; diff --git a/Content.Server/Disposal/Mailing/MailingUnitSystem.cs b/Content.Server/Disposal/Mailing/MailingUnitSystem.cs index 8e9c9e4ba73..e1fbdbf0894 100644 --- a/Content.Server/Disposal/Mailing/MailingUnitSystem.cs +++ b/Content.Server/Disposal/Mailing/MailingUnitSystem.cs @@ -152,6 +152,9 @@ private void OnConfigurationUpdated(EntityUid uid, MailingUnitComponent componen private void HandleActivate(EntityUid uid, MailingUnitComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) { return; diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index 3c7636cfd07..0da72d87cbb 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -263,6 +263,9 @@ public void ToggleEngage(EntityUid uid, SharedDisposalUnitComponent component) private void OnActivate(EntityUid uid, SharedDisposalUnitComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + if (!TryComp(args.User, out ActorComponent? actor)) { return; diff --git a/Content.Server/Doors/Systems/AirlockSystem.cs b/Content.Server/Doors/Systems/AirlockSystem.cs index 71f9347e9ed..fd5d3a9ceba 100644 --- a/Content.Server/Doors/Systems/AirlockSystem.cs +++ b/Content.Server/Doors/Systems/AirlockSystem.cs @@ -67,6 +67,9 @@ private void OnPowerChanged(EntityUid uid, AirlockComponent component, ref Power private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + if (TryComp(uid, out var panel) && panel.Open && TryComp(args.User, out var actor)) diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index 8e0a75ea24f..999a85da5aa 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -218,6 +218,9 @@ private void OnSpawnTriggered(EntityUid uid, TriggerOnSpawnComponent component, private void OnActivate(EntityUid uid, TriggerOnActivateComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + Trigger(uid, args.User); args.Handled = true; } diff --git a/Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs b/Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs index 3d0996a3802..52afdcf8b49 100644 --- a/Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs +++ b/Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs @@ -35,7 +35,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnAbsorbentInit); SubscribeLocalEvent(OnAfterInteract); - SubscribeLocalEvent(OnInteractNoHand); + SubscribeLocalEvent(OnActivateInWorld); SubscribeLocalEvent(OnAbsorbentSolutionChange); } @@ -85,12 +85,12 @@ private void UpdateAbsorbent(EntityUid uid, AbsorbentComponent component) Dirty(uid, component); } - private void OnInteractNoHand(EntityUid uid, AbsorbentComponent component, InteractNoHandEvent args) + private void OnActivateInWorld(EntityUid uid, AbsorbentComponent component, UserActivateInWorldEvent args) { - if (args.Handled || args.Target == null) + if (args.Handled) return; - Mop(uid, args.Target.Value, uid, component); + Mop(uid, args.Target, uid, component); args.Handled = true; } diff --git a/Content.Server/Gatherable/GatherableSystem.cs b/Content.Server/Gatherable/GatherableSystem.cs index 7fbbf7f4f64..0a20e2dbc1f 100644 --- a/Content.Server/Gatherable/GatherableSystem.cs +++ b/Content.Server/Gatherable/GatherableSystem.cs @@ -38,10 +38,14 @@ private void OnAttacked(EntityUid uid, GatherableComponent component, AttackedEv private void OnActivate(EntityUid uid, GatherableComponent component, ActivateInWorldEvent args) { - if (component.ToolWhitelist?.IsValid(args.User, EntityManager) != true) + if (args.Handled || !args.Complex) return; - Gather(uid, args.User, component); + if (gatherable.Comp.ToolWhitelist?.IsValid(args.User, EntityManager) != true) + return; + + Gather(gatherable, args.User); + args.Handled = true; } public void Gather(EntityUid gatheredUid, EntityUid? gatherer = null, GatherableComponent? component = null) diff --git a/Content.Server/Interaction/InteractionPopupSystem.cs b/Content.Server/Interaction/InteractionPopupSystem.cs index a028598df03..c31f7d341f8 100644 --- a/Content.Server/Interaction/InteractionPopupSystem.cs +++ b/Content.Server/Interaction/InteractionPopupSystem.cs @@ -32,6 +32,9 @@ public override void Initialize() private void OnActivateInWorld(EntityUid uid, InteractionPopupComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + if (!component.OnActivate) return; diff --git a/Content.Server/Light/EntitySystems/HandheldLightSystem.cs b/Content.Server/Light/EntitySystems/HandheldLightSystem.cs index 813f8c407b7..a5a41bcc105 100644 --- a/Content.Server/Light/EntitySystems/HandheldLightSystem.cs +++ b/Content.Server/Light/EntitySystems/HandheldLightSystem.cs @@ -126,7 +126,7 @@ private void OnRemove(Entity ent, ref ComponentRemove ar private void OnActivate(Entity ent, ref ActivateInWorldEvent args) { - if (args.Handled || !ent.Comp.ToggleOnInteract) + if (args.Handled || !args.Complex || !ent.Comp.ToggleOnInteract) return; if (ToggleStatus(args.User, ent)) diff --git a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs index 0ade8928f9f..e04499e2abc 100644 --- a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs +++ b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs @@ -40,7 +40,7 @@ public override void Initialize() SubscribeLocalEvent(OnEquipmentRemoved); SubscribeLocalEvent(OnAttemptRemove); - SubscribeLocalEvent(OnInteract); + SubscribeLocalEvent(OnInteract); SubscribeLocalEvent(OnMechGrab); } @@ -124,10 +124,11 @@ private void OnUiStateReady(EntityUid uid, MechGrabberComponent component, MechE args.States.Add(GetNetEntity(uid), state); } - private void OnInteract(EntityUid uid, MechGrabberComponent component, InteractNoHandEvent args) + private void OnInteract(EntityUid uid, MechGrabberComponent component, UserActivateInWorldEvent args) { - if (args.Handled || args.Target is not {} target) + if (args.Handled) return; + var target = args.Target; if (args.Target == args.User || component.DoAfter != null) return; diff --git a/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs b/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs index 4e672444d18..510b9552a3d 100644 --- a/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs +++ b/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs @@ -18,7 +18,7 @@ private void InitializeCigars() private void OnCigarActivatedEvent(Entity entity, ref ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable)) diff --git a/Content.Server/Pinpointer/PinpointerSystem.cs b/Content.Server/Pinpointer/PinpointerSystem.cs index be9a715d5d5..eebf9cbbfde 100644 --- a/Content.Server/Pinpointer/PinpointerSystem.cs +++ b/Content.Server/Pinpointer/PinpointerSystem.cs @@ -45,10 +45,15 @@ private void UpdateAppearance(EntityUid uid, PinpointerComponent pinpointer, App private void OnActivate(EntityUid uid, PinpointerComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + TogglePinpointer(uid, component); if (!component.CanRetarget) LocateTarget(uid, component); + + args.Handled = true; } private void OnLocateTarget(ref FTLCompletedEvent ev) diff --git a/Content.Server/Radiation/Systems/GeigerSystem.cs b/Content.Server/Radiation/Systems/GeigerSystem.cs index 06e5911cb7c..df4438c91ea 100644 --- a/Content.Server/Radiation/Systems/GeigerSystem.cs +++ b/Content.Server/Radiation/Systems/GeigerSystem.cs @@ -35,7 +35,7 @@ public override void Initialize() private void OnActivate(Entity geiger, ref ActivateInWorldEvent args) { - if (args.Handled || geiger.Comp.AttachedToSuit) + if (args.Handled || !args.Complex || geiger.Comp.AttachedToSuit) return; args.Handled = true; diff --git a/Content.Server/Radio/EntitySystems/JammerSystem.cs b/Content.Server/Radio/EntitySystems/JammerSystem.cs index 6e0689390e1..4997430ac5f 100644 --- a/Content.Server/Radio/EntitySystems/JammerSystem.cs +++ b/Content.Server/Radio/EntitySystems/JammerSystem.cs @@ -68,6 +68,9 @@ public override void Update(float frameTime) private void OnActivate(EntityUid uid, RadioJammerComponent comp, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + var activated = !HasComp(uid) && _powerCell.TryGetBatteryFromSlot(uid, out var battery) && battery.CurrentCharge > GetCurrentWattage(comp); diff --git a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs index 6ade9aea34e..02e46e6b11d 100644 --- a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs @@ -83,6 +83,9 @@ private void OnSpeakerInit(EntityUid uid, RadioSpeakerComponent component, Compo #region Toggling private void OnActivateMicrophone(EntityUid uid, RadioMicrophoneComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + if (!component.ToggleOnInteract) return; @@ -92,6 +95,9 @@ private void OnActivateMicrophone(EntityUid uid, RadioMicrophoneComponent compon private void OnActivateSpeaker(EntityUid uid, RadioSpeakerComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + if (!component.ToggleOnInteract) return; diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs index 5d7c7514b84..4ee64fff6d3 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -43,7 +43,7 @@ public sealed partial class RevenantSystem private void InitializeAbilities() { - SubscribeLocalEvent(OnInteract); + SubscribeLocalEvent(OnInteract); SubscribeLocalEvent(OnSoulSearch); SubscribeLocalEvent(OnHarvest); @@ -53,11 +53,14 @@ private void InitializeAbilities() SubscribeLocalEvent(OnMalfunctionAction); } - private void OnInteract(EntityUid uid, RevenantComponent component, InteractNoHandEvent args) + private void OnInteract(EntityUid uid, RevenantComponent component, UserActivateInWorldEvent args) { - if (args.Target == args.User || args.Target == null) + if (args.Handled) + return; + + if (args.Target == args.User) return; - var target = args.Target.Value; + var target = args.Target; if (HasComp(target)) { @@ -78,6 +81,8 @@ private void OnInteract(EntityUid uid, RevenantComponent component, InteractNoHa { BeginHarvestDoAfter(uid, target, component, essence); } + + args.Handled = true; } private void BeginSoulSearchDoAfter(EntityUid uid, EntityUid target, RevenantComponent revenant) diff --git a/Content.Server/Shuttles/Systems/ThrusterSystem.cs b/Content.Server/Shuttles/Systems/ThrusterSystem.cs index 46715dd2916..2454856a701 100644 --- a/Content.Server/Shuttles/Systems/ThrusterSystem.cs +++ b/Content.Server/Shuttles/Systems/ThrusterSystem.cs @@ -132,15 +132,20 @@ private void OnShuttleTileChange(EntityUid uid, ShuttleComponent component, ref private void OnActivateThruster(EntityUid uid, ThrusterComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + component.Enabled ^= true; if (!component.Enabled) { DisableThruster(uid, component); + args.Handled = true; } else if (CanEnable(uid, component)) { EnableThruster(uid, component); + args.Handled = true; } } diff --git a/Content.Server/Tabletop/TabletopSystem.cs b/Content.Server/Tabletop/TabletopSystem.cs index 4376ec4bc61..caa319a0b71 100644 --- a/Content.Server/Tabletop/TabletopSystem.cs +++ b/Content.Server/Tabletop/TabletopSystem.cs @@ -141,6 +141,9 @@ private void AddPlayGameVerb(EntityUid uid, TabletopGameComponent component, Get private void OnTabletopActivate(EntityUid uid, TabletopGameComponent component, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + // Check that a player is attached to the entity. if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; diff --git a/Content.Server/Zombies/ZombieSystem.Transform.cs b/Content.Server/Zombies/ZombieSystem.Transform.cs index d90ceab0dca..9e294c6aa58 100644 --- a/Content.Server/Zombies/ZombieSystem.Transform.cs +++ b/Content.Server/Zombies/ZombieSystem.Transform.cs @@ -22,6 +22,7 @@ using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Humanoid; +using Content.Shared.Interaction.Components; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; @@ -107,6 +108,7 @@ public void ZombifyEntity(EntityUid target, MobStateComponent? mobState = null) RemComp(target); RemComp(target); RemComp(target); + RemComp(target); if (HasComp(target)) // Prevent psionic zombies { diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index 47b3997806d..d2883b5ef5b 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -96,9 +96,9 @@ public bool CanInteract(EntityUid user, EntityUid? target) /// involve using a held entity. In the majority of cases, systems that provide interactions will not need /// to check this themselves. /// - public bool CanUseHeldEntity(EntityUid user) + public bool CanUseHeldEntity(EntityUid user, EntityUid used) { - var ev = new UseAttemptEvent(user); + var ev = new UseAttemptEvent(user, used); RaiseLocalEvent(user, ev); return !ev.Cancelled; diff --git a/Content.Shared/Burial/BurialSystem.cs b/Content.Shared/Burial/BurialSystem.cs index 76336e13989..1116c6797b2 100644 --- a/Content.Shared/Burial/BurialSystem.cs +++ b/Content.Shared/Burial/BurialSystem.cs @@ -84,10 +84,11 @@ private void OnAfterInteractUsing(EntityUid uid, GraveComponent component, After private void OnActivate(EntityUid uid, GraveComponent component, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; _popupSystem.PopupClient(Loc.GetString("grave-digging-requires-tool", ("grave", args.Target)), uid, args.User); + args.Handled = true; } private void OnGraveDigging(EntityUid uid, GraveComponent component, GraveDiggingDoAfterEvent args) diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerMixerSystem.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerMixerSystem.cs index 87957066125..c8e8e89ce53 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerMixerSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerMixerSystem.cs @@ -31,7 +31,11 @@ public override void Initialize() private void OnActivateInWorld(Entity entity, ref ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + TryStartMix(entity, args.User); + args.Handled = true; } private void OnRemoveAttempt(Entity ent, ref ContainerIsRemovingAttemptEvent args) diff --git a/Content.Shared/DeviceLinking/Systems/TwoWayLeverSystem.cs b/Content.Shared/DeviceLinking/Systems/TwoWayLeverSystem.cs index c8783b05fc7..7e665dc1906 100644 --- a/Content.Shared/DeviceLinking/Systems/TwoWayLeverSystem.cs +++ b/Content.Shared/DeviceLinking/Systems/TwoWayLeverSystem.cs @@ -28,7 +28,7 @@ private void OnInit(EntityUid uid, TwoWayLeverComponent component, ComponentInit private void OnActivated(EntityUid uid, TwoWayLeverComponent component, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; component.State = component.State switch diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index b58b7b265e9..f62a1bc4c53 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -216,7 +216,7 @@ protected bool SetState(EntityUid uid, DoorState state, DoorComponent? door = nu #region Interactions protected void OnActivate(EntityUid uid, DoorComponent door, ActivateInWorldEvent args) { - if (args.Handled || !door.ClickOpen) + if (args.Handled || !args.Complex || !door.ClickOpen) return; if (!TryToggleDoor(uid, door, args.User, predicted: true)) diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs index 6d4d332479f..ae22efcd6a5 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs @@ -3,6 +3,7 @@ using Content.Shared.Hands.Components; using Content.Shared.IdentityManagement; using Content.Shared.Input; +using Content.Shared.Interaction; using Content.Shared.Inventory.VirtualItem; using Content.Shared.Localizations; using Robust.Shared.Input.Binding; @@ -23,6 +24,7 @@ private void InitializeInteractions() SubscribeAllEvent(HandleMoveItemFromHand); SubscribeAllEvent(HandleHandAltInteract); + SubscribeLocalEvent(OnGetUsedEntity); SubscribeLocalEvent(HandleExamined); CommandBinds.Builder @@ -181,6 +183,18 @@ public bool TryMoveHeldEntityToActiveHand(EntityUid uid, string handName, bool c return true; } + private void OnGetUsedEntity(EntityUid uid, HandsComponent component, ref GetUsedEntityEvent args) + { + if (args.Handled) + return; + + // TODO: this pattern is super uncommon, but it might be worth changing GetUsedEntityEvent to be recursive. + if (TryComp(component.ActiveHandEntity, out var virtualItem)) + args.Used = virtualItem.BlockingEntity; + else + args.Used = component.ActiveHandEntity; + } + //TODO: Actually shows all items/clothing/etc. private void HandleExamined(EntityUid examinedUid, HandsComponent handsComp, ExaminedEvent args) { diff --git a/Content.Shared/Interaction/ActivateInWorldEvent.cs b/Content.Shared/Interaction/ActivateInWorldEvent.cs index 9dbd636c48f..f7a1b7a799d 100644 --- a/Content.Shared/Interaction/ActivateInWorldEvent.cs +++ b/Content.Shared/Interaction/ActivateInWorldEvent.cs @@ -18,14 +18,49 @@ public sealed class ActivateInWorldEvent : HandledEntityEventArgs, ITargetedInte /// public EntityUid Target { get; } + /// + /// Whether or not can perform complex interactions or only basic ones. + /// + public bool Complex; + /// /// Set to true when the activation is logged by a specific logger. /// public bool WasLogged { get; set; } - public ActivateInWorldEvent(EntityUid user, EntityUid target) + public ActivateInWorldEvent(EntityUid user, EntityUid target, bool complex) + { + User = user; + Target = target; + Complex = complex; + } +} + +/// +/// Event raised on the user when it activates something in the world +/// +[PublicAPI] +public sealed class UserActivateInWorldEvent : HandledEntityEventArgs, ITargetedInteractEventArgs +{ + /// + /// Entity that activated the target world entity. + /// + public EntityUid User { get; } + + /// + /// Entity that was activated in the world. + /// + public EntityUid Target { get; } + + /// + /// Whether or not can perform complex interactions or only basic ones. + /// + public bool Complex; + + public UserActivateInWorldEvent(EntityUid user, EntityUid target, bool complex) { User = user; Target = target; + Complex = complex; } } diff --git a/Content.Shared/Interaction/Components/ComplexInteractionComponent.cs b/Content.Shared/Interaction/Components/ComplexInteractionComponent.cs new file mode 100644 index 00000000000..ae7d65de366 --- /dev/null +++ b/Content.Shared/Interaction/Components/ComplexInteractionComponent.cs @@ -0,0 +1,9 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Interaction.Components; + +/// +/// This is used for identifying entities as being able to use complex interactions with the environment. +/// +[RegisterComponent, NetworkedComponent, Access(typeof(SharedInteractionSystem))] +public sealed partial class ComplexInteractionComponent : Component; diff --git a/Content.Shared/Interaction/Events/UseAttemptEvent.cs b/Content.Shared/Interaction/Events/UseAttemptEvent.cs index 3db185ed172..c28f2b65177 100644 --- a/Content.Shared/Interaction/Events/UseAttemptEvent.cs +++ b/Content.Shared/Interaction/Events/UseAttemptEvent.cs @@ -1,12 +1,9 @@ namespace Content.Shared.Interaction.Events { - public sealed class UseAttemptEvent : CancellableEntityEventArgs + public sealed class UseAttemptEvent(EntityUid uid, EntityUid used) : CancellableEntityEventArgs { - public UseAttemptEvent(EntityUid uid) - { - Uid = uid; - } + public EntityUid Uid { get; } = uid; - public EntityUid Uid { get; } + public EntityUid Used = used; } } diff --git a/Content.Shared/Interaction/InteractHand.cs b/Content.Shared/Interaction/InteractHand.cs index 63ea3b6f30d..1d2df4c28b2 100644 --- a/Content.Shared/Interaction/InteractHand.cs +++ b/Content.Shared/Interaction/InteractHand.cs @@ -51,58 +51,4 @@ public BeforeInteractHandEvent(EntityUid target) Target = target; } } - - /// - /// Low-level interaction event used for entities without hands. - /// - /// - /// SHIT IS CURSED. - /// - //TODO: KILLLLLLL - public sealed class InteractNoHandEvent : HandledEntityEventArgs - { - /// - /// Entity that triggered the interaction. - /// - public EntityUid User; - - /// - /// Entity that was interacted on. - /// - public EntityUid? Target; - - public EntityCoordinates ClickLocation; - - public InteractNoHandEvent(EntityUid user, EntityUid? target, EntityCoordinates clickLocation) - { - User = user; - Target = target; - ClickLocation = clickLocation; - } - } - - /// - /// Reverse of the InteractNoHandEvent - raised on what was interacted on, rather than the other way around. - /// - public sealed class InteractedNoHandEvent : HandledEntityEventArgs - { - /// - /// Entity that was interacted on - /// - public EntityUid Target; - - /// - /// Entity that triggered this interaction - /// - public EntityUid User; - - public EntityCoordinates ClickLocation; - - public InteractedNoHandEvent(EntityUid target, EntityUid user, EntityCoordinates clickLocation) - { - Target = target; - User = user; - ClickLocation = clickLocation; - } - } } diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 2bc256fd6ad..8b296d8fe7d 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -76,6 +76,7 @@ public abstract partial class SharedInteractionSystem : EntitySystem private EntityQuery _wallMountQuery; private EntityQuery _delayQuery; private EntityQuery _uiQuery; + private EntityQuery _complexInteractionQuery; private const CollisionGroup InRangeUnobstructedMask = CollisionGroup.Impassable | CollisionGroup.InteractImpassable; @@ -98,6 +99,7 @@ public override void Initialize() _wallMountQuery = GetEntityQuery(); _delayQuery = GetEntityQuery(); _uiQuery = GetEntityQuery(); + _complexInteractionQuery = GetEntityQuery(); SubscribeLocalEvent(HandleUserInterfaceRangeCheck); SubscribeLocalEvent(OnBoundInterfaceInteractAttempt); @@ -364,8 +366,13 @@ public void UserInteraction( // TODO this needs to be handled better. This probably bypasses many complex can-interact checks in weird roundabout ways. if (_actionBlockerSystem.CanInteract(user, target)) { - UserInteraction(relay.RelayEntity.Value, coordinates, target, altInteract, checkCanInteract, - checkAccess, checkCanUse); + UserInteraction(relay.RelayEntity.Value, + coordinates, + target, + altInteract, + checkCanInteract, + checkAccess, + checkCanUse); return; } } @@ -402,25 +409,10 @@ public void UserInteraction( ? !checkAccess || InRangeUnobstructed(user, coordinates) : !checkAccess || InRangeUnobstructed(user, target.Value); // permits interactions with wall mounted entities - // Does the user have hands? - if (!_handsQuery.TryComp(user, out var hands) || hands.ActiveHand == null) - { - var ev = new InteractNoHandEvent(user, target, coordinates); - RaiseLocalEvent(user, ev); - - if (target != null) - { - var interactedEv = new InteractedNoHandEvent(target.Value, user, coordinates); - RaiseLocalEvent(target.Value, interactedEv); - DoContactInteraction(user, target.Value, ev); - } - return; - } - // empty-hand interactions // combat mode hand interactions will always be true here -- since // they check this earlier before returning in - if (hands.ActiveHandEntity is not { } held) + if (!TryGetUsedEntity(user, out var used, checkCanUse)) { if (inRangeUnobstructed && target != null) InteractHand(user, target.Value); @@ -428,11 +420,7 @@ public void UserInteraction( return; } - // Can the user use the held entity? - if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user)) - return; - - if (target == held) + if (target == used) { UseInHandInteraction(user, target.Value, checkCanUse: false, checkCanInteract: false); return; @@ -442,7 +430,7 @@ public void UserInteraction( { InteractUsing( user, - held, + used.Value, target.Value, coordinates, checkCanInteract: false, @@ -453,7 +441,7 @@ public void UserInteraction( InteractUsingRanged( user, - held, + used.Value, target, coordinates, inRangeUnobstructed); @@ -461,6 +449,18 @@ public void UserInteraction( public void InteractHand(EntityUid user, EntityUid target) { + var complexInteractions = SupportsComplexInteractions(user); + if (!complexInteractions) + { + InteractionActivate(user, + target, + checkCanInteract: false, + checkUseDelay: true, + checkAccess: false, + complexInteractions: complexInteractions); + return; + } + // allow for special logic before main interaction var ev = new BeforeInteractHandEvent(target); RaiseLocalEvent(user, ev); @@ -479,10 +479,12 @@ public void InteractHand(EntityUid user, EntityUid target) return; // Else we run Activate. - InteractionActivate(user, target, + InteractionActivate(user, + target, checkCanInteract: false, checkUseDelay: true, - checkAccess: false); + checkAccess: false, + complexInteractions: complexInteractions); } public void InteractUsingRanged(EntityUid user, EntityUid used, EntityUid? target, @@ -925,7 +927,7 @@ public void InteractUsing( if (checkCanInteract && !_actionBlockerSystem.CanInteract(user, target)) return; - if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user)) + if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user, used)) return; if (RangedInteractDoBefore(user, used, target, clickLocation, true)) @@ -1005,7 +1007,8 @@ public bool InteractionActivate( EntityUid used, bool checkCanInteract = true, bool checkUseDelay = true, - bool checkAccess = true) + bool checkAccess = true, + bool? complexInteractions = null) { _delayQuery.TryComp(used, out var delayComponent); if (checkUseDelay && delayComponent != null && _useDelay.IsDelayed((used, delayComponent))) @@ -1022,13 +1025,12 @@ public bool InteractionActivate( if (checkAccess && !IsAccessible(user, used)) return false; - // Does the user have hands? - if (!_handsQuery.HasComp(user)) - return false; - - var activateMsg = new ActivateInWorldEvent(user, used); + complexInteractions ??= SupportsComplexInteractions(user); + var activateMsg = new ActivateInWorldEvent(user, used, complexInteractions.Value); RaiseLocalEvent(used, activateMsg, true); - if (!activateMsg.Handled) + var userEv = new UserActivateInWorldEvent(user, used, complexInteractions.Value); + RaiseLocalEvent(user, userEv, true); + if (!activateMsg.Handled && !userEv.Handled) return false; DoContactInteraction(user, used, activateMsg); @@ -1063,7 +1065,7 @@ public bool UseInHandInteraction( if (checkCanInteract && !_actionBlockerSystem.CanInteract(user, used)) return false; - if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user)) + if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user, used)) return false; var useMsg = new UseInHandEvent(user); @@ -1263,6 +1265,39 @@ private void HandleUserInterfaceRangeCheck(ref BoundUserInterfaceCheckRangeEvent ? BoundUserInterfaceRangeResult.Pass : BoundUserInterfaceRangeResult.Fail; } + + /// + /// Gets the entity that is currently being "used" for the interaction. + /// In most cases, this refers to the entity in the character's active hand. + /// + /// If there is an entity being used. + public bool TryGetUsedEntity(EntityUid user, [NotNullWhen(true)] out EntityUid? used, bool checkCanUse = true) + { + var ev = new GetUsedEntityEvent(); + RaiseLocalEvent(user, ref ev); + + used = ev.Used; + if (!ev.Handled) + return false; + + // Can the user use the held entity? + if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user, ev.Used!.Value)) + { + used = null; + return false; + } + + return ev.Handled; + } + + /// + /// Checks if a given entity is able to do specific complex interactions. + /// This is used to gate manipulation to general humanoids. If a mouse shouldn't be able to do something, then it's complex. + /// + public bool SupportsComplexInteractions(EntityUid user) + { + return _complexInteractionQuery.HasComp(user); + } } /// @@ -1288,6 +1323,24 @@ public InteractInventorySlotEvent(NetEntity itemUid, bool altInteract = false) } } + /// + /// Raised directed by-ref on an entity to determine what item will be used in interactions. + /// + [ByRefEvent] + public record struct GetUsedEntityEvent() + { + public EntityUid? Used = null; + + public bool Handled => Used != null; + }; + + /// + /// Raised directed by-ref on an item and a user to determine if interactions can occur. + /// + /// Whether the hand interaction should be cancelled. + [ByRefEvent] + public record struct AttemptUseInteractEvent(EntityUid User, EntityUid Used, bool Cancelled = false); + /// /// Raised directed by-ref on an item to determine if hand interactions should go through. /// Defaults to allowing hand interactions to go through. Cancel to force the item to be attacked instead. diff --git a/Content.Shared/Lock/LockSystem.cs b/Content.Shared/Lock/LockSystem.cs index 9296a354d2c..28b481fa803 100644 --- a/Content.Shared/Lock/LockSystem.cs +++ b/Content.Shared/Lock/LockSystem.cs @@ -54,7 +54,7 @@ private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup a private void OnActivated(EntityUid uid, LockComponent lockComp, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; // Only attempt an unlock by default on Activate diff --git a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs index b4f1ae9a268..04926c34562 100644 --- a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs +++ b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs @@ -43,7 +43,7 @@ public override void Initialize() { SubscribeLocalEvent(OnToggleEquipmentAction); SubscribeLocalEvent(OnEjectPilotEvent); - SubscribeLocalEvent(RelayInteractionEvent); + SubscribeLocalEvent(RelayInteractionEvent); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnDestruction); SubscribeLocalEvent(OnGetAdditionalAccess); @@ -71,7 +71,7 @@ private void OnEjectPilotEvent(EntityUid uid, MechComponent component, MechEject TryEject(uid, component); } - private void RelayInteractionEvent(EntityUid uid, MechComponent component, InteractNoHandEvent args) + private void RelayInteractionEvent(EntityUid uid, MechComponent component, UserActivateInWorldEvent args) { var pilot = component.PilotSlot.ContainedEntity; if (pilot == null) diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index f40a7a0363b..593ad221b8d 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -47,7 +47,7 @@ private void OnEmbedActivate(EntityUid uid, EmbeddableProjectileComponent compon if (component.RemovalTime == null) return; - if (args.Handled || !TryComp(uid, out var physics) || physics.BodyType != BodyType.Static) + if (args.Handled || !args.Complex || !TryComp(uid, out var physics) || physics.BodyType != BodyType.Static) return; args.Handled = true; diff --git a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs index 636c6038348..0576e46df4a 100644 --- a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs @@ -89,7 +89,7 @@ protected virtual void OnComponentStartup(EntityUid uid, SharedEntityStorageComp protected void OnInteract(EntityUid uid, SharedEntityStorageComponent component, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; args.Handled = true; diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index 2e800c386b9..6172ee27509 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -369,7 +369,7 @@ private void OnInteractUsing(EntityUid uid, StorageComponent storageComp, Intera /// private void OnActivate(EntityUid uid, StorageComponent storageComp, ActivateInWorldEvent args) { - if (args.Handled || TryComp(uid, out var lockComponent) && lockComponent.Locked) + if (args.Handled || !args.Complex || !CanInteract(args.User, (uid, storageComp), storageComp.ClickInsert)) return; // Toggle diff --git a/Content.Shared/Strip/SharedStrippableSystem.cs b/Content.Shared/Strip/SharedStrippableSystem.cs index a801e5ee467..52eccc13b8c 100644 --- a/Content.Shared/Strip/SharedStrippableSystem.cs +++ b/Content.Shared/Strip/SharedStrippableSystem.cs @@ -15,9 +15,19 @@ public override void Initialize() SubscribeLocalEvent(OnCanDropOn); SubscribeLocalEvent(OnCanDrop); SubscribeLocalEvent(OnDragDrop); + SubscribeLocalEvent(OnActivateInWorld); } - public (TimeSpan Time, ThievingStealth Stealth) GetStripTimeModifiers(EntityUid user, EntityUid target, TimeSpan initialTime) + private void OnActivateInWorld(EntityUid uid, StrippableComponent component, ActivateInWorldEvent args) + { + if (args.Handled || !args.Complex || args.Target == args.User) + return; + + if (TryOpenStrippingUi(args.User, (uid, component))) + args.Handled = true; + } + + public (TimeSpan Time, bool Stealth) GetStripTimeModifiers(EntityUid user, EntityUid target, TimeSpan initialTime) { var userEv = new BeforeStripEvent(initialTime); RaiseLocalEvent(user, ref userEv); diff --git a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs index 6e8393036d4..8903747e430 100644 --- a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs +++ b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs @@ -26,7 +26,11 @@ public override void Initialize() private void OnTrayScannerActivate(EntityUid uid, TrayScannerComponent scanner, ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + SetScannerEnabled(uid, !scanner.Enabled, scanner); + args.Handled = true; } private void SetScannerEnabled(EntityUid uid, bool enabled, TrayScannerComponent? scanner = null) diff --git a/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs b/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs index 62c0b0f44e4..bc73baa61ad 100644 --- a/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs +++ b/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs @@ -101,6 +101,9 @@ private void OnGetAltVerb(Entity ent, ref GetVerbsEvent private void OnActivateInWorld(Entity ent, ref ActivateInWorldEvent args) { + if (args.Handled || !args.Complex) + return; + var (uid, comp) = ent; var user = args.User; if (comp.TeleportTime != null) @@ -130,6 +133,7 @@ private void OnActivateInWorld(Entity ent, ref Activate comp.NextTeleportUse = _timing.CurTime + comp.Cooldown; comp.TeleportTime = _timing.CurTime + comp.TeleportDelay; Dirty(uid, comp); + args.Handled = true; } public void DoTeleport(Entity ent) diff --git a/Content.Shared/Toilet/Systems/SharedToiletSystem.cs b/Content.Shared/Toilet/Systems/SharedToiletSystem.cs index 87df69e88da..f11af335527 100644 --- a/Content.Shared/Toilet/Systems/SharedToiletSystem.cs +++ b/Content.Shared/Toilet/Systems/SharedToiletSystem.cs @@ -79,7 +79,7 @@ private void OnToggleSeatVerb(EntityUid uid, ToiletComponent component, GetVerbs private void OnActivateInWorld(EntityUid uid, ToiletComponent comp, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; args.Handled = true; diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs b/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs index 9114c62adee..d69f01d762f 100644 --- a/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs +++ b/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs @@ -28,7 +28,7 @@ private void OnMultipleToolStartup(EntityUid uid, MultipleToolComponent multiple private void OnMultipleToolActivated(EntityUid uid, MultipleToolComponent multiple, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; args.Handled = CycleMultipleTool(uid, multiple, args.User); diff --git a/Content.Shared/UserInterface/ActivatableUISystem.cs b/Content.Shared/UserInterface/ActivatableUISystem.cs index 14ce4f20dce..01f71a2c952 100644 --- a/Content.Shared/UserInterface/ActivatableUISystem.cs +++ b/Content.Shared/UserInterface/ActivatableUISystem.cs @@ -133,7 +133,7 @@ private void OnUseInHand(EntityUid uid, ActivatableUIComponent component, UseInH private void OnActivate(EntityUid uid, ActivatableUIComponent component, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; if (component.VerbOnly) diff --git a/Content.Shared/Verbs/SharedVerbSystem.cs b/Content.Shared/Verbs/SharedVerbSystem.cs index e78fe98f4c3..319f927c7b3 100644 --- a/Content.Shared/Verbs/SharedVerbSystem.cs +++ b/Content.Shared/Verbs/SharedVerbSystem.cs @@ -78,28 +78,8 @@ public SortedSet GetLocalVerbs(EntityUid target, EntityUid user, List(user, out var hands); // TODO: fix this garbage and use proper generics or reflection or something else, not this. if (types.Contains(typeof(InteractionVerb))) diff --git a/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs b/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs index 41e1895da2c..6feffffbe31 100644 --- a/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs +++ b/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs @@ -116,7 +116,7 @@ private void OnWeightlessMove(ref CanWeightlessMoveEvent ev) private void OnGunActivate(EntityUid uid, GrapplingGunComponent component, ActivateInWorldEvent args) { - if (!Timing.IsFirstTimePredicted || args.Handled) + if (!Timing.IsFirstTimePredicted || args.Handled || !args.Complex) return; if (Deleted(component.Projectile)) diff --git a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.Force.cs b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.Force.cs index eec115b02df..932ef704607 100644 --- a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.Force.cs +++ b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.Force.cs @@ -14,6 +14,9 @@ private void InitializeForce() private void OnForceActivate(EntityUid uid, ForceGunComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + StopTether(uid, component); } diff --git a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs index dd297422c37..21da0a3ca45 100644 --- a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs +++ b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs @@ -152,6 +152,9 @@ protected bool TryGetTetherGun(EntityUid user, [NotNullWhen(true)] out EntityUid private void OnTetherActivate(EntityUid uid, TetherGunComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + StopTether(uid, component); } diff --git a/Content.Shared/Weapons/Ranged/Systems/BatteryWeaponFireModesSystem.cs b/Content.Shared/Weapons/Ranged/Systems/BatteryWeaponFireModesSystem.cs index 68fb2f27c98..8e44576d283 100644 --- a/Content.Shared/Weapons/Ranged/Systems/BatteryWeaponFireModesSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/BatteryWeaponFireModesSystem.cs @@ -75,6 +75,9 @@ private void OnGetVerb(EntityUid uid, BatteryWeaponFireModesComponent component, private void OnInteractHandEvent(EntityUid uid, BatteryWeaponFireModesComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + if (component.FireModes.Count < 2) return; diff --git a/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs b/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs index a014f8e5c74..ee5ca2174f3 100644 --- a/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs @@ -18,6 +18,9 @@ public override void Initialize() private void OnRechargeCycled(EntityUid uid, RechargeCycleAmmoComponent component, ActivateInWorldEvent args) { + if (!args.Complex) + return; + if (!TryComp(uid, out var basic) || args.Handled) return; diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs index c421c92a9f7..adae26a223a 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs @@ -51,7 +51,7 @@ private void OnChamberStartup(EntityUid uid, ChamberMagazineAmmoProviderComponen /// private void OnChamberActivate(EntityUid uid, ChamberMagazineAmmoProviderComponent component, ActivateInWorldEvent args) { - if (args.Handled) + if (args.Handled || !args.Complex) return; args.Handled = true; diff --git a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml index 7974b06870e..9a4490e002f 100644 --- a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml +++ b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml @@ -84,6 +84,7 @@ - type: Hands showInHands: false disableExplosionRecursion: true + - type: ComplexInteraction - type: IntrinsicRadioReceiver - type: IntrinsicRadioTransmitter channels: diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index 6155d20c5a4..70efef669d3 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -1285,6 +1285,7 @@ visible: false - type: Carriable - type: Hands + - type: ComplexInteraction - type: GenericVisualizer visuals: enum.CreamPiedVisuals.Creamed: diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/mimic.yml b/Resources/Prototypes/Entities/Mobs/NPCs/mimic.yml index c3a92d3ebcd..3ffa449f48f 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/mimic.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/mimic.yml @@ -17,7 +17,6 @@ - type: NpcFactionMember factions: - SimpleHostile - - type: Hands - type: Sprite drawdepth: Mobs sprite: Structures/Machines/VendingMachines/cola.rsi diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml index 04b767b8ae2..04c4dd083e0 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml @@ -40,6 +40,7 @@ factions: - Xeno - type: Hands + - type: ComplexInteraction - type: Sprite drawdepth: Mobs sprite: Mobs/Aliens/Xenos/burrower.rsi diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml index 957817d4083..7e0908cf2bd 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml @@ -25,6 +25,7 @@ canInteract: true - type: GhostHearing - type: Hands + - type: ComplexInteraction - type: Puller pushAcceleration: 1000000 # Will still be capped in max speed maxPushRange: 20 diff --git a/Resources/Prototypes/Entities/Mobs/Player/guardian.yml b/Resources/Prototypes/Entities/Mobs/Player/guardian.yml index 7d1139d3d79..51078d1b100 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/guardian.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/guardian.yml @@ -228,6 +228,7 @@ - type: Inventory templateId: holoclown - type: Hands + - type: ComplexInteraction - type: Clumsy clumsyDamage: types: diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index 24ee2a964a5..fc44bab4377 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -152,6 +152,8 @@ - type: Identity - type: IdExaminable - type: Hands + - type: ComplexInteraction + - type: Internals - type: Inventory - type: InventorySlots - type: FloatingVisuals @@ -324,6 +326,7 @@ abstract: true components: - type: Hands + - type: ComplexInteraction - type: Inventory - type: InventorySlots - type: ContainerContainer From 2348b298f79b7017b49563322ce9536bc6c6e764 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Thu, 14 Jul 2022 22:29:29 +1200 Subject: [PATCH 2/3] Remove IActivate (#9705) * git mv * purge IActivate * File scoped NS --- .../Radio/EntitySystems/RadioSystem.cs | 2 +- .../Interaction/ActivateInWorldEvent.cs | 42 +------------------ .../Interaction/SharedInteractionSystem.cs | 1 + 3 files changed, 3 insertions(+), 42 deletions(-) diff --git a/Content.Server/Radio/EntitySystems/RadioSystem.cs b/Content.Server/Radio/EntitySystems/RadioSystem.cs index 71fb4ff5020..2c6647199f0 100644 --- a/Content.Server/Radio/EntitySystems/RadioSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioSystem.cs @@ -197,4 +197,4 @@ private bool HasActiveServer(MapId mapId, string channelId) } return false; } -} +} \ No newline at end of file diff --git a/Content.Shared/Interaction/ActivateInWorldEvent.cs b/Content.Shared/Interaction/ActivateInWorldEvent.cs index f7a1b7a799d..ea308f9b086 100644 --- a/Content.Shared/Interaction/ActivateInWorldEvent.cs +++ b/Content.Shared/Interaction/ActivateInWorldEvent.cs @@ -18,49 +18,9 @@ public sealed class ActivateInWorldEvent : HandledEntityEventArgs, ITargetedInte /// public EntityUid Target { get; } - /// - /// Whether or not can perform complex interactions or only basic ones. - /// - public bool Complex; - - /// - /// Set to true when the activation is logged by a specific logger. - /// - public bool WasLogged { get; set; } - - public ActivateInWorldEvent(EntityUid user, EntityUid target, bool complex) - { - User = user; - Target = target; - Complex = complex; - } -} - -/// -/// Event raised on the user when it activates something in the world -/// -[PublicAPI] -public sealed class UserActivateInWorldEvent : HandledEntityEventArgs, ITargetedInteractEventArgs -{ - /// - /// Entity that activated the target world entity. - /// - public EntityUid User { get; } - - /// - /// Entity that was activated in the world. - /// - public EntityUid Target { get; } - - /// - /// Whether or not can perform complex interactions or only basic ones. - /// - public bool Complex; - - public UserActivateInWorldEvent(EntityUid user, EntityUid target, bool complex) + public ActivateInWorldEvent(EntityUid user, EntityUid target) { User = user; Target = target; - Complex = complex; } } diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 8b296d8fe7d..3a1dd7d4f2e 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Hands; using Content.Shared.Hands.Components; using Content.Shared.Input; +using Content.Shared.Interaction; using Content.Shared.Interaction.Components; using Content.Shared.Interaction.Events; using Content.Shared.Inventory; From eb9c19b25e02e81172821fb082d002138f029f66 Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Wed, 20 Nov 2024 02:33:34 -0400 Subject: [PATCH 3/3] Use new ActivateInWorld --- .../Interaction/ActivateInWorldEvent.cs | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Interaction/ActivateInWorldEvent.cs b/Content.Shared/Interaction/ActivateInWorldEvent.cs index ea308f9b086..f7a1b7a799d 100644 --- a/Content.Shared/Interaction/ActivateInWorldEvent.cs +++ b/Content.Shared/Interaction/ActivateInWorldEvent.cs @@ -18,9 +18,49 @@ public sealed class ActivateInWorldEvent : HandledEntityEventArgs, ITargetedInte /// public EntityUid Target { get; } - public ActivateInWorldEvent(EntityUid user, EntityUid target) + /// + /// Whether or not can perform complex interactions or only basic ones. + /// + public bool Complex; + + /// + /// Set to true when the activation is logged by a specific logger. + /// + public bool WasLogged { get; set; } + + public ActivateInWorldEvent(EntityUid user, EntityUid target, bool complex) + { + User = user; + Target = target; + Complex = complex; + } +} + +/// +/// Event raised on the user when it activates something in the world +/// +[PublicAPI] +public sealed class UserActivateInWorldEvent : HandledEntityEventArgs, ITargetedInteractEventArgs +{ + /// + /// Entity that activated the target world entity. + /// + public EntityUid User { get; } + + /// + /// Entity that was activated in the world. + /// + public EntityUid Target { get; } + + /// + /// Whether or not can perform complex interactions or only basic ones. + /// + public bool Complex; + + public UserActivateInWorldEvent(EntityUid user, EntityUid target, bool complex) { User = user; Target = target; + Complex = complex; } }