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); } }
private short GetFirstPlace(InventoryType type, int backPack) { Inventory result; for (short i = 0; i < 48 + (backPack * 12); i++) { result = Inventory.FirstOrDefault(c => c.Type == type && c.Slot.Equals(i)); if (result == null) { return(i); } } return(-1); }
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); }
public T LoadBySlotAndType <T>(short slot, InventoryType type) where T : ItemInstance { return((T)Inventory.FirstOrDefault(i => i.ItemInstance.GetType().Equals(typeof(T)) && i.Slot == slot && i.Type == type)?.ItemInstance); }
public T LoadByItemInstance <T>(Guid id) where T : ItemInstanceDTO { return((T)Inventory.FirstOrDefault(i => i.ItemInstance.Id.Equals(id))?.ItemInstance); }
public Inventory GetInventoryByItemInstanceId(Guid id) { return(Inventory.FirstOrDefault(i => i.ItemInstance.Id.Equals(id))); }