diff --git a/Assets/Scripts/Controls/InventoryInterface.cs b/Assets/Scripts/Controls/InventoryInterface.cs index 493429c..3f0ad03 100644 --- a/Assets/Scripts/Controls/InventoryInterface.cs +++ b/Assets/Scripts/Controls/InventoryInterface.cs @@ -98,7 +98,6 @@ namespace Cyber.Controls { private List ItemGridCells; private List ItemGridCellMeshes; private int ItemGridSelectedIndex; - private Item SelectedItem = null; private Color IconInventoryColor; private Color IconStatusColor; @@ -139,9 +138,14 @@ namespace Cyber.Controls { if (ItemGridCells.Contains(LookedAt.collider.transform)) { // Interacting with the item list CurrentIndex = int.Parse(LookedAt.collider.name.Split(' ')[1]); - if (Input.GetButtonDown("Activate")) { - if (ItemGridSelectedIndex == CurrentIndex && SelectedItem != null) { - // Selected index was already this => equip (double-clicked) + if (Input.GetButtonDown("Activate") || Input.GetButtonDown("Equip")) { + ItemGridSelectedIndex = CurrentIndex; + } + if (Input.GetButtonDown("Equip")) { + // Selected index was already this => equip (double-clicked) + Item SelectedItem = Inventory.Drive.Interface.GetItemAt(ItemGridSelectedIndex % (int) ItemGridDimensions.x, + ItemGridSelectedIndex / (int) ItemGridDimensions.y); + if (SelectedItem != null) { Item Equipped = Inventory.Equipped.GetItem(SelectedItem.Slot); if (Equipped != null && Equipped.ID == SelectedItem.ID) { Inventory.Equipped.ClearSlot(SelectedItem.Slot); @@ -151,7 +155,6 @@ namespace Cyber.Controls { Client.Send(PktType.InventoryAction, new InventoryActionPkt(InventoryAction.Equip, SelectedItem.ID)); } } - ItemGridSelectedIndex = CurrentIndex; } } else if (Mesh != null) { float InvBrightness = 1.1f; @@ -221,9 +224,6 @@ namespace Cyber.Controls { } if (ItemGridSelectedIndex == i) { - // Update the selected item - SelectedItem = Item; - // Set preview information SetPreviewMesh(Mesh); TextTextureProperties NameProps = ItemNameText.TextProperties; diff --git a/Assets/Scripts/Items/DriveInterface.cs b/Assets/Scripts/Items/DriveInterface.cs index d16dde2..2081515 100644 --- a/Assets/Scripts/Items/DriveInterface.cs +++ b/Assets/Scripts/Items/DriveInterface.cs @@ -38,7 +38,8 @@ namespace Cyber.Items { /// The y-coordinate /// The item or null public Item GetItemAt(int x, int y) { - if (ItemGrid[y, x] == -1) { + if (y < 0 || x < 0 || y >= GetHeight() || x >= GetWidth() || + ItemGrid[y, x] == -1) { return null; } else { return Drive.GetItem(ItemGrid[y, x]);