Ejemplo n.º 1
0
        public void MoveTo(IItemContainer newLocation)
        {
            if (Location == newLocation || !newLocation.FitsInSlot(this))
            {
                return;
            }

            OnItemMoved?.Invoke(this, new ItemMovedEventArgs
            {
                From = Location,
                To   = newLocation,
                Item = this
            });

            int maxAdded = newLocation.Add(this);

            Location?.Remove(this);
            if (maxAdded < Count)
            {
                new DroppableItem(this, Count - maxAdded, Location);
                Count = maxAdded;
            }
            Location = newLocation;
        }