Add alt click to hands (#12330)
This commit is contained in:
@@ -243,6 +243,16 @@ namespace Content.Client.Hands.Systems
|
|||||||
_verbs.VerbMenu.OpenVerbMenu(entity);
|
_verbs.VerbMenu.OpenVerbMenu(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UIHandAltActivateItem(string handName)
|
||||||
|
{
|
||||||
|
if (!TryGetPlayerHands(out var hands)
|
||||||
|
|| !hands.Hands.TryGetValue(handName, out var hand)
|
||||||
|
|| hand.HeldEntity is not { Valid: true } entity)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EntityManager.RaisePredictiveEvent(new RequestHandAltInteractEvent(entity));
|
||||||
|
}
|
||||||
|
|
||||||
#region visuals
|
#region visuals
|
||||||
|
|
||||||
private void HandleItemAdded(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args)
|
private void HandleItemAdded(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args)
|
||||||
|
|||||||
@@ -69,17 +69,25 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Function == ContentKeyFunctions.ExamineEntity)
|
if (args.Function == EngineKeyFunctions.UIClick)
|
||||||
{
|
{
|
||||||
_handsSystem.UIInventoryExamine(hand.SlotName);
|
_handsSystem.UIHandClick(_playerHandsComponent, hand.SlotName);
|
||||||
}
|
}
|
||||||
else if (args.Function == EngineKeyFunctions.UseSecondary)
|
else if (args.Function == EngineKeyFunctions.UseSecondary)
|
||||||
{
|
{
|
||||||
_handsSystem.UIHandOpenContextMenu(hand.SlotName);
|
_handsSystem.UIHandOpenContextMenu(hand.SlotName);
|
||||||
}
|
}
|
||||||
else if (args.Function == EngineKeyFunctions.UIClick)
|
else if (args.Function == ContentKeyFunctions.ActivateItemInWorld)
|
||||||
{
|
{
|
||||||
_handsSystem.UIHandClick(_playerHandsComponent, hand.SlotName);
|
_handsSystem.UIHandActivate(hand.SlotName);
|
||||||
|
}
|
||||||
|
else if (args.Function == ContentKeyFunctions.AltActivateItemInWorld)
|
||||||
|
{
|
||||||
|
_handsSystem.UIHandAltActivateItem(hand.SlotName);
|
||||||
|
}
|
||||||
|
else if (args.Function == ContentKeyFunctions.ExamineEntity)
|
||||||
|
{
|
||||||
|
_handsSystem.UIInventoryExamine(hand.SlotName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
SubscribeAllEvent<RequestHandInteractUsingEvent>(HandleInteractUsingInHand);
|
SubscribeAllEvent<RequestHandInteractUsingEvent>(HandleInteractUsingInHand);
|
||||||
SubscribeAllEvent<RequestUseInHandEvent>(HandleUseInHand);
|
SubscribeAllEvent<RequestUseInHandEvent>(HandleUseInHand);
|
||||||
SubscribeAllEvent<RequestMoveHandItemEvent>(HandleMoveItemFromHand);
|
SubscribeAllEvent<RequestMoveHandItemEvent>(HandleMoveItemFromHand);
|
||||||
|
SubscribeAllEvent<RequestHandAltInteractEvent>(HandleHandAltInteract);
|
||||||
|
|
||||||
SubscribeLocalEvent<SharedHandsComponent, ExaminedEvent>(HandleExamined);
|
SubscribeLocalEvent<SharedHandsComponent, ExaminedEvent>(HandleExamined);
|
||||||
|
|
||||||
@@ -65,6 +66,12 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
TryInteractHandWithActiveHand(args.SenderSession.AttachedEntity.Value, msg.HandName);
|
TryInteractHandWithActiveHand(args.SenderSession.AttachedEntity.Value, msg.HandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleHandAltInteract(RequestHandAltInteractEvent msg, EntitySessionEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.SenderSession.AttachedEntity != null)
|
||||||
|
TryUseItemInHand(args.SenderSession.AttachedEntity.Value, true);
|
||||||
|
}
|
||||||
|
|
||||||
private void SwapHandsPressed(ICommonSession? session)
|
private void SwapHandsPressed(ICommonSession? session)
|
||||||
{
|
{
|
||||||
if (!TryComp(session?.AttachedEntity, out SharedHandsComponent? component))
|
if (!TryComp(session?.AttachedEntity, out SharedHandsComponent? component))
|
||||||
|
|||||||
@@ -267,6 +267,20 @@ namespace Content.Shared.Hands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event raised by a client when they want to alt interact with the item currently in their hands.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class RequestHandAltInteractEvent : EntityEventArgs
|
||||||
|
{
|
||||||
|
public EntityUid Entity { get; }
|
||||||
|
|
||||||
|
public RequestHandAltInteractEvent(EntityUid entity)
|
||||||
|
{
|
||||||
|
Entity = entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class HandCountChangedEvent : EntityEventArgs
|
public sealed class HandCountChangedEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
public HandCountChangedEvent(EntityUid sender)
|
public HandCountChangedEvent(EntityUid sender)
|
||||||
|
|||||||
Reference in New Issue
Block a user