public void RemoveItemFromInventory(Gameitem item) { Inventory.Remove(item); GroupedInventory itemToRemove = GroupedInventory.FirstOrDefault(gi => gi.Item == item); if (itemToRemove != null) { if (itemToRemove.Quantity == 1) { GroupedInventory.Remove(itemToRemove); } else { itemToRemove.Quantity--; } } }
public void RemoveItemFromInventory(Item item) { Inventory.Remove(item); InventoryItem inventoryItemToRemove = GroupedInventory.FirstOrDefault(gi => gi.GameItem == item); if (inventoryItemToRemove != null) { if (inventoryItemToRemove.Quantity == 1) { GroupedInventory.Remove(inventoryItemToRemove); } else { inventoryItemToRemove.Quantity--; } } OnPropertyChanged(nameof(Weapons)); OnPropertyChanged(nameof(Armors)); OnPropertyChanged(nameof(Gloves)); OnPropertyChanged(nameof(Boots)); }
public void RemoveItemFromInventory(Item item) { Inventory.Remove(item); // Check if item is unique // If unique, return the exact matching item // If not unique, return first or default grouped item with same item id in it GroupedInventoryItem stackedItemToRemove = item.IsUnique ? GroupedInventory.FirstOrDefault(gi => gi.Item == item) : GroupedInventory.FirstOrDefault(gi => gi.Item.ID == item.ID); if (stackedItemToRemove != null) { if (stackedItemToRemove.Quantity == 1) { GroupedInventory.Remove(stackedItemToRemove); } else { stackedItemToRemove.Quantity--; } } }