using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Wizard;
using Wizard.Battle;
using Wizard.Battle.Touch;
using Wizard.Battle.UI;
using Wizard.Battle.View.Vfx;

public class ReplayBattlePlayer : BattlePlayer
{
	private NewReplayBattleMgr _replayBattleMgr;

	private SkillBase _dummySelectSkill;

	private bool _isSelectComplete;

	private List<BattleCardBase> _choiceCards = new List<BattleCardBase>();

	private List<BattleCardBase> _chosenCards = new List<BattleCardBase>();

	private BattleCardBase _transformChoiceCard;

	private bool _isTransformSelect;

	public bool CanChoiceBraveOnRecord;

	public override bool CanChoiceBrave
	{
		get
		{
			if (CanChoiceBraveThisTurn)
			{
				return CanChoiceBraveOnRecord;
			}
			return false;
		}
	}

	public ReplayBattlePlayer(BattleManagerBase battleMgr, BattleCamera battleCamera, BackGroundBase backGround, IInnerOptionsBuilder innerOptionsBuilder)
		: base(battleMgr, battleCamera, backGround, innerOptionsBuilder)
	{
		_replayBattleMgr = battleMgr as NewReplayBattleMgr;
	}

	public override VfxBase StartTurnControl(string log = "")
	{
		if (_canNotTouchCardVfx == null)
		{
			_canNotTouchCardVfx = new CanNotTouchCardVfx();
			base.BattleMgr.VfxMgr.RegisterImmediateVfx(_canNotTouchCardVfx);
		}
		base.PlayerEmotion.ResetPlayCount();
		Turn++;
		_replayBattleMgr.IsRightAfterMoveTurn = false;
		base.IsEpEvolveThisTurn = false;
		SequentialVfxPlayer sequentialVfxPlayer = TurnEvolveControl(PlayerBattleView.EpIcon);
		VfxBase vfx = TurnStart();
		sequentialVfxPlayer.Register(vfx);
		return sequentialVfxPlayer;
	}

	public VfxBase TurnStartFinish()
	{
		return InstantVfx.Create(PlayerActive);
	}

	public override VfxBase TurnStart()
	{
		for (int i = 0; i < base.HandCardList.Count; i++)
		{
			base.HandCardList[i].SetOnDraw(draw: true);
		}
		_opponentBattlePlayer.IsSelfTurn = false;
		_replayBattleMgr.TurnStart(this);
		base.IsAlreadyChoiceBraveInThisTurn = false;
		for (int j = 0; j < base.HandCardList.Count; j++)
		{
			base.HandCardList[j].SetOnDraw(draw: false);
		}
		return NullVfx.GetInstance();
	}

	public VfxBase AddPpTotal(BattleCardBase ownerCard, int addPpTotalCount, int pp, bool bySkill)
	{
		return _replayBattleMgr.AddPpTotal(ownerCard, this, addPpTotalCount, pp, bySkill);
	}

	public VfxBase AddPp(BattleCardBase ownerCard, int addPpCount)
	{
		return _replayBattleMgr.AddPp(ownerCard, this, addPpCount);
	}

	public VfxBase AddBp(BattleCardBase ownerCard, int addBpCount)
	{
		return _replayBattleMgr.AddBp(ownerCard, this, addBpCount, isSelf: true);
	}

	public VfxBase AddEp(BattleCardBase ownerCard, int addEpCount, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.EpModifier(ownerCard, this, addEpCount, isAdd: true, effectInfo);
	}

	public VfxBase SetEp(BattleCardBase ownerCard, int addEpCount, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.EpModifier(ownerCard, this, addEpCount, isAdd: false, effectInfo);
	}

	public VfxWithLoading DrawCard(List<BattleCardBase> drawList, List<NetworkBattleReceiver.CardInfo> cardInfoList, bool isOpenDrawSkill)
	{
		VfxWithLoadingSequential vfxWithLoadingSequential = _replayBattleMgr.DrawCard(this, drawList, cardInfoList);
		vfxWithLoadingSequential.RegisterToMainVfx(CardDrawVfx(drawList, skipShuffle: false, isOpenDrawSkill));
		vfxWithLoadingSequential.RegisterToMainVfx(InstantVfx.Create(delegate
		{
			foreach (BattleCardBase draw in drawList)
			{
				draw.SetOnDraw(draw: false);
			}
		}));
		return vfxWithLoadingSequential;
	}

	public VfxWithLoading TokenDrawCard(BattleCardBase ownerCard, List<NetworkBattleReceiver.CardInfo> cardInfoList, List<BattleCardBase> targets, bool isOpen, bool isReserved, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.TokenDrawCard(this, ownerCard, cardInfoList, targets, isOpen, isReserved, effectInfo);
	}

	public VfxWithLoading CreateReservedCard(BattleCardBase ownerCard, List<NetworkBattleReceiver.CardInfo> cardInfoList)
	{
		return _replayBattleMgr.CreateReservedCard(this, ownerCard, cardInfoList);
	}

	public VfxBase PlayCard(BattleCardBase playCard, int cost, int transformCardId, BattleCardBase.TransformType transformType, NetworkBattleReceiver.CardInfo cardInfo)
	{
		SequentialVfxPlayer sequentialVfx = SequentialVfxPlayer.Create();
		_replayBattleMgr.VfxMgr.RegisterImmediateVfx(playCard.StopSpellCharge());
		if (playCard == PlayerBattleView.DetailOpenCard)
		{
			sequentialVfx.Register(InstantVfx.Create(delegate
			{
				PlayerBattleView.HideDetailPanel();
			}));
		}
		if (!_isSelectComplete)
		{
			sequentialVfx.Register(BattleView.PlayQueueView.AddCardToViewVfx(playCard.BattleCardView, forceCardIntoPlayQueue: false, isSelectTarget: false, isChoice: false));
		}
		else
		{
			_isSelectComplete = false;
		}
		playCard.BattleCardView.HideHandCardInfo();
		playCard.BattleCardView.HideCanPlayEffect();
		if (transformCardId != -1)
		{
			BattleCardBase battleCardBase = playCard;
			SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
			bool flag = transformType == BattleCardBase.TransformType.Accelerate || transformType == BattleCardBase.TransformType.Crystallize;
			playCard = _replayBattleMgr.CreateTransformCard(this, playCard, transformCardId, sequentialVfxPlayer, flag);
			playCard.TransformInfo = new BattleCardBase.TransformInformation(transformType, battleCardBase);
			if (flag)
			{
				sequentialVfx.Register(sequentialVfxPlayer);
			}
			else
			{
				_replayBattleMgr.VfxMgr.RegisterImmediateVfx(sequentialVfxPlayer);
			}
			base.HandCardList.Insert(base.HandCardList.IndexOf(battleCardBase), playCard);
			base.HandCardList.Remove(battleCardBase);
			sequentialVfx.Register(_replayBattleMgr.SetupTransformCard(playCard, battleCardBase, flag));
		}
		BattleView.HandView.RemoveCardFromView(playCard.BattleCardView, 0.3f);
		VfxBase vfxBase = UsePp(cost);
		if (playCard is UnitBattleCard || playCard is FieldBattleCard)
		{
			_replayBattleMgr.HandCardToField(this, playCard);
		}
		if (playCard is UnitBattleCard)
		{
			playCard.BattleCardView.ResetTemplate();
		}
		BattleLogManager.GetInstance().AddLogDestFollower(BattleLogWindow.BattleLogType.PlayCardLog, playCard);
		VfxBase vfxBase2 = _replayBattleMgr.CreatePick(playCard, cardInfo);
		sequentialVfx.Register(ParallelVfxPlayer.Create(vfxBase, vfxBase2));
		sequentialVfx.Register(playCard.SetUpInplay());
		sequentialVfx.Register(InstantVfx.Create(delegate
		{
			if (base.HandCardList.Count <= 0)
			{
				sequentialVfx.Register(BattleView.HandUnfocus());
			}
		}));
		sequentialVfx.Register(InstantVfx.Create(delegate
		{
			MotionUtils.SetLayerAll(playCard.BattleCardView.CardTemplate.CardNormalTemp.gameObject, 10);
		}));
		if (playCard is SpellBattleCard)
		{
			_replayBattleMgr.HandCardToCemetery(this, playCard);
		}
		sequentialVfx.Register(UpdateHandCardsCost());
		return sequentialVfx;
	}

	public VfxBase PlayChoiceBraveCard(int cost, int cardId, NetworkBattleReceiver.CardInfo cardInfo)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		BattleCardBase selectSkillCard = (_isSelectComplete ? _transformChoiceCard : null);
		BattleCardBase playCard = _replayBattleMgr.ReplaceChoiceBraveCard(base.Class, cardId, selectSkillCard);
		base.IsAlreadyChoiceBraveInThisTurn = true;
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.UpdateChoiceBraveButtonPulsateEffectAndSprite();
		}));
		_replayBattleMgr.VfxMgr.RegisterImmediateVfx(BattleView.PlayQueueView.AddCardToViewVfx(playCard.BattleCardView, forceCardIntoPlayQueue: false, isSelectTarget: false, isChoice: true, isChoiceBrave: true));
		_isSelectComplete = false;
		_transformChoiceCard = null;
		sequentialVfxPlayer.Register(UseBp(cost, playCard.BaseParameter.IsVariableCost, isSelf: true));
		sequentialVfxPlayer.Register(_replayBattleMgr.CreatePick(playCard, cardInfo));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			MotionUtils.SetLayerAll(playCard.BattleCardView.CardTemplate.CardNormalTemp.gameObject, 10);
		}));
		base.ChoiceBraveCardList.Add(playCard);
		sequentialVfxPlayer.Register(UpdateHandCardsCost());
		return sequentialVfxPlayer;
	}

	public VfxWithLoading SummonToken(BattleCardBase ownerCard, List<NetworkBattleReceiver.CardInfo> cardInfoList, NetworkBattleReceiver.EffectInfo effectInfo, bool isOwnerEffect, bool isIgnoreVoice, bool isRandomVoice, bool isEvoVoice)
	{
		return _replayBattleMgr.SummonToken(this, ownerCard, cardInfoList, effectInfo, isOwnerEffect, isIgnoreVoice, isRandomVoice, isEvoVoice);
	}

	public VfxWithLoading SummonCard(BattleCardBase ownerCard, List<BattleCardBase> targets, bool isDeckSelf, bool isBurialRite, NetworkBattleReceiver.EffectInfo effectInfo, bool isIgnoreVoice, List<NetworkBattleReceiver.CardInfo> cardInfoList)
	{
		return _replayBattleMgr.SummonCard(this, ownerCard, targets, isDeckSelf, isBurialRite, effectInfo, isIgnoreVoice, cardInfoList);
	}

	public VfxBase AttackStart(BattleCardBase attackCard, BattleCardBase targetCard)
	{
		return _replayBattleMgr.AttackStart(this, attackCard, targetCard);
	}

	public VfxBase Attack(BattleCardBase attackCard, BattleCardBase targetCard, int dealDamage, int receiveDamage, List<BattleCardBase> destroyList, List<NetworkBattleReceiver.DestroyType> destroyTypeList, List<BattleCardBase> banishList, int drain, NetworkBattleReceiver.CardInfo attackCardInfo, List<NetworkBattleReceiver.SideLogSkillInfo> sideLogSkillInfoList, bool isAttackerDead, bool isTargetDead)
	{
		return _replayBattleMgr.Attack(this, attackCard, targetCard, dealDamage, receiveDamage, destroyList, destroyTypeList, banishList, drain, attackCardInfo, sideLogSkillInfoList, isAttackerDead, isTargetDead);
	}

	public VfxBase Evolve(BattleCardBase card, bool isConsumeEp, int choiceEvolutionId, NetworkBattleReceiver.CardInfo cardInfo, List<NetworkBattleReceiver.CardInfo> handCardInfoList)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		if (choiceEvolutionId / 1000000 == 910)
		{
			sequentialVfxPlayer.Register(_replayBattleMgr.ChoiceEvolve(card, choiceEvolutionId));
		}
		if (isConsumeEp)
		{
			GainCurrentEpCount();
		}
		base._cumulativeEvolutionCount++;
		sequentialVfxPlayer.Register(_replayBattleMgr.UpdateHandEffect(base.HandCardList, handCardInfoList, forceHide: true));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.HideChoiceBraveButtonPulsateEffect();
		}));
		sequentialVfxPlayer.Register(card.SkillApplyInformation.AllSkillEffectStop(isEvolve: true));
		(card as UnitBattleCard).Evolution();
		base.IsEpEvolveThisTurn = true;
		if (GameMgr.GetIns().GetDataMgr().Is3DSkin(isPlayer: true))
		{
			sequentialVfxPlayer.Register(new Class3dEvolveVfx(card, _replayBattleMgr.BattleResourceMgr));
		}
		else if (GameMgr.GetIns().GetDataMgr().IsHighRankSkinPlayer())
		{
			sequentialVfxPlayer.Register(new HighRankEvolveVfx(card, _replayBattleMgr.BattleResourceMgr, !isConsumeEp));
		}
		else
		{
			sequentialVfxPlayer.Register(new EvolveVfx(card, _replayBattleMgr.BattleResourceMgr, !isConsumeEp));
		}
		sequentialVfxPlayer.Register(card.SkillApplyInformation.UpdateAllSkillEffectInReplay(cardInfo.InplaySkillEffectList, cardInfo.InductionNumber, isInitialize: true));
		sequentialVfxPlayer.Register(card.SkillApplyInformation.AllSkillEffectRestart());
		card.AttackableOnReplay = cardInfo.Attackable;
		card.IsCantAttackClassOnReplay = cardInfo.IsCantAttackClass;
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			card.BattleCardView._inPlayFrameEffect.UpdateCanAttackEffect();
		}));
		sequentialVfxPlayer.Register(_replayBattleMgr.UpdateHandEffect(base.HandCardList, handCardInfoList));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.UpdateChoiceBraveButtonPulsateEffectAndSprite();
		}));
		return sequentialVfxPlayer;
	}

	public VfxBase StartSelect(BattleCardBase actCard, List<BattleCardBase> selectableCards, bool isEvolve, NetworkBattleReceiver.CardInfo cardInfo, bool isChoiceBrave)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		if (isChoiceBrave)
		{
			actCard = _transformChoiceCard;
		}
		if (!isEvolve)
		{
			if (actCard.IsInHand && actCard == PlayerBattleView.DetailOpenCard)
			{
				sequentialVfxPlayer.Register(InstantVfx.Create(delegate
				{
					PlayerBattleView.HideDetailPanel();
				}));
			}
			sequentialVfxPlayer.Register(InstantVfx.Create(delegate
			{
				actCard.BattleCardView.HideHandCardInfo();
			}));
			if (!_isTransformSelect)
			{
				sequentialVfxPlayer.Register(_replayBattleMgr.OperateMgr.InitSetCard(actCard, isPlayer: true, isSelect: true, isRecovery: false, isChoiceSelect: false, isAccelerateSelect: true));
			}
		}
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.ShowAlert(PanelMgr.BattleAlertType.SelectChoiceCard, isClass: false, Data.SystemText.Get("Battle_0501"));
			base.ClassInformationUIController.SetIsSelect(isSelect: true);
		}));
		sequentialVfxPlayer.Register(StartShowSelect(actCard, selectableCards, isEvolve, isFusion: false, cardInfo));
		_replayBattleMgr.IsSelecting = true;
		_replayBattleMgr.ActCard = actCard;
		_replayBattleMgr.IsEvolve = isEvolve;
		return sequentialVfxPlayer;
	}

	private VfxBase StartShowSelect(BattleCardBase actCard, List<BattleCardBase> selectableCards, bool isEvol, bool isFusion, NetworkBattleReceiver.CardInfo cardInfo)
	{
		CanNotTouchCardVfx canNotTouchCardVfx = new CanNotTouchCardVfx();
		base.BattleMgr.VfxMgr.RegisterImmediateVfx(canNotTouchCardVfx);
		for (int i = 0; i < base.HandCardList.Count; i++)
		{
			if (!selectableCards.Contains(base.HandCardList[i]))
			{
				base.HandCardList[i].BattleCardView.HideCanPlayEffect();
			}
		}
		BattleView.HideChoiceBraveButtonPulsateEffect();
		if (actCard.IsInHand)
		{
			BattleView.HandView.HideCardFromView(actCard.BattleCardView);
		}
		ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create();
		_dummySelectSkill = CreateDummySkill(actCard);
		BattleView.SetSelectCardList(selectableCards);
		StartSkillSelectVfx startSkillSelectVfx = new StartSkillSelectVfx(actCard, _dummySelectSkill, selectableCards, selectableCards.First().IsInHand, isFusion);
		startSkillSelectVfx.OnStart += delegate
		{
			canNotTouchCardVfx.End();
			canNotTouchCardVfx = null;
			_replayBattleMgr.ShowSideLog(actCard, this, isEvol, 0f, isSkillTargetSelect: true, cardInfo);
		};
		parallelVfxPlayer.Register(startSkillSelectVfx);
		parallelVfxPlayer.Register(InstantVfx.Create(delegate
		{
			UpdateHandCardsPlayability(areArrowsForcedOff: true);
		}));
		parallelVfxPlayer.Register(BattleView.HandView.HandUnfocus());
		parallelVfxPlayer.Register(WaitVfx.Create(1f));
		return parallelVfxPlayer;
	}

	private SkillBase CreateDummySkill(BattleCardBase card)
	{
		return new Skill_none(new SkillParameter
		{
			selfBattlePlayer = card.SelfBattlePlayer,
			opponentBattlePlayer = card.OpponentBattlePlayer,
			ownerCard = card,
			buildInfo = new SkillCreator.SkillBuildInfo("none", "none", "none", "none", "none", "none"),
			resourceMgr = _replayBattleMgr.BattleResourceMgr
		}, string.Empty);
	}

	public VfxBase Select(BattleCardBase actCard, BattleCardBase selectedCard, List<BattleCardBase> selectableCards, bool isEvolve, NetworkBattleReceiver.CardInfo cardInfo, bool isBurialRiteSkill)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		sequentialVfxPlayer.Register(_replayBattleMgr.OperateMgr.BattleCardSelect(actCard, selectedCard, isPlayer: true, registerEffectsDirectlyToVfxMgr: false, isTransformskill: false, isBurialRiteSkill));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.ShowAlert(PanelMgr.BattleAlertType.SelectChoiceCard, isClass: false, Data.SystemText.Get("Battle_0501"));
		}));
		sequentialVfxPlayer.Register(StartShowSelect(actCard, selectableCards, isEvolve, isFusion: false, cardInfo));
		return sequentialVfxPlayer;
	}

	public VfxBase CompleteSelect(BattleCardBase actCard, BattleCardBase selectedCard, bool isEvol, bool isBurialRiteSkill, bool isChoiceBrave)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		if (isChoiceBrave)
		{
			actCard = _transformChoiceCard;
		}
		if (_isTransformSelect)
		{
			ChoiceUtility.SetupActingChoiceCardToBePlayedFromQueue(actCard, _transformChoiceCard, this, isChoiceBrave);
		}
		sequentialVfxPlayer.Register(_replayBattleMgr.OperateMgr.BattleCardSelect(actCard, selectedCard, isPlayer: true, registerEffectsDirectlyToVfxMgr: false, isTransformskill: false, isBurialRiteSkill));
		_dummySelectSkill.SelectCompleteFlag = true;
		if (!isEvol)
		{
			_isSelectComplete = true;
		}
		BattleView.ClearSelectCardList();
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			base.ClassInformationUIController.SetIsSelect(isSelect: false);
		}));
		_isTransformSelect = false;
		_replayBattleMgr.IsSelecting = false;
		if (!isChoiceBrave)
		{
			_transformChoiceCard = null;
		}
		return sequentialVfxPlayer;
	}

	public VfxBase CancelSelect(BattleCardBase actCard, bool isEvolve, bool isChoiceBrave, bool isMoveTurn = false)
	{
		if (_isTransformSelect)
		{
			PlayerBattleView.SetCancelSkillChoiceTransformCards(actCard, _transformChoiceCard);
		}
		VfxBase result = CancelSelectVfx(_isTransformSelect ? _transformChoiceCard : actCard, isEvolve, isMoveTurn);
		_dummySelectSkill = null;
		BattleView.ClearSelectCardList();
		_isTransformSelect = false;
		_transformChoiceCard = null;
		_replayBattleMgr.IsSelecting = false;
		_isSelectComplete = false;
		return result;
	}

	private VfxBase CancelSelectVfx(BattleCardBase actCard, bool isEvolve, bool isMoveTurn, bool isResetDetail = true)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		BattleView.CancelPlayCard(actCard, isEvolve, isMoveTurn);
		for (int i = 0; i < base.HandCardList.Count(); i++)
		{
			base.HandCardList[i].IsSelectedDuringSelectingBurialRiteTarget = false;
		}
		if (base.HandCardList.Contains(actCard))
		{
			base.HandControl.AttachCardView(actCard.BattleCardView);
			actCard.BattleCardView.GameObject.SetActive(value: true);
		}
		BattleView.DisableSettingFlag();
		BattleView.AllClear(popUpClose: false, isRemoveSideLog: true, isStopDrag: false, isResetDetail);
		BattleView.StopShowSelect(actCard, isAct: false, isTransformskill: false, isMoveTurn);
		ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create();
		if (_replayBattleMgr.ActCard != null && _replayBattleMgr.ActCard.BattleCardView != null && _replayBattleMgr.ActCard.BattleCardView.GameObject != null)
		{
			_replayBattleMgr.ActCard.BattleCardView.ShowFusionMetamorphoseFrameEffect(enable: false);
		}
		parallelVfxPlayer.Register(actCard.StartHandEffect());
		if (!isMoveTurn)
		{
			parallelVfxPlayer.Register(actCard.IsInHand ? actCard.BattleCardView.ShowHandCardInfo() : NullVfx.GetInstance());
		}
		_replayBattleMgr.VfxMgr.RegisterImmediateVfx(parallelVfxPlayer);
		if (actCard.IsInHand)
		{
			sequentialVfxPlayer.Register(InstantVfx.Create(delegate
			{
				base.HandControl.RearrangeHand(0.4f, base.HandCardList.ConvertToViewList());
			}));
		}
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			base.ClassInformationUIController.SetIsSelect(isSelect: false);
		}));
		if (!isMoveTurn)
		{
			sequentialVfxPlayer.Register(_replayBattleMgr.ShowHandEffect());
		}
		return sequentialVfxPlayer;
	}

	public VfxBase StartChoice(BattleCardBase actCard, List<NetworkBattleReceiver.CardInfo> cardInfoList, bool isEvolve)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		List<int> choiceCardIdList = cardInfoList.Select((NetworkBattleReceiver.CardInfo i) => i.Id).ToList();
		_choiceCards = _replayBattleMgr.CreateChoiceTokenCards(actCard, choiceCardIdList, PlayerBattleView);
		for (int num = 0; num < cardInfoList.Count; num++)
		{
			_replayBattleMgr.UpdateSkillDescriptionValueList(_choiceCards[num], cardInfoList[num]);
		}
		sequentialVfxPlayer.Register(StartShowChoice(actCard, _choiceCards, isEvolve));
		CanNotTouchCardVfx canNotTouchVfx = new CanNotTouchCardVfx();
		BattleManagerBase.GetIns().VfxMgr.RegisterImmediateVfx(canNotTouchVfx);
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			canNotTouchVfx.End();
		}));
		_replayBattleMgr.IsChoiceSelecting = true;
		_replayBattleMgr.ActCard = actCard;
		_replayBattleMgr.IsEvolve = isEvolve;
		return sequentialVfxPlayer;
	}

	private VfxBase StartShowChoice(BattleCardBase actCard, List<BattleCardBase> choiceCards, bool isEvolve)
	{
		BattleView.SetSelectCardList(choiceCards);
		ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create();
		for (int i = 0; i < base.HandCardList.Count; i++)
		{
			base.HandCardList[i].BattleCardView.HideCanPlayEffect();
		}
		BattleView.HideChoiceBraveButtonPulsateEffect();
		if (actCard.IsInHand)
		{
			if (actCard == PlayerBattleView.DetailOpenCard)
			{
				parallelVfxPlayer.Register(InstantVfx.Create(delegate
				{
					PlayerBattleView.HideDetailPanel();
				}));
			}
			BattleView.HandView.HideCardFromView(actCard.BattleCardView);
			parallelVfxPlayer.Register(InstantVfx.Create(delegate
			{
				BattleView.PlayQueueView.RemoveCardFromView(actCard.BattleCardView);
			}));
		}
		_dummySelectSkill = CreateDummySkill(actCard);
		parallelVfxPlayer.Register(new StartChoiceSelectVfx(actCard, choiceCards, _dummySelectSkill, null, actCard.IsInHand, isEvolve, isChoiceBrave: false));
		parallelVfxPlayer.Register(BattleView.HandView.HandUnfocus());
		return parallelVfxPlayer;
	}

	public VfxBase SelectChoice(List<int> chosenCardIndexList, bool hasSelectionSkill)
	{
		for (int i = 0; i < chosenCardIndexList.Count; i++)
		{
			_chosenCards.Add(_choiceCards[chosenCardIndexList[i]]);
			if (chosenCardIndexList.Count > 1)
			{
				GameObject checkFromIndex = BattleView.GetCheckFromIndex(chosenCardIndexList[i]);
				ChoiceUtility.ToggleChoiceButtonSprite(null, checkFromIndex, setActive: true, 0);
			}
		}
		_isTransformSelect = hasSelectionSkill;
		return WaitVfx.Create((chosenCardIndexList.Count > 1) ? 0.5f : 0f);
	}

	public VfxBase CompleteChoice(BattleCardBase card, bool hasSelectionSkill, bool isEvolve, bool isChoiceBrave)
	{
		BattleCardBase transformCard = null;
		card.BattleCardView.HideHandCardInfo();
		ChoiceUtility.StopChoiceEffects(_choiceCards);
		ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create(_replayBattleMgr.OperateMgr.BattleCardSelect(card, _chosenCards, isPlayer: true, registerEffectsDirectlyToVfxMgr: false));
		_dummySelectSkill.SelectCompleteFlag = true;
		if (!isEvolve && !isChoiceBrave)
		{
			_isSelectComplete = true;
		}
		_replayBattleMgr.IsChoiceSelecting = false;
		bool flag = ChoiceUtility.DoesDuplicateCardNotExistInHand(card);
		ParallelVfxPlayer parallelVfxPlayer2 = ParallelVfxPlayer.Create();
		bool flag2 = card.Skills.HaveChoiceTransformSkill() || isChoiceBrave;
		for (int i = 0; i < _choiceCards.Count; i++)
		{
			BattleCardBase choiceCard = _choiceCards[i];
			if (_chosenCards.Contains(choiceCard))
			{
				if (flag2)
				{
					if (!hasSelectionSkill && !isChoiceBrave)
					{
						card.BattleCardView.Transform.position = choiceCard.BattleCardView.Transform.position;
					}
				}
				else if (card.IsInHand)
				{
					parallelVfxPlayer2.Register(InstantVfx.Create(delegate
					{
						card.BattleCardView.Transform.position = choiceCard.BattleCardView.Transform.parent.position;
						card.BattleCardView.GameObject.SetActive(value: true);
					}));
					parallelVfxPlayer.Register(_replayBattleMgr.OperateMgr.InitSetCard(card, base.IsSelfTurn, isSelect: true, isRecovery: false, isChoiceSelect: true, isAccelerateSelect: false, registerDirectlyToVfxManager: false));
				}
				_transformChoiceCard = choiceCard;
				if (flag2 && hasSelectionSkill)
				{
					transformCard = choiceCard;
				}
			}
			if (transformCard != choiceCard)
			{
				if (flag)
				{
					choiceCard.UnloadResource();
				}
				parallelVfxPlayer2.Register(InstantVfx.Create(delegate
				{
					choiceCard.BattleCardView.GameObject.SetActive(value: false);
				}));
			}
		}
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create(parallelVfxPlayer2);
		if (transformCard != null)
		{
			ChoiceUtility.SetupChoiceCardForSkillTargetSelect(transformCard);
			parallelVfxPlayer.Register(_replayBattleMgr.OperateMgr.InitSetCard(transformCard, base.IsSelfTurn, isSelect: true));
			parallelVfxPlayer.Register(ReceivePlayActionsReflectionBase.CreateHideChoiceCardsVfx(card, _choiceCards.FindAll((BattleCardBase c) => c != transformCard), dontUnloadResources: true));
			parallelVfxPlayer.Register(InstantVfx.Create(delegate
			{
				BattleView.SetNotCancelCollider(new List<BattleCardBase> { transformCard }, isEnable: false);
			}));
		}
		sequentialVfxPlayer.Register(parallelVfxPlayer);
		_choiceCards = new List<BattleCardBase>();
		_chosenCards = new List<BattleCardBase>();
		BattleView.ClearSelectCardList();
		return sequentialVfxPlayer;
	}

	public VfxBase CancelChoice(BattleCardBase actCard, bool isEvolve, bool isMoveTurn = false)
	{
		if (!isEvolve)
		{
			PlayerBattleView.SetCancelPlayCardWithChoice(actCard, _choiceCards);
		}
		ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create(InstantVfx.Create(delegate
		{
			ChoiceUtility.StopChoiceEffects(_choiceCards);
			if (isEvolve)
			{
				bool isResetDetail = isMoveTurn || (PlayerBattleView.DetailOpenCard != null && !PlayerBattleView.DetailOpenCard.IsClass);
				_replayBattleMgr.VfxMgr.RegisterImmediateVfx(CancelSelectVfx(actCard, isEvolve, isMoveTurn, isResetDetail));
				ChoiceUtility.PlayCancelEvolveChoiceAnimation(_choiceCards, _replayBattleMgr);
				_replayBattleMgr.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
				{
					_choiceCards = new List<BattleCardBase>();
					BattleView.ClearSelectCardList();
				}));
			}
			else
			{
				_choiceCards = new List<BattleCardBase>();
				BattleView.ClearSelectCardList();
			}
		}));
		bool flag = isMoveTurn || (PlayerBattleView.DetailOpenCard != null && !PlayerBattleView.DetailOpenCard.IsClass);
		if (!isEvolve)
		{
			parallelVfxPlayer.Register(CancelSelectVfx(actCard, isEvolve, isMoveTurn, flag));
		}
		if (flag)
		{
			PlayerBattleView.HideDetailPanel();
		}
		_dummySelectSkill = null;
		_chosenCards = new List<BattleCardBase>();
		_replayBattleMgr.IsChoiceSelecting = false;
		return parallelVfxPlayer;
	}

	public VfxBase StartFusion(BattleCardBase actCard, List<BattleCardBase> selectableCards, NetworkBattleReceiver.CardInfo cardInfo)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		actCard.BattleCardView.HideHandCardInfo();
		actCard.BattleCardView.GameObject.transform.localEulerAngles = FusionTargetSelectTouchProcessor.INIT_LOCAL_EULAR_ANGLE;
		BattleView.PlayQueueView.AddCardToViewVfx(actCard.BattleCardView, forceCardIntoPlayQueue: true, isSelectTarget: true, isChoice: false);
		if (!actCard.HasNoSelectFusionSkill)
		{
			sequentialVfxPlayer.Register(InstantVfx.Create(delegate
			{
				BattleView.ShowAlert(PanelMgr.BattleAlertType.SelectChoiceCard, isClass: false, Data.SystemText.Get("Battle_0501"));
			}));
		}
		sequentialVfxPlayer.Register(StartShowSelect(actCard, selectableCards, isEvol: false, isFusion: true, cardInfo));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.StartShowFusionUI(actCard, selectableCards, 8, new EventDelegate(delegate
			{
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_CMN_CARD_SELECT_3);
			}));
			base.ClassInformationUIController.SetIsSelect(isSelect: true);
		}));
		_replayBattleMgr.IsFusionSelecting = true;
		_replayBattleMgr.ActCard = actCard;
		return sequentialVfxPlayer;
	}

	public VfxBase SelectFusion(int index, bool isActive, int maxSelectCount, bool canFusionMetamorphose)
	{
		return InstantVfx.Create(delegate
		{
			BattleView.SelectedFusionIngredientCard(index, isActive, maxSelectCount);
			if (_replayBattleMgr.ActCard != null && _replayBattleMgr.ActCard.BattleCardView != null)
			{
				_replayBattleMgr.ActCard.BattleCardView.ShowFusionMetamorphoseFrameEffect(canFusionMetamorphose);
			}
		});
	}

	public VfxBase CompleteFusion(BattleCardBase actCard, List<BattleCardBase> ingredientCards, NetworkBattleReceiver.CardInfo cardInfo, bool isFusionMetamorphose, int fusionMetamorphoseCardId, List<NetworkBattleReceiver.SideLogSkillInfo> sideLogSkillInfoList)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		CanNotTouchCardVfx canNotTouchCardVfx = new CanNotTouchCardVfx();
		_replayBattleMgr.VfxMgr.RegisterImmediateVfx(canNotTouchCardVfx);
		sequentialVfxPlayer.Register(ParallelVfxPlayer.Create(InstantVfx.Create(delegate
		{
			if (_replayBattleMgr.ActCard != null && _replayBattleMgr.ActCard.BattleCardView != null)
			{
				_replayBattleMgr.ActCard.BattleCardView.ShowFusionMetamorphoseFrameEffect(enable: false);
			}
		}), BattleView.RemoveFusionSelectedCardFromHand(ingredientCards), BattleView.CreateStopShowSelectVfx(actCard, isAct: true, stopChoiceSelectUiImmediately: false), _replayBattleMgr.Fusion(actCard, ingredientCards, this, cardInfo, isFusionMetamorphose, fusionMetamorphoseCardId, sideLogSkillInfoList)));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			canNotTouchCardVfx.End();
		}));
		BattleView.StopFusionUI();
		BattleView.ClearSelectCardList();
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			base.ClassInformationUIController.SetIsSelect(isSelect: false);
		}));
		_replayBattleMgr.IsFusionSelecting = false;
		return sequentialVfxPlayer;
	}

	public VfxBase CancelFusion(BattleCardBase actCard, bool isMoveTurn = false)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		sequentialVfxPlayer.Register(CancelSelectVfx(actCard, isEvolve: false, isMoveTurn));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			BattleView.StopFusionUI();
		}));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			PlayerBattleView.ForceStopShowSelect();
		}));
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			base.ClassInformationUIController.SetIsSelect(isSelect: false);
		}));
		_replayBattleMgr.IsFusionSelecting = false;
		return sequentialVfxPlayer;
	}

	public VfxBase UpdateDeck(BattleCardBase card, List<NetworkBattleReceiver.CardInfo> cardInfoList, bool isChange, bool isOpen, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.UpdateDeck(this, card, cardInfoList, isChange, isOpen, effectInfo);
	}

	public VfxBase Getoff(BattleCardBase attackCard, List<NetworkBattleReceiver.CardInfo> cardInfoList, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.Getoff(this, attackCard, cardInfoList, effectInfo);
	}

	public VfxBase Unite(BattleCardBase card, List<BattleCardBase> targetCards, int uniteCardId, int uniteCardIndex, NetworkBattleReceiver.EffectInfo effectInfo)
	{
		return _replayBattleMgr.Unite(this, card, targetCards, uniteCardId, uniteCardIndex, effectInfo);
	}

	public VfxBase OpenCard(BattleCardBase card)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		sequentialVfxPlayer.Register(new LoadAndPlayEffectVfx(SkillPreprocessOpenCard.HAND_SKILL_1_EFFECT, SkillPreprocessOpenCard.HAND_SKILL_1_SE, card.BattleCardView.GameObject.transform, 0.5f, isFollowAll: true));
		return sequentialVfxPlayer;
	}

	public VfxBase PlayEmotion(ClassCharaPrm.EmotionType emotionType)
	{
		return Emotion.PlayEmotion(emotionType, 1.5f);
	}
}
