Make use-in-hand default to activation interactions. (#5951)

This commit is contained in:
Leon Friedrich
2022-01-05 02:23:01 +13:00
committed by GitHub
parent c4512e3c1a
commit f13f743c51
18 changed files with 58 additions and 116 deletions

View File

@@ -18,7 +18,9 @@ using Robust.Shared.ViewVariables;
namespace Content.Server.Atmos.Components namespace Content.Server.Atmos.Components
{ {
[RegisterComponent] [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!; [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)) if (_entities.TryGetComponent(eventArgs.User, out ActorComponent? actor))
{ {
ToggleInterface(actor.PlayerSession); ToggleInterface(actor.PlayerSession);
return true; return;
} }
return false; return;
} }
} }
} }

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Components
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
#pragma warning disable 618 #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 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IEntityManager _entMan = default!;
@@ -155,13 +155,6 @@ namespace Content.Server.Atmos.Components
return air; 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) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor)) return; if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor)) return;

View File

@@ -1,9 +1,6 @@
using Content.Server.Alert;
using Content.Server.Atmos.Components;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Actions.Behaviors.Item; using Content.Shared.Actions.Behaviors.Item;
using Content.Shared.Actions.Components; using Content.Shared.Actions.Components;
using Content.Shared.Alert;
using Content.Shared.Clothing; using Content.Shared.Clothing;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Inventory; using Content.Shared.Inventory;
@@ -20,14 +17,12 @@ namespace Content.Server.Clothing.Components
{ {
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
public sealed class MagbootsComponent : SharedMagbootsComponent, IUse, IActivate public sealed class MagbootsComponent : SharedMagbootsComponent, IActivate
{ {
[ComponentDependency] private SharedItemComponent? _item = null; [ComponentDependency] private SharedItemComponent? _item = null;
[ComponentDependency] private ItemActionsComponent? _itemActions = null; [ComponentDependency] private ItemActionsComponent? _itemActions = null;
[ComponentDependency] private SpriteComponent? _sprite = null; [ComponentDependency] private SpriteComponent? _sprite = null;
[Dependency] private readonly IEntityManager _entMan = default!;
private bool _on; private bool _on;
[ViewVariables] [ViewVariables]
@@ -58,12 +53,6 @@ namespace Content.Server.Clothing.Components
On = !On; On = !On;
} }
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{
Toggle(eventArgs.User);
return true;
}
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
Toggle(eventArgs.User); Toggle(eventArgs.User);

View File

@@ -26,7 +26,6 @@ namespace Content.Server.Dice
SubscribeLocalEvent<DiceComponent, ComponentInit>(OnComponentInit); SubscribeLocalEvent<DiceComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<DiceComponent, ActivateInWorldEvent>(OnActivate); SubscribeLocalEvent<DiceComponent, ActivateInWorldEvent>(OnActivate);
SubscribeLocalEvent<DiceComponent, UseInHandEvent>(OnUse);
SubscribeLocalEvent<DiceComponent, LandEvent>(OnLand); SubscribeLocalEvent<DiceComponent, LandEvent>(OnLand);
SubscribeLocalEvent<DiceComponent, ExaminedEvent>(OnExamined); SubscribeLocalEvent<DiceComponent, ExaminedEvent>(OnExamined);
} }
@@ -42,11 +41,6 @@ namespace Content.Server.Dice
Roll(uid, component); Roll(uid, component);
} }
private void OnUse(EntityUid uid, DiceComponent component, UseInHandEvent args)
{
Roll(uid, component);
}
private void OnLand(EntityUid uid, DiceComponent component, LandEvent args) private void OnLand(EntityUid uid, DiceComponent component, LandEvent args)
{ {
Roll(uid, component); Roll(uid, component);

View File

@@ -18,7 +18,9 @@ using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Extinguisher namespace Content.Server.Extinguisher
{ {
[RegisterComponent] [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!; [Dependency] private readonly IEntityManager _entMan = default!;
@@ -81,11 +83,6 @@ namespace Content.Server.Extinguisher
return true; return true;
} }
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{
ToggleSafety(eventArgs.User);
return true;
}
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {

View File

@@ -27,7 +27,7 @@ namespace Content.Server.Labels
base.Initialize(); base.Initialize();
SubscribeLocalEvent<HandLabelerComponent, AfterInteractEvent>(AfterInteractOn); SubscribeLocalEvent<HandLabelerComponent, AfterInteractEvent>(AfterInteractOn);
SubscribeLocalEvent<HandLabelerComponent, UseInHandEvent>(OnUseInHand); SubscribeLocalEvent<HandLabelerComponent, ActivateInWorldEvent>(OnActivate);
// Bound UI subscriptions // Bound UI subscriptions
SubscribeLocalEvent<HandLabelerComponent, HandLabelerLabelChangedMessage>(OnHandLabelerLabelChanged); SubscribeLocalEvent<HandLabelerComponent, HandLabelerLabelChangedMessage>(OnHandLabelerLabelChanged);
} }
@@ -70,7 +70,7 @@ namespace Content.Server.Labels
result = Loc.GetString("hand-labeler-successfully-applied"); 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)) if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return; return;

View File

@@ -45,7 +45,7 @@ namespace Content.Server.Light.EntitySystems
SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine); SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<HandheldLightComponent, GetActivationVerbsEvent>(AddToggleLightVerb); SubscribeLocalEvent<HandheldLightComponent, GetActivationVerbsEvent>(AddToggleLightVerb);
SubscribeLocalEvent<HandheldLightComponent, InteractUsingEvent>(OnInteractUsing); SubscribeLocalEvent<HandheldLightComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<HandheldLightComponent, UseInHandEvent>(OnUse); SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(OnActivate);
} }
private void OnGetState(EntityUid uid, HandheldLightComponent component, ref ComponentGetState args) private void OnGetState(EntityUid uid, HandheldLightComponent component, ref ComponentGetState args)
@@ -93,7 +93,7 @@ namespace Content.Server.Light.EntitySystems
args.Handled = true; 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; if (args.Handled) return;

View File

@@ -24,7 +24,6 @@ namespace Content.Server.PDA
base.Initialize(); base.Initialize();
SubscribeLocalEvent<PDAComponent, ActivateInWorldEvent>(OnActivateInWorld); SubscribeLocalEvent<PDAComponent, ActivateInWorldEvent>(OnActivateInWorld);
SubscribeLocalEvent<PDAComponent, UseInHandEvent>(OnUse);
SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle); SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle);
} }
@@ -37,15 +36,6 @@ namespace Content.Server.PDA
ui.OnReceiveMessage += (msg) => OnUIMessage(pda, msg); 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) private void OnActivateInWorld(EntityUid uid, PDAComponent pda, ActivateInWorldEvent args)
{ {
if (args.Handled) if (args.Handled)

View File

@@ -16,7 +16,9 @@ namespace Content.Server.Paper
{ {
[RegisterComponent] [RegisterComponent]
#pragma warning disable 618 #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 #pragma warning restore 618
{ {
[Dependency] private readonly IEntityManager _entMan = default!; [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)) if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
return false; return;
_mode = PaperAction.Read; _mode = PaperAction.Read;
UpdateUserInterface(); UpdateUserInterface();
UserInterface?.Toggle(actor.PlayerSession); UserInterface?.Toggle(actor.PlayerSession);
return true; return;
} }
private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj) private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)

View File

@@ -16,10 +16,10 @@ namespace Content.Server.Pinpointer
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<PinpointerComponent, UseInHandEvent>(OnUseInHand); SubscribeLocalEvent<PinpointerComponent, ActivateInWorldEvent>(OnActivate);
} }
private void OnUseInHand(EntityUid uid, PinpointerComponent component, UseInHandEvent args) private void OnActivate(EntityUid uid, PinpointerComponent component, ActivateInWorldEvent args)
{ {
TogglePinpointer(uid, component); TogglePinpointer(uid, component);

View File

@@ -17,8 +17,9 @@ namespace Content.Server.Radio.Components
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(IRadio))] [ComponentReference(typeof(IRadio))]
[ComponentReference(typeof(IListen))] [ComponentReference(typeof(IListen))]
[ComponentReference(typeof(IActivate))]
#pragma warning disable 618 #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 #pragma warning restore 618
{ {
[Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly IChatManager _chatManager = default!;
@@ -74,11 +75,6 @@ namespace Content.Server.Radio.Components
return true; return true;
} }
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{
return Use(eventArgs.User);
}
public bool CanListen(string message, EntityUid source) public bool CanListen(string message, EntityUid source)
{ {
return RadioOn && return RadioOn &&

View File

@@ -41,7 +41,8 @@ namespace Content.Server.Storage.Components
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
[ComponentReference(typeof(IStorageComponent))] [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!; [Dependency] private readonly IEntityManager _entityManager = default!;
@@ -539,18 +540,10 @@ namespace Content.Server.Storage.Components
/// </summary> /// </summary>
/// <param name="eventArgs"></param> /// <param name="eventArgs"></param>
/// <returns></returns> /// <returns></returns>
bool IUse.UseEntity(UseEntityEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
EnsureInitialCalculated(); EnsureInitialCalculated();
OpenStorageUI(eventArgs.User); 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
} }
/// <summary> /// <summary>

View File

@@ -20,7 +20,6 @@ namespace Content.Server.Tools
private void InitializeMultipleTools() private void InitializeMultipleTools()
{ {
SubscribeLocalEvent<MultipleToolComponent, ComponentStartup>(OnMultipleToolStartup); SubscribeLocalEvent<MultipleToolComponent, ComponentStartup>(OnMultipleToolStartup);
SubscribeLocalEvent<MultipleToolComponent, UseInHandEvent>(OnMultipleToolUsedInHand);
SubscribeLocalEvent<MultipleToolComponent, ActivateInWorldEvent>(OnMultipleToolActivated); SubscribeLocalEvent<MultipleToolComponent, ActivateInWorldEvent>(OnMultipleToolActivated);
SubscribeLocalEvent<MultipleToolComponent, ComponentGetState>(OnMultipleToolGetState); SubscribeLocalEvent<MultipleToolComponent, ComponentGetState>(OnMultipleToolGetState);
} }
@@ -32,14 +31,6 @@ namespace Content.Server.Tools
SetMultipleTool(uid, multiple, tool); 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) private void OnMultipleToolActivated(EntityUid uid, MultipleToolComponent multiple, ActivateInWorldEvent args)
{ {
if (args.Handled) if (args.Handled)

View File

@@ -35,7 +35,6 @@ namespace Content.Server.Tools
SubscribeLocalEvent<WelderComponent, IsHotEvent>(OnWelderIsHotEvent); SubscribeLocalEvent<WelderComponent, IsHotEvent>(OnWelderIsHotEvent);
SubscribeLocalEvent<WelderComponent, ExaminedEvent>(OnWelderExamine); SubscribeLocalEvent<WelderComponent, ExaminedEvent>(OnWelderExamine);
SubscribeLocalEvent<WelderComponent, SolutionChangedEvent>(OnWelderSolutionChange); SubscribeLocalEvent<WelderComponent, SolutionChangedEvent>(OnWelderSolutionChange);
SubscribeLocalEvent<WelderComponent, UseInHandEvent>(OnWelderUseInHand);
SubscribeLocalEvent<WelderComponent, ActivateInWorldEvent>(OnWelderActivate); SubscribeLocalEvent<WelderComponent, ActivateInWorldEvent>(OnWelderActivate);
SubscribeLocalEvent<WelderComponent, AfterInteractEvent>(OnWelderAfterInteract); SubscribeLocalEvent<WelderComponent, AfterInteractEvent>(OnWelderAfterInteract);
SubscribeLocalEvent<WelderComponent, ToolUseAttemptEvent>(OnWelderToolUseAttempt); SubscribeLocalEvent<WelderComponent, ToolUseAttemptEvent>(OnWelderToolUseAttempt);
@@ -238,11 +237,6 @@ namespace Content.Server.Tools
args.Handled = true; 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) private void OnWelderToolUseAttempt(EntityUid uid, WelderComponent welder, ToolUseAttemptEvent args)
{ {
if (args.Cancelled) if (args.Cancelled)

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Traitor.Uplink
SubscribeLocalEvent<UplinkComponent, ComponentInit>(OnInit); SubscribeLocalEvent<UplinkComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<UplinkComponent, ComponentRemove>(OnRemove); SubscribeLocalEvent<UplinkComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<UplinkComponent, UseInHandEvent>(OnUseHand); SubscribeLocalEvent<UplinkComponent, ActivateInWorldEvent>(OnActivate);
// UI events // UI events
SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(OnBuy); SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(OnBuy);
@@ -75,7 +75,7 @@ namespace Content.Server.Traitor.Uplink
RaiseLocalEvent(uid, new UplinkRemovedEvent()); 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) if (args.Handled)
return; return;

View File

@@ -710,8 +710,11 @@ namespace Content.Shared.Hands.Components
if (!TryGetActiveHeldEntity(out var heldEntity)) if (!TryGetActiveHeldEntity(out var heldEntity))
return; return;
EntitySystem.Get<SharedInteractionSystem>() var sys = EntitySystem.Get<SharedInteractionSystem>();
.TryUseInteraction(Owner, heldEntity.Value, altInteract); if (altInteract)
sys.AltInteract(Owner, heldEntity.Value);
else
sys.TryUseInteraction(Owner, heldEntity.Value);
} }
public void ActivateHeldEntity(string handName) public void ActivateHeldEntity(string handName)

View File

@@ -642,32 +642,29 @@ namespace Content.Shared.Interaction
#region Hands #region Hands
#region Use #region Use
/// <summary> /// <summary>
/// Activates the IUse behaviors of an entity /// Attempt to perform a use-interaction on an entity. If no interaction occurs, it will instead attempt to
/// Verifies that the user is capable of doing the use interaction first /// activate the entity.
/// </summary> /// </summary>
/// <param name="user"></param> public void TryUseInteraction(EntityUid user, EntityUid used)
/// <param name="used"></param>
public void TryUseInteraction(EntityUid user, EntityUid used, bool altInteract = false)
{ {
if (_actionBlockerSystem.CanUse(user)) if (_actionBlockerSystem.CanUse(user) && UseInteraction(user, used))
{ return;
if (altInteract)
AltInteract(user, used); // no use-interaction occurred. Attempt to activate the item instead.
else InteractionActivate(user, used);
UseInteraction(user, used);
}
} }
/// <summary> /// <summary>
/// Activates the IUse behaviors of an entity without first checking /// Activates the IUse behaviors of an entity without first checking
/// if the user is capable of doing the use interaction. /// if the user is capable of doing the use interaction.
/// </summary> /// </summary>
public void UseInteraction(EntityUid user, EntityUid used) /// <returns>True if the interaction was handled. False otherwise</returns>
public bool UseInteraction(EntityUid user, EntityUid used)
{ {
if (TryComp(used, out UseDelayComponent? delayComponent)) if (TryComp(used, out UseDelayComponent? delayComponent))
{ {
if (delayComponent.ActiveDelay) if (delayComponent.ActiveDelay)
return; return true; // if the item is on cooldown, we consider this handled.
delayComponent.BeginDelay(); delayComponent.BeginDelay();
} }
@@ -675,7 +672,7 @@ namespace Content.Shared.Interaction
var useMsg = new UseInHandEvent(user, used); var useMsg = new UseInHandEvent(user, used);
RaiseLocalEvent(used, useMsg); RaiseLocalEvent(used, useMsg);
if (useMsg.Handled) if (useMsg.Handled)
return; return true;
var uses = AllComps<IUse>(used).ToList(); var uses = AllComps<IUse>(used).ToList();
@@ -684,8 +681,10 @@ namespace Content.Shared.Interaction
{ {
// If a Use returns a status completion we finish our interaction // If a Use returns a status completion we finish our interaction
if (use.UseEntity(new UseEntityEventArgs(user))) if (use.UseEntity(new UseEntityEventArgs(user)))
return; return true;
} }
return false;
} }
/// <summary> /// <summary>
@@ -694,12 +693,17 @@ namespace Content.Shared.Interaction
/// <remarks> /// <remarks>
/// Uses the context menu verb list, and acts out the highest priority alternative interaction verb. /// Uses the context menu verb list, and acts out the highest priority alternative interaction verb.
/// </remarks> /// </remarks>
public void AltInteract(EntityUid user, EntityUid target) /// <returns>True if the interaction was handled, false otherwise.</returns>
public bool AltInteract(EntityUid user, EntityUid target)
{ {
// Get list of alt-interact verbs // Get list of alt-interact verbs
var verbs = _verbSystem.GetLocalVerbs(target, user, VerbType.Alternative)[VerbType.Alternative]; var verbs = _verbSystem.GetLocalVerbs(target, user, VerbType.Alternative)[VerbType.Alternative];
if (verbs.Any())
if (!verbs.Any())
return false;
_verbSystem.ExecuteVerb(verbs.First(), user, target); _verbSystem.ExecuteVerb(verbs.First(), user, target);
return true;
} }
#endregion #endregion

View File

@@ -16,15 +16,9 @@ public abstract class SharedTrayScannerSystem : EntitySystem
SubscribeLocalEvent<TrayScannerComponent, ComponentGetState>(OnTrayScannerGetState); SubscribeLocalEvent<TrayScannerComponent, ComponentGetState>(OnTrayScannerGetState);
SubscribeLocalEvent<TrayScannerComponent, ComponentHandleState>(OnTrayScannerHandleState); SubscribeLocalEvent<TrayScannerComponent, ComponentHandleState>(OnTrayScannerHandleState);
SubscribeLocalEvent<TrayScannerComponent, UseInHandEvent>(OnTrayScannerUsed);
SubscribeLocalEvent<TrayScannerComponent, ActivateInWorldEvent>(OnTrayScannerActivate); SubscribeLocalEvent<TrayScannerComponent, ActivateInWorldEvent>(OnTrayScannerActivate);
} }
private void OnTrayScannerUsed(EntityUid uid, TrayScannerComponent scanner, UseInHandEvent args)
{
ActivateTray(uid, scanner);
}
private void OnTrayScannerActivate(EntityUid uid, TrayScannerComponent scanner, ActivateInWorldEvent args) private void OnTrayScannerActivate(EntityUid uid, TrayScannerComponent scanner, ActivateInWorldEvent args)
{ {
ActivateTray(uid, scanner); ActivateTray(uid, scanner);