public bool GetEmptySlot(out byte pSlot) //cpu intensive? { pSlot = 0; for (byte i = 0; i < (InventoryCount * 24); ++i) { if (!InventoryItems.ContainsKey(i)) { pSlot = i; return(true); } } return(false); //no more empty slots found }
public void AddToInventory(Item pItem) { try { locker.WaitOne(); if (InventoryItems.ContainsKey((byte)pItem.Slot)) { InventoryItems[(byte)pItem.Slot].Delete(); //removes from DB InventoryItems.Remove((byte)pItem.Slot); } InventoryItems.Add((byte)pItem.Slot, pItem); } finally { locker.ReleaseMutex(); } }