private bool AddItemToEmptySlotInCrate(StorageCrate lCrate, ItemBase lItem)
    {
        int i = 0;

        while (i < lCrate.mItems.Length)
        {
            if (lCrate.mItems[i] == null)
            {
                int maxStackSize     = ItemManager.GetMaxStackSize(lItem);
                int currentStackSize = ItemManager.GetCurrentStackSize(lItem);
                if (currentStackSize > maxStackSize)
                {
                    ItemBase item = ItemManager.CloneItem(lItem);
                    ItemManager.SetItemCount(lItem, currentStackSize - maxStackSize);
                    ItemManager.SetItemCount(item, maxStackSize);
                    StorageCrateWindow.SetSlotAndSendNetworkUpdate(WorldScript.mLocalPlayer, lCrate, i, item);
                    return(true);
                }
                StorageCrateWindow.SetSlotAndSendNetworkUpdate(WorldScript.mLocalPlayer, lCrate, i, lItem);
                this.RemoveItem(lItem, null);
                return(true);
            }
            else
            {
                i++;
            }
        }
        return(false);
    }
 private bool AttemptToStackIntoCrate(StorageCrate lCrate, ItemBase lItem)
 {
     for (int i = 0; i < lCrate.mItems.Length; i++)
     {
         if (lCrate.mItems[i] != null)
         {
             if (ItemManager.AreItemsTheSame(lItem, lCrate.mItems[i]))
             {
                 ItemBase itemBase = ItemManager.CloneItem(lItem);
                 if (ItemManager.StackWholeItems(itemBase, lCrate.mItems[i], true))
                 {
                     int currentStackSize  = ItemManager.GetCurrentStackSize(lCrate.mItems[i]);
                     int currentStackSize2 = ItemManager.GetCurrentStackSize(itemBase);
                     StorageCrateWindow.SetSlotAndSendNetworkUpdate(WorldScript.mLocalPlayer, lCrate, i, itemBase);
                     int num = currentStackSize2 - currentStackSize;
                     this.RemoveItem(lItem, null);
                     UIManager.instance.SetInfoText(string.Concat(new object[]
                     {
                         "Stacked ",
                         num,
                         "x ",
                         ItemManager.GetItemName(itemBase)
                     }), 3f, true);
                     return(true);
                 }
                 return(false);
             }
         }
     }
     return(false);
 }