Make use-in-hand default to activation interactions. (#5951)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace Content.Server.Dice
|
||||
|
||||
SubscribeLocalEvent<DiceComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<DiceComponent, ActivateInWorldEvent>(OnActivate);
|
||||
SubscribeLocalEvent<DiceComponent, UseInHandEvent>(OnUse);
|
||||
SubscribeLocalEvent<DiceComponent, LandEvent>(OnLand);
|
||||
SubscribeLocalEvent<DiceComponent, ExaminedEvent>(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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Server.Labels
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<HandLabelerComponent, AfterInteractEvent>(AfterInteractOn);
|
||||
SubscribeLocalEvent<HandLabelerComponent, UseInHandEvent>(OnUseInHand);
|
||||
SubscribeLocalEvent<HandLabelerComponent, ActivateInWorldEvent>(OnActivate);
|
||||
// Bound UI subscriptions
|
||||
SubscribeLocalEvent<HandLabelerComponent, HandLabelerLabelChangedMessage>(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;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<HandheldLightComponent, GetActivationVerbsEvent>(AddToggleLightVerb);
|
||||
SubscribeLocalEvent<HandheldLightComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<HandheldLightComponent, UseInHandEvent>(OnUse);
|
||||
SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(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;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Content.Server.PDA
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PDAComponent, ActivateInWorldEvent>(OnActivateInWorld);
|
||||
SubscribeLocalEvent<PDAComponent, UseInHandEvent>(OnUse);
|
||||
SubscribeLocalEvent<PDAComponent, LightToggleEvent>(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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace Content.Server.Pinpointer
|
||||
public override void 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);
|
||||
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace Content.Server.Tools
|
||||
private void InitializeMultipleTools()
|
||||
{
|
||||
SubscribeLocalEvent<MultipleToolComponent, ComponentStartup>(OnMultipleToolStartup);
|
||||
SubscribeLocalEvent<MultipleToolComponent, UseInHandEvent>(OnMultipleToolUsedInHand);
|
||||
SubscribeLocalEvent<MultipleToolComponent, ActivateInWorldEvent>(OnMultipleToolActivated);
|
||||
SubscribeLocalEvent<MultipleToolComponent, ComponentGetState>(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)
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace Content.Server.Tools
|
||||
SubscribeLocalEvent<WelderComponent, IsHotEvent>(OnWelderIsHotEvent);
|
||||
SubscribeLocalEvent<WelderComponent, ExaminedEvent>(OnWelderExamine);
|
||||
SubscribeLocalEvent<WelderComponent, SolutionChangedEvent>(OnWelderSolutionChange);
|
||||
SubscribeLocalEvent<WelderComponent, UseInHandEvent>(OnWelderUseInHand);
|
||||
SubscribeLocalEvent<WelderComponent, ActivateInWorldEvent>(OnWelderActivate);
|
||||
SubscribeLocalEvent<WelderComponent, AfterInteractEvent>(OnWelderAfterInteract);
|
||||
SubscribeLocalEvent<WelderComponent, ToolUseAttemptEvent>(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)
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Content.Server.Traitor.Uplink
|
||||
|
||||
SubscribeLocalEvent<UplinkComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<UplinkComponent, ComponentRemove>(OnRemove);
|
||||
SubscribeLocalEvent<UplinkComponent, UseInHandEvent>(OnUseHand);
|
||||
SubscribeLocalEvent<UplinkComponent, ActivateInWorldEvent>(OnActivate);
|
||||
|
||||
// UI events
|
||||
SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(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;
|
||||
|
||||
@@ -710,8 +710,11 @@ namespace Content.Shared.Hands.Components
|
||||
if (!TryGetActiveHeldEntity(out var heldEntity))
|
||||
return;
|
||||
|
||||
EntitySystem.Get<SharedInteractionSystem>()
|
||||
.TryUseInteraction(Owner, heldEntity.Value, altInteract);
|
||||
var sys = EntitySystem.Get<SharedInteractionSystem>();
|
||||
if (altInteract)
|
||||
sys.AltInteract(Owner, heldEntity.Value);
|
||||
else
|
||||
sys.TryUseInteraction(Owner, heldEntity.Value);
|
||||
}
|
||||
|
||||
public void ActivateHeldEntity(string handName)
|
||||
|
||||
@@ -642,32 +642,29 @@ namespace Content.Shared.Interaction
|
||||
#region Hands
|
||||
#region Use
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="used"></param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates the IUse behaviors of an entity without first checking
|
||||
/// if the user is capable of doing the use interaction.
|
||||
/// </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 (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<IUse>(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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -694,12 +693,17 @@ namespace Content.Shared.Interaction
|
||||
/// <remarks>
|
||||
/// Uses the context menu verb list, and acts out the highest priority alternative interaction verb.
|
||||
/// </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
|
||||
var verbs = _verbSystem.GetLocalVerbs(target, user, VerbType.Alternative)[VerbType.Alternative];
|
||||
if (verbs.Any())
|
||||
|
||||
if (!verbs.Any())
|
||||
return false;
|
||||
|
||||
_verbSystem.ExecuteVerb(verbs.First(), user, target);
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -16,15 +16,9 @@ public abstract class SharedTrayScannerSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<TrayScannerComponent, ComponentGetState>(OnTrayScannerGetState);
|
||||
SubscribeLocalEvent<TrayScannerComponent, ComponentHandleState>(OnTrayScannerHandleState);
|
||||
SubscribeLocalEvent<TrayScannerComponent, UseInHandEvent>(OnTrayScannerUsed);
|
||||
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)
|
||||
{
|
||||
ActivateTray(uid, scanner);
|
||||
|
||||
Reference in New Issue
Block a user