public static void ClearRandomQuickSlot() { QuickSlots quickSlots = Inventory.main.quickSlots; // Find all slots which have items in them List <int> activeSlots = new List <int>(); for (int i = 0; i < quickSlots.slotCount; i++) { if (quickSlots.GetSlotItem(i) != null) { activeSlots.Add(i); } } if (activeSlots.Count == 0) { // Prevent OutOfBounds errors return; } System.Random random = new System.Random(); int randomSlotID = activeSlots[random.Next(0, activeSlots.Count)]; quickSlots.Unbind(randomSlotID); }