/// <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); }
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); } }
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); }
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); }