Example #1
0
    public void EndDrag(EndDragPosition endPosition = EndDragPosition.newPosition)
    {
        if (GetDragged == null)
        {
            return;
        }

        var copy = GetDragged;

        GetDragged = null;

        itemGridPanel.EndDrag(copy, endPosition);
    }
    public void EndDrag(ItemDisplayer draggedCopy, EndDragPosition endPosition)
    {
        if (draggedMouse)
        {
            emptyPlaceholder.SetParent(emptyPlaceholderStorage);

            if (draggedCopy.isInventory)
            {
                draggedCopy.transform.SetParent(displayersGrid.transform);
            }
        }
        else
        {
            draggedCopy.SetBobbing(false);
            draggedCopy.SetNavigation(true);
            draggedCopy.selectable.Select();
        }

        if (endPosition == EndDragPosition.newPosition)
        {
            var equipment = master.playerEquipment;

            if (draggedCopy.isInventory)
            {
                //this will induce further callbacks which corrects the dragged sibling index
                equipment.Reorder(draggedCopy.itemIndex, draggedSiblingIndex);
            }
            else if ((draggedInside &&
                      //this will induce further callbacks which corrects the position
                      equipment.UnequipArms((Armament.Slot)draggedCopy.itemIndex, draggedSiblingIndex))
                     == false)
            {
                master.equipmentPanel.ResetPosition((Armament.Slot)draggedCopy.itemIndex);
            }
        }
        else if (endPosition == EndDragPosition.original)
        {
            if (draggedCopy.isInventory)
            {
                draggedCopy.transform.SetSiblingIndex(draggedCopy.itemIndex);
            }
            else
            {
                master.equipmentPanel.ResetPosition((Armament.Slot)draggedCopy.itemIndex);
            }
        }
    }