Add keybind for swapping hands in the other direction (#37588)
add swap hands reverse
This commit is contained in:
@@ -56,6 +56,7 @@ namespace Content.Client.Input
|
||||
human.AddFunction(EngineKeyFunctions.MoveRight);
|
||||
human.AddFunction(EngineKeyFunctions.Walk);
|
||||
human.AddFunction(ContentKeyFunctions.SwapHands);
|
||||
human.AddFunction(ContentKeyFunctions.SwapHandsReverse);
|
||||
human.AddFunction(ContentKeyFunctions.Drop);
|
||||
human.AddFunction(ContentKeyFunctions.UseItemInHand);
|
||||
human.AddFunction(ContentKeyFunctions.AltUseItemInHand);
|
||||
@@ -100,6 +101,7 @@ namespace Content.Client.Input
|
||||
aghost.AddFunction(EngineKeyFunctions.MoveRight);
|
||||
aghost.AddFunction(EngineKeyFunctions.Walk);
|
||||
aghost.AddFunction(ContentKeyFunctions.SwapHands);
|
||||
aghost.AddFunction(ContentKeyFunctions.SwapHandsReverse);
|
||||
aghost.AddFunction(ContentKeyFunctions.Drop);
|
||||
aghost.AddFunction(ContentKeyFunctions.UseItemInHand);
|
||||
aghost.AddFunction(ContentKeyFunctions.AltUseItemInHand);
|
||||
|
||||
@@ -181,6 +181,7 @@ namespace Content.Client.Options.UI.Tabs
|
||||
AddButton(ContentKeyFunctions.Drop);
|
||||
AddButton(ContentKeyFunctions.ExamineEntity);
|
||||
AddButton(ContentKeyFunctions.SwapHands);
|
||||
AddButton(ContentKeyFunctions.SwapHandsReverse);
|
||||
AddButton(ContentKeyFunctions.MoveStoredItem);
|
||||
AddButton(ContentKeyFunctions.RotateStoredItem);
|
||||
AddButton(ContentKeyFunctions.SaveItemLocation);
|
||||
|
||||
@@ -31,6 +31,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
.Bind(ContentKeyFunctions.UseItemInHand, InputCmdHandler.FromDelegate(HandleUseItem, handle: false, outsidePrediction: false))
|
||||
.Bind(ContentKeyFunctions.AltUseItemInHand, InputCmdHandler.FromDelegate(HandleAltUseInHand, handle: false, outsidePrediction: false))
|
||||
.Bind(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(SwapHandsPressed, handle: false, outsidePrediction: false))
|
||||
.Bind(ContentKeyFunctions.SwapHandsReverse, InputCmdHandler.FromDelegate(SwapHandsReversePressed, handle: false, outsidePrediction: false))
|
||||
.Bind(ContentKeyFunctions.Drop, new PointerInputCmdHandler(DropPressed))
|
||||
.Register<SharedHandsSystem>();
|
||||
}
|
||||
@@ -79,6 +80,16 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
}
|
||||
|
||||
private void SwapHandsPressed(ICommonSession? session)
|
||||
{
|
||||
SwapHands(session, false);
|
||||
}
|
||||
|
||||
private void SwapHandsReversePressed(ICommonSession? session)
|
||||
{
|
||||
SwapHands(session, true);
|
||||
}
|
||||
|
||||
private void SwapHands(ICommonSession? session, bool reverse)
|
||||
{
|
||||
if (!TryComp(session?.AttachedEntity, out HandsComponent? component))
|
||||
return;
|
||||
@@ -89,8 +100,9 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
if (component.ActiveHand == null || component.Hands.Count < 2)
|
||||
return;
|
||||
|
||||
var newActiveIndex = component.SortedHands.IndexOf(component.ActiveHand.Name) + 1;
|
||||
var nextHand = component.SortedHands[newActiveIndex % component.Hands.Count];
|
||||
var currentIndex = component.SortedHands.IndexOf(component.ActiveHand.Name);
|
||||
var newActiveIndex = (currentIndex + (reverse ? -1 : 1) + component.Hands.Count) % component.Hands.Count;
|
||||
var nextHand = component.SortedHands[newActiveIndex];
|
||||
|
||||
TrySetActiveHand(session.AttachedEntity.Value, nextHand, component);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Content.Shared.Input
|
||||
public static readonly BoundKeyFunction OpenBelt = "OpenBelt";
|
||||
public static readonly BoundKeyFunction OpenAHelp = "OpenAHelp";
|
||||
public static readonly BoundKeyFunction SwapHands = "SwapHands";
|
||||
public static readonly BoundKeyFunction SwapHandsReverse = "SwapHandsReverse";
|
||||
public static readonly BoundKeyFunction MoveStoredItem = "MoveStoredItem";
|
||||
public static readonly BoundKeyFunction RotateStoredItem = "RotateStoredItem";
|
||||
public static readonly BoundKeyFunction SaveItemLocation = "SaveItemLocation";
|
||||
|
||||
@@ -151,6 +151,7 @@ ui-options-function-alt-activate-item-in-world = Alternative activate item in wo
|
||||
ui-options-function-drop = Drop item
|
||||
ui-options-function-examine-entity = Examine
|
||||
ui-options-function-swap-hands = Swap hands
|
||||
ui-options-function-swap-hands-reverse = Swap hands (other direction)
|
||||
ui-options-function-move-stored-item = Move stored item
|
||||
ui-options-function-rotate-stored-item = Rotate stored item
|
||||
ui-options-function-save-item-location = Save item location
|
||||
@@ -227,16 +228,16 @@ ui-options-function-hotbar7 = Hotbar slot 7
|
||||
ui-options-function-hotbar8 = Hotbar slot 8
|
||||
ui-options-function-hotbar9 = Hotbar slot 9
|
||||
ui-options-function-hotbar0 = Hotbar slot 0
|
||||
ui-options-function-hotbarshift1 = Hotbar slot Shift+1
|
||||
ui-options-function-hotbarshift2 = Hotbar slot Shift+2
|
||||
ui-options-function-hotbarshift3 = Hotbar slot Shift+3
|
||||
ui-options-function-hotbarshift4 = Hotbar slot Shift+4
|
||||
ui-options-function-hotbarshift5 = Hotbar slot Shift+5
|
||||
ui-options-function-hotbarshift6 = Hotbar slot Shift+6
|
||||
ui-options-function-hotbarshift7 = Hotbar slot Shift+7
|
||||
ui-options-function-hotbarshift8 = Hotbar slot Shift+8
|
||||
ui-options-function-hotbarshift9 = Hotbar slot Shift+9
|
||||
ui-options-function-hotbarshift0 = Hotbar slot Shift+0
|
||||
ui-options-function-hotbar-shift1 = Hotbar slot Shift+1
|
||||
ui-options-function-hotbar-shift2 = Hotbar slot Shift+2
|
||||
ui-options-function-hotbar-shift3 = Hotbar slot Shift+3
|
||||
ui-options-function-hotbar-shift4 = Hotbar slot Shift+4
|
||||
ui-options-function-hotbar-shift5 = Hotbar slot Shift+5
|
||||
ui-options-function-hotbar-shift6 = Hotbar slot Shift+6
|
||||
ui-options-function-hotbar-shift7 = Hotbar slot Shift+7
|
||||
ui-options-function-hotbar-shift8 = Hotbar slot Shift+8
|
||||
ui-options-function-hotbar-shift9 = Hotbar slot Shift+9
|
||||
ui-options-function-hotbar-shift0 = Hotbar slot Shift+0
|
||||
ui-options-function-loadout1 = Hotbar Loadout 1
|
||||
ui-options-function-loadout2 = Hotbar Loadout 2
|
||||
ui-options-function-loadout3 = Hotbar Loadout 3
|
||||
|
||||
@@ -163,6 +163,10 @@ binds:
|
||||
- function: SwapHands
|
||||
type: State
|
||||
key: X
|
||||
- function: SwapHandsReverse
|
||||
type: State
|
||||
key: X
|
||||
mod1: Shift
|
||||
- function: MoveStoredItem
|
||||
type: State
|
||||
key: MouseLeft
|
||||
|
||||
Reference in New Issue
Block a user