protected override IEnumerator MainRoutine()
    {
        if (base.stateManager.battleMode == BattleMode.PvP)
        {
            if (base.stateManager.isLastBattle && (base.battleStateData.GetCharactersDeath(true) || base.battleStateData.GetCharactersDeath(false)))
            {
                yield break;
            }
        }
        else if (base.stateManager.isLastBattle && base.battleStateData.GetCharactersDeath(true))
        {
            yield break;
        }
        bool flag  = !BattleStateManager.current.battleStateData.enemies.Where((CharacterStateControl item) => !item.isDied).Any <CharacterStateControl>();
        bool flag2 = !BattleStateManager.current.battleStateData.playerCharacters.Where((CharacterStateControl item) => !item.isDied).Any <CharacterStateControl>();

        foreach (CharacterStateControl characterStateControl in this.GetTotalCharacters())
        {
            if ((characterStateControl.isEnemy && flag) || (!characterStateControl.isEnemy && flag2))
            {
                characterStateControl.RemoveDeadStagingChips();
            }
        }
        CharacterStateControl[] chipActors = this.GetChipActors();
        while (chipActors.Length > 0)
        {
            List <SubStatePlayChipEffect.ReturnData> resultList   = this.CheckPlayStagingChipEffect(chipActors);
            SubStatePlayChipEffect.ChipPlayType      chipPlayType = SubStatePlayChipEffect.ChipPlayType.None;
            foreach (SubStatePlayChipEffect.ReturnData returnData in resultList)
            {
                if (returnData.chipPlayType > chipPlayType)
                {
                    chipPlayType = returnData.chipPlayType;
                }
            }
            string cameraKey             = string.Empty;
            CharacterStateControl target = null;
            if ((chipPlayType == SubStatePlayChipEffect.ChipPlayType.ChipAndSKillPlay || chipPlayType == SubStatePlayChipEffect.ChipPlayType.SKillPlay) && this.IsSkillEnd != null && this.IsSkillEnd())
            {
                List <CharacterStateControl> list = new List <CharacterStateControl>();
                foreach (SubStatePlayChipEffect.ReturnData returnData2 in resultList)
                {
                    if (returnData2.chipPlayType == SubStatePlayChipEffect.ChipPlayType.ChipAndSKillPlay)
                    {
                        returnData2.characterStateControl.CharacterParams.gameObject.SetActive(true);
                        list.Add(returnData2.characterStateControl);
                    }
                }
                if (list.Count > 0)
                {
                    if (list.Count == 1)
                    {
                        cameraKey = "skillF";
                    }
                    else
                    {
                        cameraKey = "skillA";
                    }
                    list[0].CharacterParams.PlayAnimation(CharacterAnimationType.idle, SkillType.Attack, 0, null, null);
                    target = list[0];
                }
            }
            if (chipPlayType != SubStatePlayChipEffect.ChipPlayType.None)
            {
                foreach (SubStatePlayChipEffect.ReturnData returnData3 in resultList)
                {
                    if (returnData3.chipPlayType != SubStatePlayChipEffect.ChipPlayType.None)
                    {
                        returnData3.characterStateControl.CharacterParams.gameObject.SetActive(true);
                        returnData3.characterStateControl.CharacterParams.StopAnimation();
                        returnData3.characterStateControl.CharacterParams.PlayAnimation(CharacterAnimationType.idle, SkillType.Attack, 0, null, null);
                    }
                }
                if (target != null)
                {
                    yield return(new WaitForEndOfFrame());

                    base.stateManager.cameraControl.PlayCameraMotionActionCharacter(cameraKey, target);
                    base.stateManager.cameraControl.SetTime(cameraKey, 1f);
                }
                IEnumerator chipWait = this.PlayChipEffectPerformance(resultList);
                while (chipWait.MoveNext())
                {
                    object obj = chipWait.Current;
                    yield return(obj);
                }
                if (!string.IsNullOrEmpty(cameraKey))
                {
                    base.stateManager.cameraControl.StopCameraMotionAction(cameraKey);
                }
                IEnumerator chipEffectWait = this.PlayStagingChipEffect(resultList);
                while (chipEffectWait.MoveNext())
                {
                    object obj2 = chipEffectWait.Current;
                    yield return(obj2);
                }
            }
            chipActors = this.GetChipActors();
            if (chipActors.Length == 0)
            {
                foreach (CharacterStateControl characterStateControl2 in base.battleStateData.GetTotalCharacters())
                {
                    if (!characterStateControl2.isDied)
                    {
                        characterStateControl2.CharacterParams.gameObject.SetActive(true);
                        base.stateManager.threeDAction.PlayIdleAnimationActiveCharacterAction(new CharacterStateControl[]
                        {
                            characterStateControl2
                        });
                    }
                    else
                    {
                        characterStateControl2.CharacterParams.gameObject.SetActive(false);
                    }
                }
            }
        }
        yield break;
    }
    private List <SubStatePlayChipEffect.ReturnData> CheckPlayStagingChipEffect(CharacterStateControl[] chipActor)
    {
        List <SubStatePlayChipEffect.ReturnData> list = new List <SubStatePlayChipEffect.ReturnData>();

        foreach (CharacterStateControl characterStateControl in chipActor)
        {
            SubStatePlayChipEffect.ReturnData returnData = new SubStatePlayChipEffect.ReturnData();
            returnData.characterStateControl = characterStateControl;
            SubStatePlayChipEffect.ChipPlayType chipPlayType = SubStatePlayChipEffect.ChipPlayType.None;
            foreach (KeyValuePair <int, int> keyValuePair in characterStateControl.stagingChipIdList)
            {
                GameWebAPI.RespDataMA_ChipEffectM.ChipEffect chipEffectDataToId = ChipDataMng.GetChipEffectDataToId(keyValuePair.Key.ToString());
                if (!characterStateControl.isDied || chipEffectDataToId.effectTrigger.ToInt32() == 6)
                {
                    if (!returnData.dictionary.ContainsKey(keyValuePair.Value))
                    {
                        returnData.dictionary[keyValuePair.Value] = new List <GameWebAPI.RespDataMA_ChipEffectM.ChipEffect>();
                    }
                    if (chipEffectDataToId.effectType.ToInt32() == 60)
                    {
                        SkillStatus           skillStatus = base.hierarchyData.GetSkillStatus(chipEffectDataToId.effectValue);
                        CharacterStateControl target      = this.GetTarget(characterStateControl, chipEffectDataToId);
                        if (chipEffectDataToId.effectTrigger.ToInt32() == 37)
                        {
                            if (skillStatus != null && target != null && this.checkUseSkill(skillStatus, characterStateControl, target))
                            {
                                returnData.chipPlayType = SubStatePlayChipEffect.ChipPlayType.ChipAndSKillPlay;
                                returnData.dictionary[keyValuePair.Value].Add(chipEffectDataToId);
                            }
                            else
                            {
                                returnData.characterStateControl.AddChipEffectCount(chipEffectDataToId.chipEffectId.ToInt32(), 1);
                            }
                        }
                        else if (skillStatus != null && target != null)
                        {
                            returnData.chipPlayType = SubStatePlayChipEffect.ChipPlayType.ChipAndSKillPlay;
                            returnData.dictionary[keyValuePair.Value].Add(chipEffectDataToId);
                        }
                        else
                        {
                            returnData.characterStateControl.AddChipEffectCount(chipEffectDataToId.chipEffectId.ToInt32(), 1);
                        }
                    }
                    else if (chipEffectDataToId.effectType.ToInt32() == 56)
                    {
                        SkillStatus           skillStatus2 = base.hierarchyData.GetSkillStatus(chipEffectDataToId.effectValue);
                        CharacterStateControl target2      = this.GetTarget(characterStateControl, chipEffectDataToId);
                        if (skillStatus2 != null && target2 != null)
                        {
                            chipPlayType = SubStatePlayChipEffect.ChipPlayType.SKillPlay;
                            returnData.dictionary[keyValuePair.Value].Add(chipEffectDataToId);
                        }
                        else
                        {
                            returnData.characterStateControl.AddChipEffectCount(chipEffectDataToId.chipEffectId.ToInt32(), 1);
                        }
                    }
                    else
                    {
                        if (returnData.chipPlayType == SubStatePlayChipEffect.ChipPlayType.None)
                        {
                            returnData.chipPlayType = SubStatePlayChipEffect.ChipPlayType.ChipPlay;
                        }
                        returnData.dictionary[keyValuePair.Value].Add(chipEffectDataToId);
                    }
                }
            }
            if (returnData.chipPlayType == SubStatePlayChipEffect.ChipPlayType.None && chipPlayType != SubStatePlayChipEffect.ChipPlayType.None)
            {
                returnData.chipPlayType = chipPlayType;
            }
            list.Add(returnData);
            characterStateControl.stagingChipIdList.Clear();
        }
        return(list);
    }