Aura.Channel.World.Inventory.InventoryPocketSingle.TryAdd C# (CSharp) Метод

TryAdd() публичный Метод

public TryAdd ( Item newItem, byte targetX, byte targetY, Item &collidingItem ) : bool
newItem Item
targetX byte
targetY byte
collidingItem Item
Результат bool
		public override bool TryAdd(Item newItem, byte targetX, byte targetY, out Item collidingItem)
		{
			collidingItem = _item;

			// Handle stackables and sacs
			if (collidingItem != null && ((collidingItem.Data.StackType == StackType.Sac && (collidingItem.Data.StackItemId == newItem.Info.Id || collidingItem.Data.StackItemId == newItem.Data.StackItemId)) || (newItem.Data.StackType == StackType.Stackable && newItem.Info.Id == collidingItem.Info.Id)))
			{
				if (collidingItem.Info.Amount < collidingItem.Data.StackMax)
				{
					var diff = (ushort)(collidingItem.Data.StackMax - collidingItem.Info.Amount);

					collidingItem.Info.Amount += Math.Min(diff, newItem.Info.Amount);
					newItem.Info.Amount -= Math.Min(diff, newItem.Info.Amount);

					return true;
				}
			}

			// Switch items if colliding
			if (collidingItem != null)
			{
				collidingItem = _item;
				collidingItem.Move(newItem.Info.Pocket, newItem.Info.X, newItem.Info.Y);
			}

			_item = newItem;
			_item.Move(this.Pocket, 0, 0);

			return true;
		}