コード例 #1
0
        /// <summary>
        /// Takes a Single Inventory including ItemInstance from the List and removes it.
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public Inventory TakeInventory(short slot, InventoryType type)
        {
            Inventory inventoryToTake = Inventory.SingleOrDefault(i => i.Slot == slot && i.Type == type);

            Inventory.Remove(inventoryToTake);
            return(inventoryToTake);
        }
コード例 #2
0
        public void DeleteFromSlotAndType(short slot, InventoryType type)
        {
            Logger.Debug($"Slot: {slot} Type: {type}", Owner.Session.SessionId);
            Inventory inv = Inventory.FirstOrDefault(i => i.Slot.Equals(slot) && i.Type.Equals(type));

            if (inv != null)
            {
                Inventory.Remove(inv);
            }
        }
コード例 #3
0
        public Tuple <short, InventoryType> DeleteByInventoryItemId(Guid id)
        {
            Logger.Debug(id.ToString(), Owner.Session.SessionId);
            Tuple <short, InventoryType> removedPlace = new Tuple <short, InventoryType>(0, 0);
            Inventory inv = Inventory.FirstOrDefault(i => i.ItemInstance.Id.Equals(id));

            if (inv != null)
            {
                removedPlace = new Tuple <short, InventoryType>(inv.Slot, inv.Type);
                Inventory.Remove(inv);
            }

            return(removedPlace);
        }
コード例 #4
0
        public Inventory RemoveItemAmountFromInventory(byte amount, Guid id)
        {
            Logger.Debug($"InventoryId: {id} amount: {amount}", Owner.Session.SessionId);
            Inventory inv = Inventory.FirstOrDefault(i => i.Id.Equals(id));

            if (inv != null)
            {
                inv.ItemInstance.Amount -= amount;
                if (inv.ItemInstance.Amount <= 0)
                {
                    Inventory.Remove(inv);
                    return(null);
                }
            }

            return(inv);
        }