private void SetTroopSlotForExistingFollower(TroopSlot[] troopSlots, JamGarrisonFollower follower)
 {
     if (follower.Durability <= 0)
     {
         return;
     }
     for (int i = 0; i < troopSlots.Length; i++)
     {
         TroopSlot troopSlot       = troopSlots[i];
         int       ownedFollowerID = troopSlot.GetOwnedFollowerID();
         if (ownedFollowerID != 0 && ownedFollowerID == follower.GarrFollowerID)
         {
             return;
         }
     }
     for (int j = 0; j < troopSlots.Length; j++)
     {
         TroopSlot troopSlot2 = troopSlots[j];
         if (troopSlot2.IsCollected())
         {
             GarrFollowerRec record         = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             iconFileDataID = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceIconFileDataID : record.HordeIconFileDataID;
             troopSlot2.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, follower.GarrFollowerID, false, iconFileDataID);
             return;
         }
     }
     for (int k = 0; k < troopSlots.Length; k++)
     {
         TroopSlot troopSlot3 = troopSlots[k];
         if (troopSlot3.IsEmpty())
         {
             GarrFollowerRec record2         = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             iconFileDataID2 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record2.AllianceIconFileDataID : record2.HordeIconFileDataID;
             troopSlot3.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, follower.GarrFollowerID, false, iconFileDataID2);
             return;
         }
     }
 }
    private void UpdateTroopSlots()
    {
        int maxTroops = this.GetMaxTroops((int)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID));

        TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
        if (componentsInChildren.Length < maxTroops)
        {
            for (int i = componentsInChildren.Length; i < maxTroops; 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 > maxTroops)
        {
            for (int j = maxTroops; 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];
            int       ownedFollowerID = troopSlot.GetOwnedFollowerID();
            if (ownedFollowerID != 0 && (!PersistentFollowerData.followerDictionary.ContainsKey(ownedFollowerID) || PersistentFollowerData.followerDictionary.get_Item(ownedFollowerID).Durability == 0))
            {
                troopSlot.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0);
            }
        }
        uint num = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID;

        using (Dictionary <int, JamGarrisonFollower> .ValueCollection.Enumerator enumerator = PersistentFollowerData.followerDictionary.get_Values().GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                JamGarrisonFollower current = enumerator.get_Current();
                GarrFollowerRec     record  = StaticDB.garrFollowerDB.GetRecord(current.GarrFollowerID);
                uint num2 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID;
                if (num2 == num && current.Durability > 0)
                {
                    this.SetTroopSlotForExistingFollower(componentsInChildren, current);
                }
            }
        }
        CharShipmentRec record2     = StaticDB.charShipmentDB.GetRecord(this.m_shipmentType.CharShipmentID);
        IEnumerator     enumerator2 = PersistentShipmentData.shipmentDictionary.get_Values().GetEnumerator();

        try
        {
            while (enumerator2.MoveNext())
            {
                JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)enumerator2.get_Current();
                if (jamCharacterShipment.ShipmentRecID == this.m_shipmentType.CharShipmentID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                }
                else
                {
                    CharShipmentRec record3 = StaticDB.charShipmentDB.GetRecord(jamCharacterShipment.ShipmentRecID);
                    if (record3.ContainerID == record2.ContainerID)
                    {
                        this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                    }
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator2 as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
    }