private void UseLock() { interacting = true; // Close it if (lockInRange.isOpen) { if (inventory.CheckInventoryFull()) { Debug.Log("Max inventory is 3"); return; } GameObject objectToAdd = lockInRange.Close(); inventory.AddItem(objectToAdd); } else { int tryKey = -1; tryKey = lockInRange.Open(inventory.GetItemIds()); // no valid key is possessed if (tryKey < 0) { return; } inventory.UseItem(tryKey, lockInRange); } }