public bool Insert(Item item, bool tempFallback, out List<Item> changed)
{
changed = null;
var originalAmount = item.Amount;
// TODO: Maybe it would be cleaner to ask the pockets for a list
// of certain items, that we can fill into, instead of them
// returning lists of changed items via out.
if (item.Data.StackType == StackType.Stackable)
{
// Try stacks/sacs first
lock (_pockets)
{
// Main inv
_pockets[Pocket.Inventory].FillStacks(item, out changed);
this.UpdateChangedItems(changed);
// VIP inv
// TODO: Add and check inv locks
if (item.Info.Amount != 0)
{
_pockets[Pocket.VIPInventory].FillStacks(item, out changed);
this.UpdateChangedItems(changed);
}
// Bags
if (_creature.Client.Account.PremiumServices.CanUseBags)
{
for (var i = Pocket.ItemBags; i <= Pocket.ItemBagsMax; ++i)
{
if (item.Info.Amount == 0)
break;
if (_pockets.ContainsKey(i))
{
_pockets[i].FillStacks(item, out changed);
this.UpdateChangedItems(changed);
}
}
}
}
// Notify everybody about receiving the item, amount being
// the amount of items filled into stacks.
var inserted = (originalAmount - item.Info.Amount);
if (inserted > 0 && _creature.IsPlayer)
ChannelServer.Instance.Events.OnPlayerReceivesItem(_creature, item.Info.Id, inserted);
if (item.Info.Amount == 0)
return true;
}
return this.Add(item, tempFallback);
}