public void UpdateMechanicPreview(bool missionInProgress, JamGarrisonMobileMission mission)
 {
     if (this.m_previewMechanicsGroup != null)
     {
         AbilityDisplay[] componentsInChildren = this.m_previewMechanicsGroup.GetComponentsInChildren <AbilityDisplay>(true);
         for (int i = 0; i < componentsInChildren.Length; i++)
         {
             if (componentsInChildren[i] != null)
             {
                 Object.DestroyImmediate(componentsInChildren[i].get_gameObject());
             }
         }
     }
     if (!missionInProgress)
     {
         for (int j = 0; j < mission.Encounter.Length; j++)
         {
             int             id     = (mission.Encounter[j].MechanicID.Length <= 0) ? 0 : mission.Encounter[j].MechanicID[0];
             GarrMechanicRec record = StaticDB.garrMechanicDB.GetRecord(id);
             if (record != null && record.GarrAbilityID != 0)
             {
                 GameObject gameObject = Object.Instantiate <GameObject>(this.m_previewMechanicEffectPrefab);
                 gameObject.get_transform().SetParent(this.m_previewMechanicsGroup.get_transform(), false);
                 AbilityDisplay component = gameObject.GetComponent <AbilityDisplay>();
                 component.SetAbility(record.GarrAbilityID, false, false, null);
                 FollowerCanCounterMechanic canCounterStatus = GeneralHelpers.HasFollowerWhoCanCounter((int)record.GarrMechanicTypeID);
                 component.SetCanCounterStatus(canCounterStatus);
             }
         }
     }
 }
    public void UpdateMechanicPreview(bool missionInProgress, JamGarrisonMobileMission mission)
    {
        int num = 0;

        if (!missionInProgress)
        {
            for (int i = 0; i < mission.Encounter.Length; i++)
            {
                int             id     = (mission.Encounter[i].MechanicID.Length <= 0) ? 0 : mission.Encounter[i].MechanicID[0];
                GarrMechanicRec record = StaticDB.garrMechanicDB.GetRecord(id);
                if (record != null && record.GarrAbilityID != 0)
                {
                    this.m_previewAbilityID[num]        = record.GarrAbilityID;
                    this.m_previewCanCounterStatus[num] = GeneralHelpers.HasFollowerWhoCanCounter((int)record.GarrMechanicTypeID);
                    num++;
                }
            }
            bool             flag = true;
            AbilityDisplay[] componentsInChildren = this.m_previewMechanicsGroup.GetComponentsInChildren <AbilityDisplay>(true);
            if (num != componentsInChildren.Length)
            {
                flag = false;
            }
            if (flag)
            {
                for (int j = 0; j < componentsInChildren.Length; j++)
                {
                    if (componentsInChildren[j] == null)
                    {
                        flag = false;
                        break;
                    }
                    if (componentsInChildren[j].GetAbilityID() != this.m_previewAbilityID[j])
                    {
                        flag = false;
                        break;
                    }
                    if (componentsInChildren[j].GetCanCounterStatus() != this.m_previewCanCounterStatus[j])
                    {
                        flag = false;
                        break;
                    }
                }
            }
            if (!flag)
            {
                for (int k = 0; k < componentsInChildren.Length; k++)
                {
                    if (componentsInChildren[k] != null)
                    {
                        Object.DestroyImmediate(componentsInChildren[k].get_gameObject());
                    }
                }
                for (int l = 0; l < num; l++)
                {
                    GameObject gameObject = Object.Instantiate <GameObject>(this.m_previewMechanicEffectPrefab);
                    gameObject.get_transform().SetParent(this.m_previewMechanicsGroup.get_transform(), false);
                    AbilityDisplay component = gameObject.GetComponent <AbilityDisplay>();
                    component.SetAbility(this.m_previewAbilityID[l], false, false, null);
                    component.SetCanCounterStatus(this.m_previewCanCounterStatus[l]);
                }
            }
        }
    }