Method has problems

mail@pastecode.io avatar
unknown
csharp
10 days ago
1.6 kB
2
Indexable
Never
public IItemSlot<T> SwapItemRightClick(IItemSlot<T> cursorItem, int indexItem)
 {
     if (this.itemSlots[indexItem].Item == null && cursorItem.Item == null) return cursorItem;
     IItemSlot<T> cursorItemClone = cursorItem.Clone();
     IItemSlot<T> itemClone = this.itemSlots[indexItem].Clone();
     if (itemClone.Item != null && cursorItemClone.Item == null)
     {
         if (itemClone.Quanity <= 1)
             return this.SimplySwapItem(cursorItemClone, itemClone, indexItem);
         this.itemSlots[indexItem].Quanity = itemClone.Quanity / 2;
         cursorItemClone = itemClone;
         cursorItemClone.Quanity = itemClone.Quanity / 2;
         if (itemClone.Quanity % 2 == 1) cursorItemClone.Quanity += 1;
 
         return cursorItemClone;
     }
     else if (itemClone.Item != null && cursorItemClone.Item != null)
     {
         if (!cursorItemClone.Item.Equals(itemClone.Item) ||
         cursorItemClone.DuranceLeft != itemClone.DuranceLeft)
             return this.SimplySwapItem(cursorItemClone, itemClone, indexItem);
         if (itemClone.Quanity >= itemClone.Item.MaxStack) return cursorItemClone;
         cursorItemClone.Quanity -= 1;
         this.itemSlots[indexItem].Quanity += 1;
 
         return cursorItemClone;
     }
     else
     {
         if (cursorItemClone.Quanity <= 1)
             return this.SimplySwapItem(cursorItemClone, itemClone, indexItem);
         cursorItemClone.Quanity -= 1;
         this.itemSlots[indexItem] = cursorItemClone;
         this.itemSlots[indexItem].Quanity = 1;
 
         return cursorItemClone;
     }
 }
Leave a Comment