diff --git a/Content.Server/Atmos/Components/GasAnalyzerComponent.cs b/Content.Server/Atmos/Components/GasAnalyzerComponent.cs index 03230438e3..68d4d79d90 100644 --- a/Content.Server/Atmos/Components/GasAnalyzerComponent.cs +++ b/Content.Server/Atmos/Components/GasAnalyzerComponent.cs @@ -18,7 +18,9 @@ using Robust.Shared.ViewVariables; namespace Content.Server.Atmos.Components { [RegisterComponent] - public class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract, IDropped, IUse + [ComponentReference(typeof(IActivate))] + [ComponentReference(typeof(SharedGasAnalyzerComponent))] + public class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract, IDropped, IActivate { [Dependency] private readonly IEntityManager _entities = default!; @@ -271,14 +273,14 @@ namespace Content.Server.Atmos.Components } } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) + void IActivate.Activate(ActivateEventArgs eventArgs) { if (_entities.TryGetComponent(eventArgs.User, out ActorComponent? actor)) { ToggleInterface(actor.PlayerSession); - return true; + return; } - return false; + return; } } } diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index b9d5d1a6b6..96834d48c3 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Components [RegisterComponent] [ComponentReference(typeof(IActivate))] #pragma warning disable 618 - public class GasTankComponent : Component, IExamine, IGasMixtureHolder, IUse, IDropped, IActivate + public class GasTankComponent : Component, IExamine, IGasMixtureHolder, IDropped, IActivate #pragma warning restore 618 { [Dependency] private readonly IEntityManager _entMan = default!; @@ -155,13 +155,6 @@ namespace Content.Server.Atmos.Components return air; } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) - { - if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor)) return false; - OpenInterface(actor.PlayerSession); - return true; - } - void IActivate.Activate(ActivateEventArgs eventArgs) { if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor)) return; diff --git a/Content.Server/Clothing/Components/MagbootsComponent.cs b/Content.Server/Clothing/Components/MagbootsComponent.cs index efc1980ce1..a0bea10ebf 100644 --- a/Content.Server/Clothing/Components/MagbootsComponent.cs +++ b/Content.Server/Clothing/Components/MagbootsComponent.cs @@ -1,9 +1,6 @@ -using Content.Server.Alert; -using Content.Server.Atmos.Components; using Content.Shared.Actions; using Content.Shared.Actions.Behaviors.Item; using Content.Shared.Actions.Components; -using Content.Shared.Alert; using Content.Shared.Clothing; using Content.Shared.Interaction; using Content.Shared.Inventory; @@ -20,14 +17,12 @@ namespace Content.Server.Clothing.Components { [RegisterComponent] [ComponentReference(typeof(IActivate))] - public sealed class MagbootsComponent : SharedMagbootsComponent, IUse, IActivate + public sealed class MagbootsComponent : SharedMagbootsComponent, IActivate { [ComponentDependency] private SharedItemComponent? _item = null; [ComponentDependency] private ItemActionsComponent? _itemActions = null; [ComponentDependency] private SpriteComponent? _sprite = null; - [Dependency] private readonly IEntityManager _entMan = default!; - private bool _on; [ViewVariables] @@ -58,12 +53,6 @@ namespace Content.Server.Clothing.Components On = !On; } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) - { - Toggle(eventArgs.User); - return true; - } - void IActivate.Activate(ActivateEventArgs eventArgs) { Toggle(eventArgs.User); diff --git a/Content.Server/Dice/DiceSystem.cs b/Content.Server/Dice/DiceSystem.cs index 073969859b..f1df0bd4a5 100644 --- a/Content.Server/Dice/DiceSystem.cs +++ b/Content.Server/Dice/DiceSystem.cs @@ -26,7 +26,6 @@ namespace Content.Server.Dice SubscribeLocalEvent(OnComponentInit); SubscribeLocalEvent(OnActivate); - SubscribeLocalEvent(OnUse); SubscribeLocalEvent(OnLand); SubscribeLocalEvent(OnExamined); } @@ -42,11 +41,6 @@ namespace Content.Server.Dice Roll(uid, component); } - private void OnUse(EntityUid uid, DiceComponent component, UseInHandEvent args) - { - Roll(uid, component); - } - private void OnLand(EntityUid uid, DiceComponent component, LandEvent args) { Roll(uid, component); diff --git a/Content.Server/Extinguisher/FireExtinguisherComponent.cs b/Content.Server/Extinguisher/FireExtinguisherComponent.cs index 240777dc2a..b15ad1e9db 100644 --- a/Content.Server/Extinguisher/FireExtinguisherComponent.cs +++ b/Content.Server/Extinguisher/FireExtinguisherComponent.cs @@ -18,7 +18,9 @@ using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Extinguisher { [RegisterComponent] - public class FireExtinguisherComponent : SharedFireExtinguisherComponent, IAfterInteract, IUse, IActivate, IDropped + [ComponentReference(typeof(IActivate))] + [ComponentReference(typeof(SharedFireExtinguisherComponent))] + public class FireExtinguisherComponent : SharedFireExtinguisherComponent, IAfterInteract, IActivate, IDropped { [Dependency] private readonly IEntityManager _entMan = default!; @@ -81,11 +83,6 @@ namespace Content.Server.Extinguisher return true; } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) - { - ToggleSafety(eventArgs.User); - return true; - } void IActivate.Activate(ActivateEventArgs eventArgs) { diff --git a/Content.Server/Labels/Label/HandLabelerSystem.cs b/Content.Server/Labels/Label/HandLabelerSystem.cs index cc9293922b..0c2a18ff1a 100644 --- a/Content.Server/Labels/Label/HandLabelerSystem.cs +++ b/Content.Server/Labels/Label/HandLabelerSystem.cs @@ -27,7 +27,7 @@ namespace Content.Server.Labels base.Initialize(); SubscribeLocalEvent(AfterInteractOn); - SubscribeLocalEvent(OnUseInHand); + SubscribeLocalEvent(OnActivate); // Bound UI subscriptions SubscribeLocalEvent(OnHandLabelerLabelChanged); } @@ -70,7 +70,7 @@ namespace Content.Server.Labels result = Loc.GetString("hand-labeler-successfully-applied"); } - private void OnUseInHand(EntityUid uid, HandLabelerComponent handLabeler, UseInHandEvent args) + private void OnActivate(EntityUid uid, HandLabelerComponent handLabeler, ActivateInWorldEvent args) { if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; diff --git a/Content.Server/Light/EntitySystems/HandheldLightSystem.cs b/Content.Server/Light/EntitySystems/HandheldLightSystem.cs index aa998b4c7c..96ff42e711 100644 --- a/Content.Server/Light/EntitySystems/HandheldLightSystem.cs +++ b/Content.Server/Light/EntitySystems/HandheldLightSystem.cs @@ -45,7 +45,7 @@ namespace Content.Server.Light.EntitySystems SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(AddToggleLightVerb); SubscribeLocalEvent(OnInteractUsing); - SubscribeLocalEvent(OnUse); + SubscribeLocalEvent(OnActivate); } private void OnGetState(EntityUid uid, HandheldLightComponent component, ref ComponentGetState args) @@ -93,7 +93,7 @@ namespace Content.Server.Light.EntitySystems args.Handled = true; } - private void OnUse(EntityUid uid, HandheldLightComponent component, UseInHandEvent args) + private void OnActivate(EntityUid uid, HandheldLightComponent component, ActivateInWorldEvent args) { if (args.Handled) return; diff --git a/Content.Server/PDA/PDASystem.cs b/Content.Server/PDA/PDASystem.cs index 903f868ee8..8e263a0912 100644 --- a/Content.Server/PDA/PDASystem.cs +++ b/Content.Server/PDA/PDASystem.cs @@ -24,7 +24,6 @@ namespace Content.Server.PDA base.Initialize(); SubscribeLocalEvent(OnActivateInWorld); - SubscribeLocalEvent(OnUse); SubscribeLocalEvent(OnLightToggle); } @@ -37,15 +36,6 @@ namespace Content.Server.PDA ui.OnReceiveMessage += (msg) => OnUIMessage(pda, msg); } - - - private void OnUse(EntityUid uid, PDAComponent pda, UseInHandEvent args) - { - if (args.Handled) - return; - args.Handled = OpenUI(pda, args.User); - } - private void OnActivateInWorld(EntityUid uid, PDAComponent pda, ActivateInWorldEvent args) { if (args.Handled) diff --git a/Content.Server/Paper/PaperComponent.cs b/Content.Server/Paper/PaperComponent.cs index e99520c72e..1611f24c0e 100644 --- a/Content.Server/Paper/PaperComponent.cs +++ b/Content.Server/Paper/PaperComponent.cs @@ -16,7 +16,9 @@ namespace Content.Server.Paper { [RegisterComponent] #pragma warning disable 618 - public class PaperComponent : SharedPaperComponent, IExamine, IInteractUsing, IUse + [ComponentReference(typeof(SharedPaperComponent))] + [ComponentReference(typeof(IActivate))] + public sealed class PaperComponent : SharedPaperComponent, IExamine, IInteractUsing, IActivate #pragma warning restore 618 { [Dependency] private readonly IEntityManager _entMan = default!; @@ -74,15 +76,15 @@ namespace Content.Server.Paper ); } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) + void IActivate.Activate(ActivateEventArgs eventArgs) { if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor)) - return false; + return; _mode = PaperAction.Read; UpdateUserInterface(); UserInterface?.Toggle(actor.PlayerSession); - return true; + return; } private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj) diff --git a/Content.Server/Pinpointer/ServerPinpointerSystem.cs b/Content.Server/Pinpointer/ServerPinpointerSystem.cs index 2ed782176e..bddc65d1a7 100644 --- a/Content.Server/Pinpointer/ServerPinpointerSystem.cs +++ b/Content.Server/Pinpointer/ServerPinpointerSystem.cs @@ -16,10 +16,10 @@ namespace Content.Server.Pinpointer public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnUseInHand); + SubscribeLocalEvent(OnActivate); } - private void OnUseInHand(EntityUid uid, PinpointerComponent component, UseInHandEvent args) + private void OnActivate(EntityUid uid, PinpointerComponent component, ActivateInWorldEvent args) { TogglePinpointer(uid, component); diff --git a/Content.Server/Radio/Components/HandheldRadioComponent.cs b/Content.Server/Radio/Components/HandheldRadioComponent.cs index f05181d5b4..200069f0f1 100644 --- a/Content.Server/Radio/Components/HandheldRadioComponent.cs +++ b/Content.Server/Radio/Components/HandheldRadioComponent.cs @@ -17,8 +17,9 @@ namespace Content.Server.Radio.Components [RegisterComponent] [ComponentReference(typeof(IRadio))] [ComponentReference(typeof(IListen))] + [ComponentReference(typeof(IActivate))] #pragma warning disable 618 - public class HandheldRadioComponent : Component, IUse, IListen, IRadio, IActivate, IExamine + public class HandheldRadioComponent : Component, IListen, IRadio, IActivate, IExamine #pragma warning restore 618 { [Dependency] private readonly IChatManager _chatManager = default!; @@ -74,11 +75,6 @@ namespace Content.Server.Radio.Components return true; } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) - { - return Use(eventArgs.User); - } - public bool CanListen(string message, EntityUid source) { return RadioOn && diff --git a/Content.Server/Storage/Components/ServerStorageComponent.cs b/Content.Server/Storage/Components/ServerStorageComponent.cs index d749f93f37..92ae9d3ca2 100644 --- a/Content.Server/Storage/Components/ServerStorageComponent.cs +++ b/Content.Server/Storage/Components/ServerStorageComponent.cs @@ -41,7 +41,8 @@ namespace Content.Server.Storage.Components [RegisterComponent] [ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IStorageComponent))] - public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct, IExAct, IAfterInteract + [ComponentReference(typeof(SharedStorageComponent))] + public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IActivate, IStorageComponent, IDestroyAct, IExAct, IAfterInteract { [Dependency] private readonly IEntityManager _entityManager = default!; @@ -539,18 +540,10 @@ namespace Content.Server.Storage.Components /// /// /// - bool IUse.UseEntity(UseEntityEventArgs eventArgs) + void IActivate.Activate(ActivateEventArgs eventArgs) { EnsureInitialCalculated(); OpenStorageUI(eventArgs.User); - return false; - } - - void IActivate.Activate(ActivateEventArgs eventArgs) - { -#pragma warning disable 618 - ((IUse) this).UseEntity(new UseEntityEventArgs(eventArgs.User)); -#pragma warning restore 618 } /// diff --git a/Content.Server/Tools/ToolSystem.MultipleTool.cs b/Content.Server/Tools/ToolSystem.MultipleTool.cs index 6ea8d80af8..1e8ad1a2c9 100644 --- a/Content.Server/Tools/ToolSystem.MultipleTool.cs +++ b/Content.Server/Tools/ToolSystem.MultipleTool.cs @@ -20,7 +20,6 @@ namespace Content.Server.Tools private void InitializeMultipleTools() { SubscribeLocalEvent(OnMultipleToolStartup); - SubscribeLocalEvent(OnMultipleToolUsedInHand); SubscribeLocalEvent(OnMultipleToolActivated); SubscribeLocalEvent(OnMultipleToolGetState); } @@ -32,14 +31,6 @@ namespace Content.Server.Tools SetMultipleTool(uid, multiple, tool); } - private void OnMultipleToolUsedInHand(EntityUid uid, MultipleToolComponent multiple, UseInHandEvent args) - { - if (args.Handled) - return; - - args.Handled = CycleMultipleTool(uid, multiple); - } - private void OnMultipleToolActivated(EntityUid uid, MultipleToolComponent multiple, ActivateInWorldEvent args) { if (args.Handled) diff --git a/Content.Server/Tools/ToolSystem.Welder.cs b/Content.Server/Tools/ToolSystem.Welder.cs index cb290ef118..a4649bd07f 100644 --- a/Content.Server/Tools/ToolSystem.Welder.cs +++ b/Content.Server/Tools/ToolSystem.Welder.cs @@ -35,7 +35,6 @@ namespace Content.Server.Tools SubscribeLocalEvent(OnWelderIsHotEvent); SubscribeLocalEvent(OnWelderExamine); SubscribeLocalEvent(OnWelderSolutionChange); - SubscribeLocalEvent(OnWelderUseInHand); SubscribeLocalEvent(OnWelderActivate); SubscribeLocalEvent(OnWelderAfterInteract); SubscribeLocalEvent(OnWelderToolUseAttempt); @@ -238,11 +237,6 @@ namespace Content.Server.Tools args.Handled = true; } - private void OnWelderUseInHand(EntityUid uid, WelderComponent welder, UseInHandEvent args) - { - args.Handled = TryToggleWelder(uid, args.User, welder); - } - private void OnWelderToolUseAttempt(EntityUid uid, WelderComponent welder, ToolUseAttemptEvent args) { if (args.Cancelled) diff --git a/Content.Server/Traitor/Uplink/UplinkSystem.cs b/Content.Server/Traitor/Uplink/UplinkSystem.cs index 415d09c28c..925a9741e2 100644 --- a/Content.Server/Traitor/Uplink/UplinkSystem.cs +++ b/Content.Server/Traitor/Uplink/UplinkSystem.cs @@ -35,7 +35,7 @@ namespace Content.Server.Traitor.Uplink SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnRemove); - SubscribeLocalEvent(OnUseHand); + SubscribeLocalEvent(OnActivate); // UI events SubscribeLocalEvent(OnBuy); @@ -75,7 +75,7 @@ namespace Content.Server.Traitor.Uplink RaiseLocalEvent(uid, new UplinkRemovedEvent()); } - private void OnUseHand(EntityUid uid, UplinkComponent component, UseInHandEvent args) + private void OnActivate(EntityUid uid, UplinkComponent component, ActivateInWorldEvent args) { if (args.Handled) return; diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index d2f39e50bf..21ce645e1d 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -710,8 +710,11 @@ namespace Content.Shared.Hands.Components if (!TryGetActiveHeldEntity(out var heldEntity)) return; - EntitySystem.Get() - .TryUseInteraction(Owner, heldEntity.Value, altInteract); + var sys = EntitySystem.Get(); + if (altInteract) + sys.AltInteract(Owner, heldEntity.Value); + else + sys.TryUseInteraction(Owner, heldEntity.Value); } public void ActivateHeldEntity(string handName) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index bbf8b44adb..c431a8711b 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -642,32 +642,29 @@ namespace Content.Shared.Interaction #region Hands #region Use /// - /// Activates the IUse behaviors of an entity - /// Verifies that the user is capable of doing the use interaction first + /// Attempt to perform a use-interaction on an entity. If no interaction occurs, it will instead attempt to + /// activate the entity. /// - /// - /// - public void TryUseInteraction(EntityUid user, EntityUid used, bool altInteract = false) + public void TryUseInteraction(EntityUid user, EntityUid used) { - if (_actionBlockerSystem.CanUse(user)) - { - if (altInteract) - AltInteract(user, used); - else - UseInteraction(user, used); - } + if (_actionBlockerSystem.CanUse(user) && UseInteraction(user, used)) + return; + + // no use-interaction occurred. Attempt to activate the item instead. + InteractionActivate(user, used); } /// /// Activates the IUse behaviors of an entity without first checking /// if the user is capable of doing the use interaction. /// - public void UseInteraction(EntityUid user, EntityUid used) + /// True if the interaction was handled. False otherwise + public bool UseInteraction(EntityUid user, EntityUid used) { if (TryComp(used, out UseDelayComponent? delayComponent)) { if (delayComponent.ActiveDelay) - return; + return true; // if the item is on cooldown, we consider this handled. delayComponent.BeginDelay(); } @@ -675,7 +672,7 @@ namespace Content.Shared.Interaction var useMsg = new UseInHandEvent(user, used); RaiseLocalEvent(used, useMsg); if (useMsg.Handled) - return; + return true; var uses = AllComps(used).ToList(); @@ -684,8 +681,10 @@ namespace Content.Shared.Interaction { // If a Use returns a status completion we finish our interaction if (use.UseEntity(new UseEntityEventArgs(user))) - return; + return true; } + + return false; } /// @@ -694,12 +693,17 @@ namespace Content.Shared.Interaction /// /// Uses the context menu verb list, and acts out the highest priority alternative interaction verb. /// - public void AltInteract(EntityUid user, EntityUid target) + /// True if the interaction was handled, false otherwise. + public bool AltInteract(EntityUid user, EntityUid target) { // Get list of alt-interact verbs var verbs = _verbSystem.GetLocalVerbs(target, user, VerbType.Alternative)[VerbType.Alternative]; - if (verbs.Any()) - _verbSystem.ExecuteVerb(verbs.First(), user, target); + + if (!verbs.Any()) + return false; + + _verbSystem.ExecuteVerb(verbs.First(), user, target); + return true; } #endregion diff --git a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs index 7d3c40327c..e55f0c9255 100644 --- a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs +++ b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs @@ -16,15 +16,9 @@ public abstract class SharedTrayScannerSystem : EntitySystem SubscribeLocalEvent(OnTrayScannerGetState); SubscribeLocalEvent(OnTrayScannerHandleState); - SubscribeLocalEvent(OnTrayScannerUsed); SubscribeLocalEvent(OnTrayScannerActivate); } - private void OnTrayScannerUsed(EntityUid uid, TrayScannerComponent scanner, UseInHandEvent args) - { - ActivateTray(uid, scanner); - } - private void OnTrayScannerActivate(EntityUid uid, TrayScannerComponent scanner, ActivateInWorldEvent args) { ActivateTray(uid, scanner);