private void Drop(int index, BaseItemSlot dropItemSlot) { if (_draggedItemSlot == null) { return; } if (dropItemSlot.CanAddStack(_draggedItemSlot.Item) || (dropItemSlot.CanReceiveItem(_draggedItemSlot.Item) && _draggedItemSlot.CanReceiveItem(dropItemSlot.Item))) { InvokeServerRpc(ChangeItemSlots, _draggedItemSlotIndex, _draggedItemSlot.GetType().ToString(), index, dropItemSlot.GetType().ToString()); } }
private void SwapItems(BaseItemSlot tranferItemSlot) { ItemPickUp dragItem = dragItemSlot.ITEM as ItemPickUp; int dragIndex = dragItemSlot.INDEX; ItemPickUp tranferItem = tranferItemSlot.ITEM as ItemPickUp; int tranferIndex = tranferItemSlot.INDEX; if (dragItemSlot.GetType() != tranferItemSlot.GetType()) { //inv to storage if (dragItemSlot is BaseInvSlot) { if (tranferItemSlot.ITEM != null) { inv_container.StoreItem(tranferItem, dragIndex); storage_container.StoreItem(dragItem, tranferIndex); } else { if (inv_container.RemoveItem(dragIndex)) { storage_container.StoreItem(dragItem, tranferIndex); } } } else { //storage to inv if (dragItemSlot is BaseStorageSlot) { //has item if (tranferItemSlot.ITEM != null) { inv_container.StoreItem(dragItem, tranferIndex); storage_container.StoreItem(tranferItem, dragIndex); } else //hasn't item { if (storage_container.RemoveItem(dragIndex)) { inv_container.StoreItem(dragItem, tranferIndex); } } } } } else { if (dragItemSlot is BaseInvSlot && dragItemSlot != null) { inv_container.Swap(dragIndex, tranferIndex); } if (dragItemSlot is BaseStorageSlot && dragItemSlot != null) { storage_container.Swap(dragIndex, tranferIndex); } } }