예제 #1
0
        /// <summary>
        /// Marks the item as placed removing it from the original container.
        /// </summary>
        /// <param name="slot">slot if an equipment placement.</param>
        public void MarkPlaced()
        {
            int slot = -1;

            // modified items do not have a source sack.
            // so no one needs to be notified of the placement.
            if (!this.IsModifiedItem)
            {
                // Check to see if the dragged item is from one of the equipped slots.
                if (this.sack.SackType == SackType.Equipment)
                {
                    slot = EquipmentPanel.FindEquipmentSlot(this.sack, this.item);
                }

                if (slot != -1)
                {
                    // Remove the item out of the equipment slot
                    this.sack.RemoveAtItem(slot);

                    // Put a dummy item in it's place
                    Item newItem = this.item.MakeEmptyItem();
                    newItem.PositionX = SackCollection.GetEquipmentLocationOffset(slot).X;
                    newItem.PositionY = SackCollection.GetEquipmentLocationOffset(slot).Y;
                    this.sack.InsertItem(slot, newItem);
                }
                else
                {
                    // Remove the item from the old sack
                    this.sack.RemoveItem(this.item);
                }

                BagButtonTooltip.InvalidateCache(this.Sack, this.Original?.Sack);
            }

            // finally clear things out
            this.item             = null;
            this.sack             = null;
            this.sackPanel        = null;
            this.original         = null;
            this.AutoMove         = AutoMoveLocation.NotSet;
            this.IsBeingCancelled = false;
        }