public bool Add(Item item, Pocket pocket)
{
var success = false;
lock (_pockets)
{
if (!_pockets.ContainsKey(pocket))
return success;
success = _pockets[pocket].Add(item);
}
if (success)
{
this.PrepareBags(item);
Send.ItemNew(_creature, item);
if (_creature.IsPlayer && pocket != Pocket.Temporary)
{
this.OnItemEntersInventory(item);
// Notify everybody about receiving the item.
ChannelServer.Instance.Events.OnPlayerReceivesItem(_creature, item.Info.Id, item.Amount);
// If item was a sac, we have to notify the server about
// receiving its *contents* as well.
if (item.Data.StackType == StackType.Sac)
ChannelServer.Instance.Events.OnPlayerReceivesItem(_creature, item.Data.StackItemId, item.Info.Amount);
}
if (pocket.IsEquip())
{
this.UpdateEquipReferences();
this.OnEquip(item);
this.UpdateEquipStats();
if (_creature.Region != Region.Limbo)
Send.EquipmentChanged(_creature, item);
}
}
return success;
}