public DroppableItem(DroppableItem item, int count, IItemContainer startingLocation) { ItemId = item.ItemId; Name = item.Name; Count = count; Location = startingLocation; startingLocation.Add(this); }
public void Remove(DroppableItem item) { if (Item != item) { throw new Exception("Removing wrong item"); } Item = null; Notify("Item"); }
public int Add(DroppableItem item) { if (Item != null) { throw new Exception("Cant equip weapon without removing existing on first"); } Item = item; Notify("Item"); return(1); }
public void SetCount(DroppableItem item, int count) { if (count > 1) { throw new Exception("Cant be over 1"); } if (count == 0) { Item = null; } Notify("Item"); }
private void OnDroppedItemsAlert(DroppedItemAlert alert) { var existingItem = DroppedItems.FirstOrDefault(i => i.ItemId == alert.DroppedItem.ItemId); if (existingItem != null) { existingItem.SetCount(existingItem.Count + alert.DroppedItem.Count); } else { var item = new DroppableItem(alert.DroppedItem, DroppedItems); item.OnItemMoved += OnItemMoved; } Notify("DroppedItems"); }
private async void GetInventory() { var result = await client.SendRequest(new GetInventoryRequest(), player); if (result.Success && result.data is InventoryResponse response) { foreach (var item in response.Inventory) { var droppableItem = new DroppableItem(item, Items); droppableItem.OnItemMoved += OnItemMoved; } foreach (var item in response.DroppedItems) { var droppableItem = new DroppableItem(item, DroppedItems); droppableItem.OnItemMoved += OnItemMoved; } Equipment.EquipAll(response.EquippedItems, OnItemMoved); } else { throw new Exception("Got wrong result"); } }
public bool FitsInSlot(DroppableItem item) { return(item.SlotType != null && item.SlotType == Type); }