From a586b36a9e0636b1e16fd93412750c34c8e3bd18 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 10 May 2021 14:00:09 -0400 Subject: [PATCH 1/2] Implement changing the number of slots in a players hotbar --- .../Scripts/Characters/State/PlayerCharacterPrivateState.cs | 2 +- Core.cpk/Scripts/Characters/State/PlayerConstants.cs | 5 +++++ .../InputListeners/ClientComponentHotBarHelper.cs | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Core.cpk/Scripts/Characters/State/PlayerCharacterPrivateState.cs b/Core.cpk/Scripts/Characters/State/PlayerCharacterPrivateState.cs index e2c4ea680..ef7c25d57 100644 --- a/Core.cpk/Scripts/Characters/State/PlayerCharacterPrivateState.cs +++ b/Core.cpk/Scripts/Characters/State/PlayerCharacterPrivateState.cs @@ -154,7 +154,7 @@ public void ServerInitState(ICharacter character) this.ContainerHotbar ??= serverItemsService.CreateContainer( character, - slotsCount: 10); + slotsCount: PlayerConstants.HotbarSlotsCount); this.CraftingQueue ??= new CharacterCraftingQueue(); this.Skills ??= new PlayerCharacterSkills(); diff --git a/Core.cpk/Scripts/Characters/State/PlayerConstants.cs b/Core.cpk/Scripts/Characters/State/PlayerConstants.cs index 723c94745..3909da78f 100644 --- a/Core.cpk/Scripts/Characters/State/PlayerConstants.cs +++ b/Core.cpk/Scripts/Characters/State/PlayerConstants.cs @@ -7,5 +7,10 @@ public static class PlayerConstants /// Please note that it doesn't apply to the already registered players (their inventory container is already created). /// public const int InventorySlotsCount = 40; + /// + /// The number of the hotbar slots is configured here. + /// Please note that it doesn't apply to the already registered players (their hotbar container is already created). + /// + public const int HotbarSlotsCount = 10; } } \ No newline at end of file diff --git a/Core.cpk/Scripts/ClientComponents/InputListeners/ClientComponentHotBarHelper.cs b/Core.cpk/Scripts/ClientComponents/InputListeners/ClientComponentHotBarHelper.cs index 88abf3414..5b7b72a91 100644 --- a/Core.cpk/Scripts/ClientComponents/InputListeners/ClientComponentHotBarHelper.cs +++ b/Core.cpk/Scripts/ClientComponents/InputListeners/ClientComponentHotBarHelper.cs @@ -140,6 +140,11 @@ private void ProcessInputUpdate() // the key was pressed var hotbarSlotId = pair.Value; + if (hotbarSlotId >= ClientHotbarSelectedItemManager.ContainerHotbar.SlotsCount) + { + break; + } + if (Input.IsKeyHeld(InputKey.Control, evenIfHandled: true) || Input.IsKeyHeld(InputKey.Alt, evenIfHandled: true)) { From eb5f90d77ec9c681d79a7873bfc2e12b3d875bf8 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 10 May 2021 14:23:18 -0400 Subject: [PATCH 2/2] Add note about odd numbers for hotbar slots constant --- Core.cpk/Scripts/Characters/State/PlayerConstants.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Core.cpk/Scripts/Characters/State/PlayerConstants.cs b/Core.cpk/Scripts/Characters/State/PlayerConstants.cs index 3909da78f..122beec75 100644 --- a/Core.cpk/Scripts/Characters/State/PlayerConstants.cs +++ b/Core.cpk/Scripts/Characters/State/PlayerConstants.cs @@ -10,6 +10,7 @@ public static class PlayerConstants /// /// The number of the hotbar slots is configured here. /// Please note that it doesn't apply to the already registered players (their hotbar container is already created). + /// Also note if this value is odd then it will create a graphical bug in the display of the hotbar. See https://i.imgur.com/Dl6sRBi.png /// public const int HotbarSlotsCount = 10; }