private void HandleShipmentAdded(int charShipmentID, ulong shipmentDBID)
 {
     if (charShipmentID == this.m_shipmentType.CharShipmentID)
     {
         TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>();
         TroopSlot[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             TroopSlot troopSlot = array[i];
             if (troopSlot.GetDBID() == shipmentDBID)
             {
                 return;
             }
         }
         TroopSlot[] array2 = componentsInChildren;
         for (int j = 0; j < array2.Length; j++)
         {
             TroopSlot troopSlot2 = array2[j];
             if (troopSlot2.IsEmpty())
             {
                 troopSlot2.SetCharShipment(charShipmentID, shipmentDBID, 0, true, 0);
                 break;
             }
         }
         this.UpdateRecruitButtonState();
     }
 }
    private void UpdateItemSlots()
    {
        int maxShipments = (int)this.m_charShipmentRec.MaxShipments;

        TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
        if (componentsInChildren.Length < maxShipments)
        {
            for (int i = componentsInChildren.Length; i < maxShipments; i++)
            {
                GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopSlotPrefab);
                gameObject.get_transform().SetParent(this.m_troopSlotsRootObject.get_transform(), false);
                TroopSlot component = gameObject.GetComponent <TroopSlot>();
                component.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0);
            }
        }
        if (componentsInChildren.Length > maxShipments)
        {
            for (int j = maxShipments; j < componentsInChildren.Length; j++)
            {
                Object.DestroyImmediate(componentsInChildren[j].get_gameObject());
            }
        }
        componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
        TroopSlot[] array = componentsInChildren;
        for (int k = 0; k < array.Length; k++)
        {
            TroopSlot troopSlot = array[k];
            if (troopSlot.GetDBID() != 0uL && !PersistentShipmentData.shipmentDictionary.ContainsKey(troopSlot.GetDBID()))
            {
                troopSlot.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0);
            }
        }
        IEnumerator enumerator = PersistentShipmentData.shipmentDictionary.get_Values().GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)enumerator.get_Current();
                if (jamCharacterShipment.ShipmentRecID == this.m_shipmentType.CharShipmentID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
    }
 private void SetTroopSlotForPendingShipment(TroopSlot[] troopSlots, ulong shipmentDBID)
 {
     for (int i = 0; i < troopSlots.Length; i++)
     {
         TroopSlot troopSlot = troopSlots[i];
         if (troopSlot.GetDBID() == shipmentDBID)
         {
             return;
         }
     }
     for (int j = 0; j < troopSlots.Length; j++)
     {
         TroopSlot troopSlot2 = troopSlots[j];
         if (troopSlot2.IsEmpty())
         {
             troopSlot2.SetCharShipment(this.m_shipmentType.CharShipmentID, shipmentDBID, 0, true, 0);
             return;
         }
     }
 }