public static ItemLocation FromItemLocation(ItemLocation location) { switch (location.Type) { case Tibia.Constants.ItemLocationType.Container: return(ItemLocation.FromContainer(location.ContainerId, location.ContainerSlot)); case Tibia.Constants.ItemLocationType.Ground: return(ItemLocation.FromLocation(location.GroundLocation, location.StackOrder)); case Tibia.Constants.ItemLocationType.Slot: return(ItemLocation.FromSlot(location.Slot)); default: return(null); } }
/// <summary> /// Return a list of all the items in the container. /// </summary> /// <returns></returns> public IEnumerable <Item> GetItems() { byte slot = 0; int amount = Amount; for (uint i = address; i <= address + Addresses.Container.StepSlot * amount - 1; i += Addresses.Container.StepSlot) { uint itemId = client.Memory.ReadUInt32(i + Addresses.Container.DistanceItemId); if (itemId > 0) { yield return(new Item( client, itemId, client.Memory.ReadByte(i + Addresses.Container.DistanceItemCount), "", ItemLocation.FromContainer(number, slot))); } slot++; } }