Hotbar Improvements + Item Action Integration Test (#2749)
* my IDE keeps wanting to change this so.... * Add item actions integration test, fix bug where empty item action dict was left in SharedActionsComponent state * bigger hotbar arrows * nice wide hotbar pagination hitboxes * add ability to switch hotbar loadout via keybinds * always highlight on drag over of actions hotbar * dont rely on content entity for integration test
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Mobs
|
||||
[ComponentReference(typeof(SharedActionsComponent))]
|
||||
public sealed class ClientActionsComponent : SharedActionsComponent
|
||||
{
|
||||
public const byte Hotbars = 10;
|
||||
public const byte Hotbars = 9;
|
||||
public const byte Slots = 10;
|
||||
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
@@ -106,6 +106,11 @@ namespace Content.Client.GameObjects.Components.Mobs
|
||||
_ui?.HandleHotbarKeybind(slot, args);
|
||||
}
|
||||
|
||||
public void HandleChangeHotbarKeybind(byte hotbar, in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
_ui?.HandleChangeHotbarKeybind(hotbar, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the displayed hotbar (and menu) based on current state of actions.
|
||||
/// </summary>
|
||||
|
||||
@@ -42,6 +42,24 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
HandleHotbarKeybind(8))
|
||||
.Bind(ContentKeyFunctions.Hotbar0,
|
||||
HandleHotbarKeybind(9))
|
||||
.Bind(ContentKeyFunctions.Loadout1,
|
||||
HandleChangeHotbarKeybind(0))
|
||||
.Bind(ContentKeyFunctions.Loadout2,
|
||||
HandleChangeHotbarKeybind(1))
|
||||
.Bind(ContentKeyFunctions.Loadout3,
|
||||
HandleChangeHotbarKeybind(2))
|
||||
.Bind(ContentKeyFunctions.Loadout4,
|
||||
HandleChangeHotbarKeybind(3))
|
||||
.Bind(ContentKeyFunctions.Loadout5,
|
||||
HandleChangeHotbarKeybind(4))
|
||||
.Bind(ContentKeyFunctions.Loadout6,
|
||||
HandleChangeHotbarKeybind(5))
|
||||
.Bind(ContentKeyFunctions.Loadout7,
|
||||
HandleChangeHotbarKeybind(6))
|
||||
.Bind(ContentKeyFunctions.Loadout8,
|
||||
HandleChangeHotbarKeybind(7))
|
||||
.Bind(ContentKeyFunctions.Loadout9,
|
||||
HandleChangeHotbarKeybind(8))
|
||||
// when selecting a target, we intercept clicks in the game world, treating them as our target selection. We want to
|
||||
// take priority before any other systems handle the click.
|
||||
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(TargetingOnUse),
|
||||
@@ -66,6 +84,20 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
|
||||
actionsComponent.HandleHotbarKeybind(slot, args);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private PointerInputCmdHandler HandleChangeHotbarKeybind(byte hotbar)
|
||||
{
|
||||
// delegate to the ActionsUI, simulating a click on it
|
||||
return new((in PointerInputCmdHandler.PointerInputCmdArgs args) =>
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false;
|
||||
|
||||
actionsComponent.HandleChangeHotbarKeybind(hotbar, args);
|
||||
return true;
|
||||
},
|
||||
false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user