示例#1
0
 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
 }
示例#2
0
        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();
            }
        }