/// <summary> /// Attempts to get the best slot for an item location to move into this container. Returns null if unsuccessful. /// </summary> /// <param name="itemToMove">The item location to move into this container.</param> /// <returns></returns> public ItemLocation GetBestSlot(ItemLocation itemToMove) { if (!this.IsOpen) { return(null); } // check if item is non-stackable if (itemToMove.ItemCount == 0) { return(this.GetFirstEmptySlot()); } foreach (Item item in this.GetItems()) { if (item.ID != itemToMove.ItemID) { continue; } if (item.Count + itemToMove.ItemCount <= 100) { return(item.ToItemLocation()); } } return(this.GetFirstEmptySlot()); }
public ItemLocation GetBestSlot(ItemLocation itemLoc, bool mustBeOtherContainer = true) { foreach (Container c in this.GetContainers()) { if (mustBeOtherContainer && c.ContainsItemLocation(itemLoc)) { continue; } var best = c.GetBestSlot(itemLoc); if (best != null) { return(best); } } return(null); }
/// <summary> /// Attempts to get the best slot for an item location to move into this container. Returns null if unsuccessful. /// </summary> /// <param name="itemToMove">The item location to move into this container.</param> /// <returns></returns> public ItemLocation GetBestSlot(ItemLocation itemToMove) { if (!this.IsOpen) return null; // check if item is non-stackable if (itemToMove.ItemCount == 0) return this.GetFirstEmptySlot(); foreach (Item item in this.GetItems()) { if (item.ID != itemToMove.ItemID) continue; if (item.Count + itemToMove.ItemCount <= 100) return item.ToItemLocation(); } return this.GetFirstEmptySlot(); }
public bool ContainsItemLocation(ItemLocation itemLoc) { return itemLoc.WorldLocation.X == 0xFFFF && itemLoc.WorldLocation.Y == this.OrderNumber + Constants.Inventory.MinimumContainerNumber; }
public bool ContainsItemLocation(ItemLocation itemLoc) { return(itemLoc.WorldLocation.X == 0xFFFF && itemLoc.WorldLocation.Y == this.OrderNumber + Constants.Inventory.MinimumContainerNumber); }