Aura.Channel.World.Inventory.CreatureInventory.TryAutoAdd C# (CSharp) 메소드

TryAutoAdd() 개인적인 메소드

Tries to add item to one of the main invs or bags, wherever free space is available. Returns whether it was successful.
private TryAutoAdd ( Item item, bool tempFallback ) : bool
item Item
tempFallback bool Use temp inventory if all others are full?
리턴 bool
		private bool TryAutoAdd(Item item, bool tempFallback)
		{
			var success = false;
			var inTemp = false;

			lock (_pockets)
			{
				// Try main inv
				if (_pockets.ContainsKey(Pocket.Inventory))
					success = _pockets[Pocket.Inventory].Add(item);

				// VIP inv
				// TODO: Add and check inv locks
				if (!success)
				{
					if (_pockets.ContainsKey(Pocket.VIPInventory))
						success = _pockets[Pocket.VIPInventory].Add(item);
				}

				// Try bags
				if (_creature.Client.Account.PremiumServices.CanUseBags)
				{
					for (var i = Pocket.ItemBags; i <= Pocket.ItemBagsMax; ++i)
					{
						if (success)
							break;

						if (_pockets.ContainsKey(i))
							success = _pockets[i].Add(item);
					}
				}

				// Try temp
				if (!success && tempFallback)
				{
					success = _pockets[Pocket.Temporary].Add(item);
					inTemp = true;
				}
			}

			if (success && _creature.IsPlayer && !inTemp)
			{
				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);
			}

			return success;
		}