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

public class DetailPanelControl : CardDetailBase, IDetailPanelControl
{
	public enum ShowRequest
	{
		NORMAL,
		MULLIGAN,
		EVOLUTION_SELECT,
		BATTLELOG,
		DESTROYLOG,
		CHOICE,
		BUFF_DETAIL,
		DECK_SUMMON_CARD_LIST,
		FUSION_INFO_CARD_LIST,
		CHOICE_BRAVE,
		CHOICE_BRAVE_AND_BUFF
	}

	private class CoroutineActions
	{
		public Coroutine _coroutine;

		public List<Action> _actions;

		public CoroutineActions(Action a)
		{
			_coroutine = null;
			_actions = new List<Action> { a };
		}
	}

	public struct ItemCursor
	{
		private const float ITEM_MARGIN = 3f;

		private float _offset;

		public float Height { get; private set; }

		public ItemCursor(float offset)
		{
			_offset = offset;
			Height = 0f;
		}

		public ItemCursor Clone()
		{
			ItemCursor result = new ItemCursor(0f);
			result.Height = Height;
			result._offset = _offset;
			return result;
		}

		public float AddAndGetCenterOffset(float height)
		{
			float result = _offset - 3f - height / 2f;
			float num = 6f + height;
			_offset -= num;
			Height += num;
			return result;
		}

		public float AddAndGetTopOffset(float height)
		{
			float result = _offset - 3f;
			float num = 6f + height;
			_offset -= num;
			Height += num;
			return result;
		}
	}

	[SerializeField]
	private BattleButtonControl battleButtonControl;

	[SerializeField]
	private UIPanel MainPanel;

	[SerializeField]
	private GameObject Window;

	[SerializeField]
	private GameObject FollowerPanel;

	[SerializeField]
	private UILabel FollowerAtkLabel;

	[SerializeField]
	private UILabel FollowerLifeLabel;

	[SerializeField]
	private GameObject EvoPanel;

	[SerializeField]
	private UILabel EvoTitleLabel;

	[SerializeField]
	private UILabel EvoAtkLabel;

	[SerializeField]
	private UILabel EvoLifeLabel;

	[SerializeField]
	private UISprite Underline;

	[SerializeField]
	private UIButton EvolutionButton;

	[SerializeField]
	private UILabel EvolutionComment;

	private UILabel _evolutionButtonUiLabel;

	[SerializeField]
	private UIButton FusionButton;

	private UILabel _fusionButtonUiLabel;

	[SerializeField]
	private UIButton NonFollowerFusionButton;

	private UILabel _nonFollowerFusionButtonUiLabel;

	[SerializeField]
	private UISprite NonFollowerFusionUnderline;

	[SerializeField]
	private UIWidget _buffRootWidget;

	[SerializeField]
	private UISprite _buffPanelSprite;

	[SerializeField]
	private UIPanel _buffPanel;

	[SerializeField]
	private UIPanel _buffContentsPanel;

	[SerializeField]
	private Transform _buffContentsParent;

	[SerializeField]
	private UIScrollBar _buffScrollBar;

	[SerializeField]
	private UIScrollView _buffScrollView;

	[SerializeField]
	private UIDragScrollView _bgDragScrollView;

	[SerializeField]
	private UILabel _buffTitleLabel;

	[SerializeField]
	private UILabel _myRotationBonusTitleLabel;

	[SerializeField]
	private UIPanel _myRotationBonusContentsPanel;

	[SerializeField]
	private Transform _myRotationBonusContentsParent;

	[SerializeField]
	private UISprite _myRotationBonusBorderLine;

	[SerializeField]
	private UIPanel _avatarBattleBonusContentsPanel;

	[SerializeField]
	private Transform _avatarBattleBonusContentsParent;

	[SerializeField]
	private UIScrollBar _avatarBattleBonusScrollBar;

	[SerializeField]
	private UIScrollView _avatarBattleBonusScrollView;

	[SerializeField]
	private Transform _avatarBattleBonusBPIconParent;

	[SerializeField]
	private UISprite _avatarBattleBonusBPSprite;

	[SerializeField]
	private UILabel _avatarBattleBonusBPLabel;

	[SerializeField]
	private UILabel _avatarBattleBonusBPDescriptionLabel;

	[SerializeField]
	private UILabel _bossRushSpecialSkillTitleLabel;

	[SerializeField]
	private UIPanel _bossRushSpecialSkillContentsPanel;

	[SerializeField]
	private Transform _bossRushSpecialSkillContentsParent;

	[SerializeField]
	public GameObject EvoTargetPanel;

	private GameObject _normalLightFrame;

	private GameObject _evoLightFrame;

	private Vector3 DefaultPanelPos;

	private Vector3 DefaultNorPanelPos;

	private Vector3 DefaultEvoPanelPos;

	[SerializeField]
	private BoxCollider _buffPanelCollider;

	private BattleManagerBase _battleMgr;

	private OperateMgr _operateMgr;

	private SystemText _text;

	private BuffInfo _buff;

	private string _divergenceId = string.Empty;

	private int _logTextureId;

	private bool _isToGreyTextEnabled;

	private readonly string[] GREY_TEXT_PATTERNS = new string[2] { "\\[u\\]\\[524522\\]", "\\[555555\\]-?\\[b\\]" };

	private const float LabelColliderSizeZ = 500f;

	private readonly float NONFOLOWER_SCROLLVIEW_POS_Y = -143.7f;

	private readonly float NONFOLOWER_DETAILLABEL_POS_Y = 37.7f;

	private const int CLASS_BUFF_CORRECTION_COEFFICIENT = 47;

	private const int CLASS_BUFF_ADVANCED_INFO_COEFFICIENT = 44;

	private const int MY_ROTATION_INFO_COEFFICIENT = 54;

	private const int CACHE_BUFF_LOG_MAX = 50;

	private const float BETWEEN_BUFF_AND_BUFF = 6f;

	private const float BETWEEN_BUFF_AND_BG_BOTTOM = 8f;

	private readonly Vector3 BATTLELOG_DETAIL = new Vector3(675f, -150f, 0f);

	private readonly Vector3 MULLIGAN_DETAIL = new Vector3(0f, 0f, -350f);

	private readonly Vector3 BUFF_LOG_DETAIL_LEFT = new Vector3(-434f, -106f, 0f);

	private readonly Vector3 BUFF_LOG_DETAIL_RIGHT = new Vector3(434f, -106f, 0f);

	private readonly Vector3 BATTLELOG_BUFF_SAME_BOTTOM_OFFSET = new Vector3(0f, 147f, 0f);

	private const float RIGHT_REL_OFFSET = -0.44f;

	private const float RIGHT_REL_OFFSET_MIN = -0.222f;

	private const float TOP_PIXEL_OFFSET = 34f;

	private const float TOP_PIXEL_OFFSET_MIN = -30f;

	private const float MIN_SCALE = 0.4f;

	private const float HIDE_DISTANCE = 10000f;

	private const float MAX_HEIGHT = 598f;

	private List<BattleLogItem> _cacheLogList = new List<BattleLogItem>();

	private List<MyRotationBonusItem> _cacheMyRotationLogList = new List<MyRotationBonusItem>();

	private List<BattleLogItem> _cachePlayerBossRushSkillList = new List<BattleLogItem>();

	private List<BossRushEnemySpecialSkillItem> _cacheEnemyBossRushSkillList = new List<BossRushEnemySpecialSkillItem>();

	private List<AvatarBattleTitleItem> _cacheAvatarBattleTitleList = new List<AvatarBattleTitleItem>();

	private List<AvatarBattlePassiveBonusItem> _cacheAvatarBattlePassiveBonusList = new List<AvatarBattlePassiveBonusItem>();

	private List<AvatarBattleBonusItem> _cacheAvatarBattleBonusList = new List<AvatarBattleBonusItem>();

	private List<GameObject> _drawLogList = new List<GameObject>();

	private GameObject _copiedLabel;

	private GameObject _saveBurialRiteLabel;

	private GameObject _getonCardLabel;

	private BuffDetailInfoUI _buffDetailInfoUI;

	private Vector3 _currentBuffWindowOffset = Vector3.zero;

	private const int CARD_ID_CLASS = 0;

	private static Dictionary<string, CoroutineActions> loadHeaderCoroutine = new Dictionary<string, CoroutineActions>();

	private bool _hasKeyword;

	public const string PREFAB_PATH = "Prefab/UI/DetailPanel";

	private DetailPanelControl _nextPanel;

	private DetailPanelControl _parentPanel;

	private const float LONG_PRESS_TIME = 0.2f;

	private float? _predictionWaitTime;

	private const string HBP_ICON_SPRITE_NAME = "icon_hbp";

	private const string PP_ICON_SPRITE_NAME = "icon_pp";

	public bool forceEvolutionConfirm { get; set; }

	public GameObject EvoTargetPanelColliderGameObject => EvoTargetPanel.GetComponent<Collider>().gameObject;

	public bool IsShow { get; private set; }

	public UIButton EvolveButton => EvolutionButton;

	public EvolutionConfirmation _evolutionConfirmation { get; private set; }

	public bool IsUpdateCardDescription { get; private set; }

	public BattleCardBase _card { get; private set; }

	public ShowRequest CurrentShowRequest { get; private set; }

	private bool IsEvolveToOtherCardLog => _logTextureId / 1000000 == 910;

	public event Action OnHideOneTime;

	public static bool IsDestroyOrDeckCardList(ShowRequest showRequest)
	{
		if (ShowRequest.DESTROYLOG != showRequest)
		{
			return ShowRequest.DECK_SUMMON_CARD_LIST == showRequest;
		}
		return true;
	}

	public static bool IsChoiceBraveRequest(ShowRequest showRequest)
	{
		if (showRequest != ShowRequest.CHOICE_BRAVE)
		{
			return showRequest == ShowRequest.CHOICE_BRAVE_AND_BUFF;
		}
		return true;
	}

	public void ResetUpdateCardDescriptionFlag()
	{
		IsUpdateCardDescription = false;
	}

	public void SetBuff(BuffInfo buff)
	{
		_buff = buff;
	}

	private void Start()
	{
		_evolutionConfirmation = new EvolutionConfirmation(base.transform);
		_evolutionButtonUiLabel = EvolutionButton.transform.Find("Label").GetComponent<UILabel>();
		_evolutionButtonUiLabel.text = Data.SystemText.Get("Battle_0117");
		EvolutionButton.defaultColor = new Color(1f, 1f, 1f);
		EvolutionButton.onClick.Clear();
		EvolutionButton.onClick.Add(new EventDelegate(delegate
		{
			if (!GameMgr.GetIns().IsWatchBattle && _battleMgr != null && _operateMgr != null && _card != null)
			{
				BattleCardBase evoCard = _card;
				if (_card.IsInplay)
				{
					GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
					if (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.CONFIRM_EVOLVE) || forceEvolutionConfirm)
					{
						_battleMgr.BattlePlayer.PlayerBattleView.CallOnOpenEvolveDialoguePanel();
						_evolutionConfirmation.Show(_battleMgr.BattlePlayer).onPushButton1 = delegate
						{
							OnTouchEvolutionButton(evoCard);
						};
					}
					else
					{
						OnTouchEvolutionButton(evoCard);
					}
				}
			}
		}));
		EventDelegate item = new EventDelegate(delegate
		{
			if (!GameMgr.GetIns().IsWatchBattle && _battleMgr != null && _operateMgr != null && _card != null && _card.IsInHand && _card.SelfBattlePlayer.IsSelfTurn)
			{
				OnTouchFusionButton(_card);
			}
		});
		FusionButton.defaultColor = new Color(1f, 1f, 1f);
		FusionButton.onClick.Clear();
		FusionButton.onClick.Add(item);
		_fusionButtonUiLabel = FusionButton.transform.Find("Label").GetComponent<UILabel>();
		_fusionButtonUiLabel.text = Data.SystemText.Get("Battle_0506");
		NonFollowerFusionButton.defaultColor = new Color(1f, 1f, 1f);
		NonFollowerFusionButton.onClick.Clear();
		NonFollowerFusionButton.onClick.Add(item);
		_nonFollowerFusionButtonUiLabel = NonFollowerFusionButton.transform.Find("Label").GetComponent<UILabel>();
		_nonFollowerFusionButtonUiLabel.text = Data.SystemText.Get("Battle_0506");
		_predictionWaitTime = null;
		UIEventListener.Get(EvolutionButton.gameObject).onPress = delegate(GameObject obj, bool isPress)
		{
			if (isPress)
			{
				_predictionWaitTime = Time.realtimeSinceStartup;
			}
			else
			{
				_predictionWaitTime = null;
				_battleMgr.Prediction.Clear();
			}
		};
		UIEventListener.Get(EvolutionButton.gameObject).onDragOut = delegate
		{
			_predictionWaitTime = null;
			_battleMgr.Prediction.Clear();
		};
		_normalLightFrame = FollowerPanel.transform.Find("LightFrame").gameObject;
		_evoLightFrame = EvoPanel.transform.Find("LightFrame").gameObject;
		DefaultPanelPos = MainPanel.transform.localPosition;
		MainPanel.transform.localPosition = DefaultPanelPos + Vector3.left * 10000f;
		MainPanel.alpha = 0f;
		IsShow = false;
		ResetUpdateCardDescriptionFlag();
		DefaultNorPanelPos = FollowerPanel.transform.localPosition;
		DefaultEvoPanelPos = EvoPanel.transform.localPosition;
		SystemText systemText = Data.SystemText;
		EvoTargetPanel.transform.Find("Label").GetComponent<UILabel>().text = systemText.Get("Battle_0117");
		List<GameObject> list = new List<GameObject>();
		list.Add(base.gameObject);
		list.Add(FollowerPanel);
		list.Add(EvoPanel);
		list.Add(_buffPanelSprite.gameObject);
		list.Add(EvoTargetPanel);
		UIManager.GetInstance().AttachAtlas(list);
		SetSize(OptionSettingWindow.GetBattleDetailPanelSizePercent());
		_followerPanel.Initialize();
		_followerEvoPanel.Initialize();
		_nonFollowerPanel.Initialize();
	}

	private void Update()
	{
		if (EvolutionButton.state == UIButtonColor.State.Pressed)
		{
			if (_predictionWaitTime.HasValue && _predictionWaitTime.Value + 0.2f < Time.realtimeSinceStartup)
			{
				_battleMgr.Prediction.Evolve(_card);
				_predictionWaitTime = null;
			}
		}
		else
		{
			_predictionWaitTime = null;
		}
	}

	private void OnTouchEvolutionButton(BattleCardBase card)
	{
		Hide();
		if (!_battleMgr.BattlePlayer.IsSelfTurn)
		{
			LocalLog.AccumulateLastTraceLog("OnTouchEvolutionButton selfTurn");
			return;
		}
		BattleLogManager instance = BattleLogManager.GetInstance();
		if (instance._clickSubLogItem != null)
		{
			instance._clickSubLogItem.OnUnClickLog();
		}
		_battleMgr.BattlePlayer.PlayerBattleView._isEvolutionSkillSelect = true;
		TouchControl touchControl = _battleMgr.TouchControl;
		touchControl.RegisterTouchProcessor(touchControl.CreateEvolutionSimpleProcessor(card));
		_battleMgr.BattleUIContainer.DisableMenu();
	}

	private void OnTouchFusionButton(BattleCardBase card)
	{
		Hide();
		BattleLogManager instance = BattleLogManager.GetInstance();
		if (instance._clickSubLogItem != null)
		{
			instance._clickSubLogItem.OnUnClickLog();
		}
		if (!_battleMgr.BattlePlayer.IsSelfTurn)
		{
			LocalLog.AccumulateLastTraceLog("OnTouchFusionButton selfTurn");
			return;
		}
		_battleMgr.TouchControl.RegisterTouchProcessor(new FusionSimpleProcessor(fusionSkill: card.Skills.FirstOrDefault((SkillBase s) => s is Skill_fusion), fusionMetamorphoseSkill: card.Skills.FirstOrDefault((SkillBase s) => s is Skill_fusion_metamorphose) as Skill_fusion_metamorphose, battleMgr: _battleMgr, card: card));
		_battleMgr.BattleUIContainer.DisableMenu();
	}

	public void Show(BattleManagerBase battleMgrBase, OperateMgr operateMgr, BattleCardBase card, ShowRequest showRequest)
	{
		BattleCoroutine.GetInstance().StartCoroutine(StartShow(battleMgrBase, operateMgr, card, showRequest));
	}

	public void ShowList(BattleManagerBase battleMgrBase, OperateMgr operateMgr, List<BattleCardBase> cards, ShowRequest showRequest, BuffInfo buff, BattleLogItem.CardTextureOption textureOption = BattleLogItem.CardTextureOption.Null, string divergenceId = "", int logTextureId = 0)
	{
		BattleCoroutine.GetInstance().StartCoroutine(StartShow(battleMgrBase, operateMgr, cards[0], showRequest, textureOption, buff, divergenceId, logTextureId));
		if ((bool)_nextPanel && cards.Count > 1)
		{
			_nextPanel.SetParent(this);
			List<BattleCardBase> cards2 = new List<BattleCardBase>(cards.GetRange(1, cards.Count - 1));
			_nextPanel.ShowList(battleMgrBase, operateMgr, cards2, showRequest, buff);
		}
	}

	public void CreateNextPanel()
	{
		GameMgr ins = GameMgr.GetIns();
		BattleManagerBase ins2 = BattleManagerBase.GetIns();
		GameObject gameObject = ins.GetGameObjMgr().AddUIContainerChildPrefab("Prefab/UI/DetailPanel");
		gameObject.transform.parent = ins2.BtlUIContainer.transform;
		_nextPanel = gameObject.GetComponent<DetailPanelControl>();
		_nextPanel.SetParent(this);
	}

	public void UpdateCardDescription()
	{
		if (!IsShow || _card == null || (_card.IsInHand && !_card.IsPlayer && !GameMgr.GetIns().IsAdminWatch && (CurrentShowRequest != ShowRequest.FUSION_INFO_CARD_LIST || !_isToGreyTextEnabled)))
		{
			return;
		}
		bool isSkipOption = CurrentShowRequest == ShowRequest.BATTLELOG || CurrentShowRequest == ShowRequest.DESTROYLOG || (CurrentShowRequest == ShowRequest.FUSION_INFO_CARD_LIST && !_isToGreyTextEnabled);
		if (!_card.IsClass)
		{
			if (_card.IsUnit)
			{
				bool flag = GameMgr.GetIns().IsNewReplayBattle && _buff != null && _buff.IsCopied;
				string skillDisc = (flag ? _card.CopiedSkillDescriptionInReplay(_buff, _buff.CopiedSkillDescriptionValueList) : _card.SkillDescription(null, isSkipOption, _buff, _divergenceId));
				string evoSkillDisc = ((IsEvolveToOtherCardLog || (_card.IsChoiceEvolutionCard && _logTextureId != 0)) ? CardMaster.GetInstanceForBattle().GetCardParameterFromId(_logTextureId).EvoSkillDescription : (flag ? _card.CopiedEvoSkillDescriptionInReplay(_buff, _buff.CopiedEvoSkillDescriptionValueList) : _card.EvoSkillDescription(null, isSkipOption, _buff)));
				SetFollowerDetailLabel(skillDisc, evoSkillDisc, Underline.gameObject.activeSelf, resetScrollPosition: false);
			}
			else
			{
				SetDescLabelText(_nonFollowerPanel, _card.SkillDescription(null, isSkipOption, _buff, _divergenceId), NonFollowerFusionUnderline.gameObject.activeSelf, resetScrollPosition: false);
			}
			Window.SetActive(value: false);
			Window.SetActive(value: true);
			IsUpdateCardDescription = true;
		}
	}

	private void UpdateAvatarBattleBonusPanel()
	{
		if (!IsChoiceBraveRequest(CurrentShowRequest) || _card == null)
		{
			return;
		}
		_avatarBattleBonusBPLabel.text = _card.SelfBattlePlayer.Bp.ToString();
		BattlePlayerBase.AvatarBattleDescInfo passiveSkillDescInfo = (_card.IsPlayer ? _battleMgr.BattlePlayer.AvatarBattlePassiveSkillDescInfo : _battleMgr.BattleEnemy.AvatarBattlePassiveSkillDescInfo);
		AvatarBattlePassiveBonusItem avatarBattlePassiveBonusItem = _cacheAvatarBattlePassiveBonusList.FirstOrDefault((AvatarBattlePassiveBonusItem cache) => cache.SkillDescInfo == passiveSkillDescInfo);
		if (avatarBattlePassiveBonusItem != null)
		{
			avatarBattlePassiveBonusItem.SetText(_card);
		}
		List<BattlePlayerBase.AvatarBattleDescInfo> choiceBraveDescInfoList = (_card.IsPlayer ? _battleMgr.BattlePlayer.ChoiceBraveSkillDescInfoList : _battleMgr.BattleEnemy.ChoiceBraveSkillDescInfoList);
		int i;
		for (i = 0; i < choiceBraveDescInfoList.Count; i++)
		{
			AvatarBattleBonusItem avatarBattleBonusItem = _cacheAvatarBattleBonusList.FirstOrDefault((AvatarBattleBonusItem cache) => cache.SkillDescInfo == choiceBraveDescInfoList[i]);
			if (avatarBattleBonusItem != null)
			{
				bool isNeedSeparator = _battleMgr.BattlePlayer.BattleView.IsShowCantChoiceBraveText || passiveSkillDescInfo.DescText != string.Empty || i != 0;
				avatarBattleBonusItem.SetText(_card, isNeedSeparator);
			}
		}
	}

	public void UpdateCardDescriptionOnEvent()
	{
		UpdateCardDescription();
		BattleManagerBase.GetIns().DetailMgr.SubDetailPanelControl.UpdateCardDescription();
		UpdateAvatarBattleBonusPanel();
	}

	public void UpdateCardDescriptionOnEvolutionEvent()
	{
		if (_card != null && !_card.IsChoiceEvolutionCard)
		{
			UpdateCardDescriptionOnEvent();
		}
	}

	private IEnumerator StartShow(BattleManagerBase battleMgrBase, OperateMgr operateMgr, BattleCardBase card, ShowRequest showRequest, BattleLogItem.CardTextureOption textureOption = BattleLogItem.CardTextureOption.Null, BuffInfo buff = null, string divergenceId = "", int logTextureId = 0)
	{
		base.gameObject.SetActive(value: true);
		RemoveCardEvent(card);
		_card = card;
		_battleMgr = battleMgrBase;
		_operateMgr = operateMgr;
		_text = Data.SystemText;
		CurrentShowRequest = showRequest;
		_buff = buff;
		_divergenceId = divergenceId;
		_logTextureId = logTextureId;
		_isToGreyTextEnabled = GREY_TEXT_PATTERNS.Any((string pattern) => Regex.IsMatch(_card.BaseParameter.SkillDescription, pattern));
		if (IsEvolveToOtherCardLog || (card.IsChoiceEvolutionCard && logTextureId == 0))
		{
			textureOption = BattleLogItem.CardTextureOption.ForceEvolution;
		}
		else if ((card.IsChoiceEvolutionCard || card.IsChoiceEvolutionCardBeforeUpdateBuildInfo) && logTextureId != 0)
		{
			textureOption = BattleLogItem.CardTextureOption.ForceNormal;
		}
		CardParameter baseParameter = ((IsEvolveToOtherCardLog || ((card.IsChoiceEvolutionCard || card.IsChoiceEvolutionCardBeforeUpdateBuildInfo) && logTextureId != 0)) ? CardMaster.GetInstanceForBattle().GetCardParameterFromId(logTextureId) : card.BaseParameter);
		DetailPanelInfo currentPanel = _followerPanel;
		if (!card.IsUnit)
		{
			currentPanel = _nonFollowerPanel;
			currentPanel._classLabel.gameObject.SetActive(value: true);
			currentPanel._myRotationInfo.SetActive(value: false);
		}
		GameMgr gameMgr = GameMgr.GetIns();
		DataMgr dataMgr = gameMgr.GetDataMgr();
		bool isSkipOption = showRequest == ShowRequest.BATTLELOG || showRequest == ShowRequest.DESTROYLOG || (CurrentShowRequest == ShowRequest.FUSION_INFO_CARD_LIST && !_isToGreyTextEnabled);
		string text = string.Format("battle_card_info_{0}", ((dataMgr.m_BattleType != DataMgr.BattleType.Story && !GameMgr.GetIns().IsPuzzleQuest) ? (card.IsClass ? dataMgr.GetCharaPrmByCharaId((card as ClassBattleCardBase).CharaId).class_id : ((int)card.BaseParameter.Clan)) : ((!card.IsPlayer) ? (card.IsClass ? dataMgr.GetEnemyClassId() : ((int)card.BaseParameter.Clan)) : (card.IsClass ? dataMgr.GetCharaPrmByCharaId((card as ClassBattleCardBase).CharaId).class_id : ((int)card.BaseParameter.Clan)))).ToString("00"));
		if (currentPanel._classBG.spriteName != text)
		{
			currentPanel._classBG.spriteName = text;
		}
		bool loaded = false;
		Action<Texture> cbOnLoaded = delegate
		{
			loaded = true;
		};
		if (card.IsClass)
		{
			bool isSkinEvolved = battleMgrBase.GetBattlePlayer(card.IsPlayer).IsSkinEvolved;
			LoadClassHeaderTexture((card as ClassBattleCardBase).CharaId, currentPanel._logImage, cbOnLoaded, isSkinEvolved);
		}
		else if (IsDestroyOrDeckCardList(showRequest) || textureOption == BattleLogItem.CardTextureOption.ForceNormal)
		{
			LoadCardHeaderTexture(baseParameter.NormalCardId, card.IsUnit, currentPanel._logImage, isEvolution: false, isBattleLogHeader: false, cbOnLoaded);
		}
		else if (textureOption == BattleLogItem.CardTextureOption.ForceEvolution)
		{
			LoadCardHeaderTexture(baseParameter.NormalCardId, card.IsUnit, currentPanel._logImage, isEvolution: true, isBattleLogHeader: false, cbOnLoaded);
		}
		else
		{
			LoadCardHeaderTexture(baseParameter.NormalCardId, card.IsUnit || (card.IsSpecialSkill && card.BaseParameter.CharType == CardBasePrm.CharaType.NORMAL), currentPanel._logImage, card.IsEvolution, isBattleLogHeader: false, cbOnLoaded);
		}
		while (!loaded)
		{
			yield return null;
		}
		ResetDetailPosition();
		if (!card.IsUnit)
		{
			FollowerPanel.SetActive(value: true);
			EvoPanel.SetActive(value: false);
			if (card.IsClass)
			{
				_nonFollowerPanel._costSprite.gameObject.SetActive(value: false);
				_nonFollowerPanel._costLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel._signLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel._zeroCostLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel._signedCostLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel.DiscLabel.gameObject.SetActive(value: false);
			}
			else if (card.IsSpecialSkill)
			{
				_nonFollowerPanel._costSprite.gameObject.SetActive(value: false);
				_nonFollowerPanel._costLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel._signLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel._zeroCostLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel._signedCostLabel.gameObject.SetActive(value: false);
				_nonFollowerPanel.DiscLabel.gameObject.SetActive(value: true);
			}
			else
			{
				_nonFollowerPanel._costSprite.gameObject.SetActive(value: true);
				bool flag = CardMaster.IsChoiceBraveCardCheck(baseParameter.CardId);
				_nonFollowerPanel._costSprite.spriteName = (flag ? "icon_hbp" : "icon_pp");
				if (baseParameter.IsVariableCost)
				{
					_nonFollowerPanel._costLabel.gameObject.SetActive(value: false);
					_nonFollowerPanel._signLabel.gameObject.SetActive(value: true);
					_nonFollowerPanel._zeroCostLabel.gameObject.SetActive(value: false);
					_nonFollowerPanel._signedCostLabel.gameObject.SetActive(value: true);
					_nonFollowerPanel._signLabel.text = "-";
					_nonFollowerPanel._signedCostLabel.text = "X";
				}
				else if (flag)
				{
					if (baseParameter.Cost == 0)
					{
						_nonFollowerPanel._costLabel.gameObject.SetActive(value: false);
						_nonFollowerPanel._signLabel.gameObject.SetActive(value: false);
						_nonFollowerPanel._zeroCostLabel.gameObject.SetActive(value: true);
						_nonFollowerPanel._signedCostLabel.gameObject.SetActive(value: false);
						_nonFollowerPanel._zeroCostLabel.text = baseParameter.Cost.ToString();
					}
					else
					{
						_nonFollowerPanel._costLabel.gameObject.SetActive(value: false);
						_nonFollowerPanel._signLabel.gameObject.SetActive(value: true);
						_nonFollowerPanel._zeroCostLabel.gameObject.SetActive(value: false);
						_nonFollowerPanel._signedCostLabel.gameObject.SetActive(value: true);
						_nonFollowerPanel._signLabel.text = ((baseParameter.Cost > 0) ? "-" : "+");
						_nonFollowerPanel._signedCostLabel.text = Mathf.Abs(baseParameter.Cost).ToString();
					}
				}
				else
				{
					_nonFollowerPanel._costLabel.gameObject.SetActive(value: true);
					_nonFollowerPanel._signLabel.gameObject.SetActive(value: false);
					_nonFollowerPanel._zeroCostLabel.gameObject.SetActive(value: false);
					_nonFollowerPanel._signedCostLabel.gameObject.SetActive(value: false);
					_nonFollowerPanel._costLabel.text = baseParameter.Cost.ToString();
				}
				_nonFollowerPanel.DiscLabel.gameObject.SetActive(value: true);
			}
			_normalLightFrame.SetActive(value: true);
			_nonFollowerPanel._root.SetActive(value: true);
			_followerPanel._root.SetActive(value: false);
			_followerEvoPanel._root.SetActive(value: false);
		}
		else
		{
			FollowerPanel.SetActive(value: true);
			_followerPanel._costLabel.text = baseParameter.Cost.ToString();
			FollowerAtkLabel.text = baseParameter.Atk.ToString();
			FollowerLifeLabel.text = baseParameter.Life.ToString();
			EvoPanel.SetActive(value: true);
			EvoTitleLabel.text = _text.Get("Card_0038");
			EvoAtkLabel.text = baseParameter.EvoAtk.ToString();
			EvoLifeLabel.text = baseParameter.EvoLife.ToString();
			if (IsDestroyOrDeckCardList(showRequest))
			{
				_normalLightFrame.SetActive(value: false);
				_evoLightFrame.SetActive(value: false);
			}
			else
			{
				bool flag2 = card.IsEvolution;
				switch (textureOption)
				{
				case BattleLogItem.CardTextureOption.ForceNormal:
					flag2 = false;
					break;
				case BattleLogItem.CardTextureOption.ForceEvolution:
					flag2 = true;
					break;
				}
				_normalLightFrame.SetActive(!flag2);
				_evoLightFrame.SetActive(flag2);
			}
			if (card.SelfBattlePlayer.IsSelfTurn && card.IsPlayer && card.IsInplay && card.AttackableCount <= 0)
			{
				_battleMgr.VfxMgr.RegisterImmediateVfx(card.BattleCardView.ShowAttackFinished());
			}
		}
		_avatarBattleBonusBPIconParent.gameObject.SetActive(IsChoiceBraveRequest(showRequest));
		AddCardEvent(card);
		EvolutionConfigSetup(card, _text, showRequest);
		if (card.IsUnit)
		{
			bool flag3 = GameMgr.GetIns().IsNewReplayBattle && buff != null && buff.IsCopied;
			string skillDisc = (flag3 ? card.CopiedSkillDescriptionInReplay(buff, buff.CopiedSkillDescriptionValueList) : card.SkillDescription(null, isSkipOption, buff));
			string evoSkillDisc = ((IsEvolveToOtherCardLog || (card.IsChoiceEvolutionCard && logTextureId != 0)) ? baseParameter.EvoSkillDescription : (flag3 ? card.CopiedEvoSkillDescriptionInReplay(buff, buff.CopiedEvoSkillDescriptionValueList) : card.EvoSkillDescription(null, isSkipOption, buff)));
			SetFollowerDetailLabel(skillDisc, evoSkillDisc, Underline.gameObject.activeSelf);
			_buffRootWidget.topAnchor.target = _followerEvoPanel._bg.transform;
		}
		else if (card.IsClass)
		{
			SetDescLabelText(_nonFollowerPanel, card.SkillDescription(null, isSkipOption, divergenceId: _divergenceId, buff: _buff), needEvolutionOrFusionButton: false, resetScrollPosition: true, isClass: true);
			_buffRootWidget.topAnchor.target = _nonFollowerPanel._bg.transform;
		}
		else
		{
			SetDescLabelText(_nonFollowerPanel, card.SkillDescription(null, isSkipOption, buff, _divergenceId), NonFollowerFusionUnderline.gameObject.activeSelf);
			_buffRootWidget.topAnchor.target = _nonFollowerPanel._bg.transform;
		}
		_buffRootWidget.ResetAnchors();
		_buffRootWidget.UpdateAnchors();
		if (!card.IsUnit)
		{
			_nonFollowerPanel._scrollView.transform.localPosition = new Vector3(_nonFollowerPanel._scrollView.transform.localPosition.x, NONFOLOWER_SCROLLVIEW_POS_Y, _nonFollowerPanel._scrollView.transform.localPosition.z);
			_nonFollowerPanel.DiscLabel.transform.localPosition = new Vector3(_nonFollowerPanel.DiscLabel.transform.localPosition.x, NONFOLOWER_DETAILLABEL_POS_Y, _nonFollowerPanel.DiscLabel.transform.localPosition.z);
		}
		if (card.IsClass)
		{
			ClassCharacterMasterData charaPrmByCharaId = dataMgr.GetCharaPrmByCharaId((card as ClassBattleCardBase).CharaId);
			currentPanel._nameLabel.text = charaPrmByCharaId.chara_name;
			if (charaPrmByCharaId.hide_class_name)
			{
				currentPanel._classLabel.text = "";
			}
			else
			{
				currentPanel._classLabel.text = dataMgr.GetClanNameByKey((int)charaPrmByCharaId.clan);
				if (card.IsPlayer)
				{
					if (dataMgr.GetPlayerSubClassId() != 10)
					{
						UILabel classLabel = currentPanel._classLabel;
						classLabel.text = classLabel.text + "/" + dataMgr.GetClanNameByKey(dataMgr.GetPlayerSubClassId());
					}
					if (dataMgr.TryGetPlayerMyRotationInfo(out var myRotationInfo))
					{
						SetMyRotationLabel(currentPanel, dataMgr.GetPlayerCharaData(), myRotationInfo);
					}
				}
				else
				{
					if (dataMgr.GetEnemySubClassId() != 10)
					{
						UILabel classLabel2 = currentPanel._classLabel;
						classLabel2.text = classLabel2.text + "/" + dataMgr.GetClanNameByKey(dataMgr.GetEnemySubClassId());
					}
					if (dataMgr.TryGetEnemyMyRotationInfo(out var myRotationInfo2))
					{
						SetMyRotationLabel(currentPanel, dataMgr.GetEnemyCharaData(), myRotationInfo2);
					}
				}
			}
		}
		else
		{
			currentPanel._nameLabel.text = (card.IsSpecialSkill ? Data.SystemText.Get("BossRush_0011", baseParameter.CardName) : baseParameter.CardName);
			int clan = (int)baseParameter.Clan;
			if (card.IsSpecialSkill)
			{
				currentPanel._classLabel.text = dataMgr.GetClanNameByKey(clan);
			}
			else
			{
				string tribeName = baseParameter.TribeName;
				if (tribeName != null && tribeName == "ALL")
				{
					currentPanel._classLabel.text = dataMgr.GetClanNameByKey(clan);
				}
				else
				{
					currentPanel._classLabel.text = dataMgr.GetClanNameByKey(clan) + " / " + baseParameter.TribeName;
				}
			}
		}
		gameMgr.GetSoundMgr().PlaySe(Se.TYPE.SYS_CARD_INFO_SMALL);
		List<BattlePlayerBase.MyRotationBonusCondition> myRotationBonusConditionList = new List<BattlePlayerBase.MyRotationBonusCondition>();
		List<BossRushSpecialSkill> bossRushSpecialSkillList = new List<BossRushSpecialSkill>();
		AvatarBattleInfo avatarBattleInfo = null;
		if (card.IsClass)
		{
			myRotationBonusConditionList.AddRange(card.SelfBattlePlayer.BonusConditionList);
			bossRushSpecialSkillList = card.SelfBattlePlayer.BossRushSpecialSkillList.Distinct().ToList();
			avatarBattleInfo = ((!card.SelfBattlePlayer.IsPlayer) ? _battleMgr.BattleEnemy.AvatarBattleInfo : _battleMgr.BattlePlayer.AvatarBattleInfo);
		}
		bool isShowBuffList = ((((!GameMgr.GetIns().IsNewReplayBattle) ? (card.BuffInfoList.Count > 0) : (card.ReplayBuffInfoList.Count > 0 || card.ReplayNoConsumeEpBuffInfoNameList.Count > 0 || card.ReplayBuffInfoLabelList.Count > 0)) || IsNeedNoConsumeEp(card)) && showRequest != ShowRequest.EVOLUTION_SELECT && ((showRequest != ShowRequest.BATTLELOG && showRequest != ShowRequest.FUSION_INFO_CARD_LIST) || card.IsClass) && !IsDestroyOrDeckCardList(showRequest) && showRequest != ShowRequest.BUFF_DETAIL) || myRotationBonusConditionList.Count > 0 || bossRushSpecialSkillList.Count > 0 || avatarBattleInfo != null;
		bool isShowAnimation = !IsShow;
		if (!IsShow)
		{
			IsShow = true;
			iTween.Stop(MainPanel.gameObject);
			yield return null;
			if (IsShow)
			{
				MainPanel.alpha = 0f;
				TweenAlpha.Begin(MainPanel.gameObject, 0.1f, 1f);
				if (!isShowBuffList)
				{
					_buffRootWidget.gameObject.SetActive(value: false);
				}
				else
				{
					_buffRootWidget.gameObject.SetActive(value: true);
					AddBuffInfo(card, showRequest, myRotationBonusConditionList, bossRushSpecialSkillList, avatarBattleInfo);
				}
			}
		}
		else if (!isShowBuffList)
		{
			_buffRootWidget.gameObject.SetActive(value: false);
		}
		SetupPanelTouchEvent(showRequest, baseParameter);
		Window.SetActive(value: false);
		Window.SetActive(value: true);
		_buffScrollView.RestrictWithinBounds(instant: true);
		_buffScrollView.ResetPosition();
		MainPanel.transform.localPosition = GetShowPos(showRequest);
		if (card.IsClass && (showRequest == ShowRequest.BATTLELOG || showRequest == ShowRequest.FUSION_INFO_CARD_LIST))
		{
			MainPanel.transform.position = new Vector3(MainPanel.transform.position.x, BattleLogManager.GetInstance()._logWindow.transform.position.y, MainPanel.transform.position.z);
			MainPanel.transform.localPosition += BATTLELOG_BUFF_SAME_BOTTOM_OFFSET;
		}
		if (isShowAnimation)
		{
			iTween.MoveFrom(MainPanel.gameObject, iTween.Hash("x", MainPanel.transform.localPosition.x, "y", MainPanel.transform.localPosition.y - 5f, "z", MainPanel.transform.localPosition.z, "islocal", true, "time", 0.1f, "easetype", iTween.EaseType.easeOutCubic));
		}
		UpdateParentAnchor();
		BattleLogManager.GetInstance()._logWindow.HideCardListPanel();
	}

	private void SetMyRotationLabel(DetailPanelInfo currentPanel, ClassCharacterMasterData classCharaData, MyRotationInfo myRotationInfo)
	{
		currentPanel._myRotationClassLabel.text = DeckData.CreateMyRotationClassName(classCharaData.class_id, myRotationInfo);
		currentPanel._classLabel.gameObject.SetActive(value: false);
		currentPanel._myRotationInfo.SetActive(value: true);
		currentPanel._myRotationBonusIconOriginal.SetActive(value: false);
		currentPanel._myRotationBonusIconGrid.transform.DestroyChildren();
		foreach (MyRotationInfo.MyRotationBonus ability in myRotationInfo.Abilities)
		{
			GameObject obj = NGUITools.AddChild(currentPanel._myRotationBonusIconGrid.gameObject, currentPanel._myRotationBonusIconOriginal);
			obj.GetComponent<UISprite>().spriteName = ability.IconName;
			obj.SetActive(value: true);
		}
		currentPanel._myRotationBonusIconGrid.Reposition();
		currentPanel._myRotationInfoGrid.Reposition();
		StartCoroutine(currentPanel._myRotationInfoGrid.RepositionNextFrame());
	}

	private Vector3 GetShowPos(ShowRequest showRequest)
	{
		return DefaultPanelPos + GetBuffWindowOffset(showRequest);
	}

	private Vector3 GetBuffWindowOffset(ShowRequest showRequest)
	{
		switch (showRequest)
		{
		case ShowRequest.MULLIGAN:
			_currentBuffWindowOffset = MULLIGAN_DETAIL;
			break;
		case ShowRequest.BATTLELOG:
		case ShowRequest.DESTROYLOG:
		case ShowRequest.DECK_SUMMON_CARD_LIST:
		case ShowRequest.FUSION_INFO_CARD_LIST:
			_currentBuffWindowOffset = BATTLELOG_DETAIL;
			break;
		case ShowRequest.BUFF_DETAIL:
			if (BattleManagerBase.GetIns().DetailMgr.DetailPanelControl.IsDisplayedRight())
			{
				SetScreenPosition(right: true);
				_currentBuffWindowOffset = BUFF_LOG_DETAIL_LEFT;
			}
			else
			{
				_currentBuffWindowOffset = BUFF_LOG_DETAIL_RIGHT;
			}
			break;
		default:
			_currentBuffWindowOffset = Vector3.zero;
			break;
		}
		return _currentBuffWindowOffset;
	}

	public bool IsDisplayedRight()
	{
		UIAnchor component = base.transform.Find("AnchorL").GetComponent<UIAnchor>();
		if (component != null)
		{
			return component.side == UIAnchor.Side.TopRight;
		}
		return false;
	}

	private void SetupPanelTouchEvent(ShowRequest showRequest, CardParameter baseParameter)
	{
		SetDetailKeywordEvents(null, _card, baseParameter, this);
		UIEventListener.Get(_buffPanelCollider.gameObject).onClick = null;
		if (ShowRequest.EVOLUTION_SELECT != showRequest && _hasKeyword)
		{
			SetDetailKeywordEvents(battleButtonControl.OnPressKeyBtn, _card, baseParameter, this);
		}
	}

	public VfxBase ShowEvolutionButton(BattleCardBase card)
	{
		return InstantVfx.Create(delegate
		{
			EvoTargetPanel.transform.parent = card.BattleCardView.Transform;
			EvoTargetPanel.transform.localPosition = new Vector3(0f, 18.5f, -1f);
			EvoTargetPanel.SetActive(value: true);
			GameMgr.GetIns().GetEffectMgr().StartBuff(EffectMgr.EffectType.CMN_FRAME_BTN_2, EvoTargetPanel);
			EvoTargetPanel.transform.localScale = new Vector3(1.6f, 1.6f, 1.6f);
			EvoTargetPanel.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
		});
	}

	private void EvolutionConfigSetup(BattleCardBase targetCard, SystemText text, ShowRequest showRequest)
	{
		UIButton uIButton = (targetCard.IsUnit ? FusionButton : NonFollowerFusionButton);
		UILabel uILabel = (targetCard.IsUnit ? _fusionButtonUiLabel : _nonFollowerFusionButtonUiLabel);
		UISprite uISprite = (targetCard.IsUnit ? Underline : NonFollowerFusionUnderline);
		if (GameMgr.GetIns().IsWatchBattle)
		{
			uISprite.gameObject.SetActive(value: false);
			uIButton.gameObject.SetActive(value: false);
			uILabel.gameObject.SetActive(value: false);
			EvolutionButton.gameObject.SetActive(value: false);
			EvolutionComment.gameObject.SetActive(value: false);
			return;
		}
		if (showRequest == ShowRequest.NORMAL && targetCard.IsInHand && targetCard.SelfBattlePlayer.IsSelfTurn && targetCard.HasFusionSkill)
		{
			uISprite.gameObject.SetActive(value: true);
			uIButton.isEnabled = targetCard.IsFusionable;
			uIButton.UpdateColor(instant: true);
			uIButton.gameObject.SetActive(value: true);
			EvolutionButton.gameObject.SetActive(value: false);
			EvolutionComment.gameObject.SetActive(value: false);
			return;
		}
		if (showRequest == ShowRequest.EVOLUTION_SELECT || showRequest == ShowRequest.BATTLELOG || IsDestroyOrDeckCardList(showRequest) || showRequest == ShowRequest.BUFF_DETAIL || showRequest == ShowRequest.FUSION_INFO_CARD_LIST || targetCard.IsEvolution || !targetCard.IsUnit || !targetCard.IsInplay || !targetCard.SelfBattlePlayer.IsSelfTurn || !targetCard.IsPlayer)
		{
			uISprite.gameObject.SetActive(value: false);
			EvolutionButton.gameObject.SetActive(value: false);
			EvolutionComment.gameObject.SetActive(value: false);
			uIButton.gameObject.SetActive(value: false);
			return;
		}
		EvolutionButton.UpdateColor(instant: true);
		uIButton.gameObject.SetActive(value: false);
		if (!targetCard.SelfBattlePlayer.NowTurnEvol)
		{
			uISprite.gameObject.SetActive(value: true);
			EvolutionButton.isEnabled = false;
			EvolutionButton.gameObject.SetActive(value: true);
			EvolutionComment.gameObject.SetActive(value: false);
		}
		else if (targetCard.SelfBattlePlayer.EvolveWaitTurnCount > 0)
		{
			uISprite.gameObject.SetActive(value: true);
			EvolutionComment.text = text.Get("Battle_0114", targetCard.SelfBattlePlayer.EvolveWaitTurnCount.ToString());
			EvolutionComment.gameObject.SetActive(value: true);
			EvolutionButton.gameObject.SetActive(value: false);
		}
		else if (targetCard.CanEvolution(isSkill: false, isSelfBattlePlayer: true) && targetCard.IsInplay && !_battleMgr.IsStopOperate)
		{
			uISprite.gameObject.SetActive(value: true);
			EvolutionButton.isEnabled = targetCard.AreCanEvolveConditionsFulfilled;
			EvolutionButton.gameObject.SetActive(value: true);
			EvolutionComment.gameObject.SetActive(value: false);
		}
		else
		{
			uISprite.gameObject.SetActive(value: true);
			EvolutionButton.isEnabled = false;
			EvolutionButton.gameObject.SetActive(value: true);
			EvolutionComment.gameObject.SetActive(value: false);
		}
	}

	public void Hide()
	{
		StartHide();
	}

	private void StartHide()
	{
		SetSize(OptionSettingWindow.GetBattleDetailPanelSizePercent());
		if (_battleMgr != null)
		{
			_battleMgr.BattlePlayer.IsShowBuffDetail = false;
			_battleMgr.BattleEnemy.IsShowBuffDetail = false;
			if (_card != null)
			{
				_card.IsShowBuffDetail = false;
			}
		}
		IsShow = false;
		_isToGreyTextEnabled = false;
		ResetUpdateCardDescriptionFlag();
		this.OnHideOneTime.Call();
		this.OnHideOneTime = null;
		RemoveCardEvent(_card);
		EvoTargetPanel.SetActive(value: false);
		GameMgr.GetIns().GetEffectMgr().Stop(EffectMgr.EffectType.CMN_FRAME_BTN_2);
		MainPanel.alpha = 0f;
		MainPanel.transform.localPosition = DefaultPanelPos + Vector3.left * 10000f;
		iTween.Stop(MainPanel.gameObject);
		_buffScrollView.currentMomentum = Vector3.zero;
		_card = null;
		base.gameObject.SetActive(value: false);
		_nonFollowerPanel._scrollView.currentMomentum = new Vector3(0f, 0f, 0f);
		_nonFollowerPanel._scrollView.DisableSpring();
		_followerEvoPanel._root.SetActive(value: false);
		_nonFollowerPanel._root.SetActive(value: false);
		_followerEvoPanel._root.SetActive(value: false);
		if ((bool)_nextPanel)
		{
			_nextPanel.StartHide();
		}
		BattleManagerBase.GetIns().DetailMgr.SubDetailPanel.gameObject.SetActive(value: false);
		battleButtonControl.HideKeyWordDialog(isNotCloseEvent: false);
	}

	private void ResetDetailPosition()
	{
		FollowerPanel.transform.localPosition = DefaultNorPanelPos;
		EvoPanel.transform.localPosition = DefaultEvoPanelPos;
	}

	private void AddBuffInfo(BattleCardBase targetCard, ShowRequest request, List<BattlePlayerBase.MyRotationBonusCondition> myRotationBonusList, List<BossRushSpecialSkill> bossRushSpecialSkillList, AvatarBattleInfo avatarBattleInfo)
	{
		if (_card != null)
		{
			SetupAllBuffPanel(targetCard, GetBuffWindowOffset(request).y, myRotationBonusList, bossRushSpecialSkillList, avatarBattleInfo, isUpdate: false, IsChoiceBraveRequest(request));
		}
	}

	public void UpdateBuffInfo(BattleCardBase targetCard, List<BattlePlayerBase.MyRotationBonusCondition> myRotationBonusList)
	{
		if (!IsShow)
		{
			return;
		}
		List<BossRushSpecialSkill> bossRushSkillList = new List<BossRushSpecialSkill>();
		AvatarBattleInfo avatarBattleInfo = null;
		if (targetCard.IsClass)
		{
			bossRushSkillList = targetCard.SelfBattlePlayer.BossRushSpecialSkillList.Distinct().ToList();
			avatarBattleInfo = ((!targetCard.SelfBattlePlayer.IsPlayer) ? _battleMgr.BattleEnemy.AvatarBattleInfo : _battleMgr.BattlePlayer.AvatarBattleInfo);
		}
		if ((GameMgr.GetIns().IsNewReplayBattle ? (targetCard.ReplayBuffInfoList.Count == 0) : (targetCard.BuffInfoList.Count == 0)) && myRotationBonusList.Count == 0 && avatarBattleInfo == null)
		{
			_buffRootWidget.gameObject.SetActive(value: false);
			return;
		}
		if (!_buffRootWidget.gameObject.activeSelf)
		{
			_buffRootWidget.gameObject.SetActive(value: true);
		}
		SetupAllBuffPanel(targetCard, _currentBuffWindowOffset.y, myRotationBonusList, bossRushSkillList, avatarBattleInfo, isUpdate: true, avatarBattleInfo != null);
	}

	public void UpdateLogItemBuffInfo(BattleCardBase targetCard)
	{
		List<BuffInfo> list = targetCard.ReplayBuffInfoList.Where((BuffInfo b) => b.IsCopied).ToList();
		for (int num = 0; num < list.Count; num++)
		{
			BuffInfo buffInfo = list[num];
			BattleLogItem logFromCacheLogList = GetLogFromCacheLogList(buffInfo, (!buffInfo.IsCopiedEvolutionSkill) ? BattleLogItem.CardTextureOption.ForceNormal : BattleLogItem.CardTextureOption.ForceEvolution, buffInfo.DivergenceId, checkActive: false);
			if (logFromCacheLogList != null)
			{
				logFromCacheLogList.SetBuff(buffInfo);
			}
		}
	}

	private void MakeCardLogItem(BuffInfo buff, Transform contentsParent, ref ItemCursor itemCursor)
	{
		if (buff.IsHiddenClassLogSkill)
		{
			return;
		}
		BattleCardBase battleCardBase = buff.OwnerCard;
		bool flag = (buff.IsCopied && buff.IsCopiedEvolutionSkill) || (!buff.IsCopied && buff.IsEvolutionSkill);
		if (battleCardBase.IsClass)
		{
			flag = battleCardBase.SelfBattlePlayer.IsSkinEvolved;
		}
		BattleLogItem.CardTextureOption textureOption = ((!flag) ? BattleLogItem.CardTextureOption.ForceNormal : BattleLogItem.CardTextureOption.ForceEvolution);
		string divergenceId = string.Empty;
		if (buff.SkillFrom != null || GameMgr.GetIns().IsNewReplayBattle)
		{
			divergenceId = buff.DivergenceId;
		}
		BattleLogItem battleLogItem = GetLogFromCacheLogList(buff, textureOption, divergenceId);
		if (battleLogItem == null)
		{
			if (_cacheLogList.Count > 50)
			{
				for (int num = _cacheLogList.Count - 1; num >= 0; num--)
				{
					BattleLogItem battleLogItem2 = _cacheLogList[num];
					if (!battleLogItem2.gameObject.activeSelf)
					{
						UnityEngine.Object.Destroy(battleLogItem2.gameObject);
						_cacheLogList.RemoveAt(num);
					}
				}
			}
			bool? isPlayer = null;
			if (buff.IsCopied && buff.SkillFrom != null)
			{
				isPlayer = buff.IsPlayer;
			}
			if (buff.PreviousOwner != null)
			{
				battleCardBase = buff.PreviousOwner;
			}
			if (buff.IsSaveBurialRiteSkill || buff.IsGetonSkill || buff.IsReserveTokenDrawSkill)
			{
				battleCardBase = ((!GameMgr.GetIns().IsNewReplayBattle) ? battleCardBase.SelfBattlePlayer.BattleMgr.CreateTransformCardRegisterVfx(battleCardBase, buff.BaseCardIDFrom, _card.IsPlayer) : buff.TargetCard);
			}
			battleLogItem = BattleLogManager.CreateBuffLogItem(battleCardBase, battleCardBase, buff, isPlayer, buff.IsReserveTokenDrawSkill, textureOption, buff.CardIDFrom);
			if (buff.IsReserveTokenDrawSkill)
			{
				battleLogItem.UpdateLogType(Wizard.Battle.UI.LogType.ReserveToken);
			}
			battleLogItem.SetLogSkill(buff.SkillFrom);
			_cacheLogList.Add(battleLogItem);
		}
		else if (GameMgr.GetIns().IsNewReplayBattle && buff.IsCopied)
		{
			battleLogItem.SetBuff(buff);
		}
		battleLogItem.transform.SetParent(contentsParent);
		battleLogItem.transform.localScale = Vector3.one;
		battleLogItem.SetDivergenceId(divergenceId);
		float y = itemCursor.AddAndGetCenterOffset(47f);
		battleLogItem.transform.localPosition = new Vector3(buff.IsReserveTokenDrawSkill ? battleLogItem.GetPosX() : 0f, y, 0f);
		battleLogItem.gameObject.SetActive(value: true);
		_drawLogList.Add(battleLogItem.gameObject);
		battleLogItem.SetSelectSpriteActive(setActive: false);
	}

	private BattleLogItem GetLogFromCacheLogList(BuffInfo buff, BattleLogItem.CardTextureOption textureOption, string divergenceId, bool checkActive = true)
	{
		return _cacheLogList.FirstOrDefault(delegate(BattleLogItem cache)
		{
			if (cache.gameObject.activeSelf && checkActive)
			{
				return false;
			}
			bool flag = cache.IsCopiedBuff();
			if (buff.IsCopied != flag)
			{
				return false;
			}
			BattleCardBase card = cache.GetCard();
			if (buff.IsCopied && buff.PreviousOwner != null && buff.PreviousOwner == card && _card.IsPlayer != cache.IsPlayer && cache.GetTextureOption() == textureOption && buff.OwnerCard == cache.Buff.OwnerCard)
			{
				return true;
			}
			bool flag2 = (buff.IsGetonSkill || buff.IsSaveBurialRiteSkill || buff.IsReserveTokenDrawSkill) && cache.GetLogSkill() == buff.SkillFrom && card.BaseParameter.CardId == buff.BaseCardIDFrom && cache.GetTextureOption() == textureOption;
			if (GameMgr.GetIns().IsNewReplayBattle)
			{
				if (buff.IsReserveTokenDrawSkill)
				{
					flag2 &= buff.TargetCard != null && buff.TargetCard == card;
				}
				else if (buff.IsGetonSkill || buff.IsSaveBurialRiteSkill)
				{
					flag2 &= buff.IsPlayer == cache.IsPlayer;
				}
			}
			if (flag2)
			{
				return true;
			}
			if (buff.IsReserveTokenDrawSkill)
			{
				return false;
			}
			return !buff.IsCopied && card == buff.OwnerCard && card.IsPlayer == cache.IsPlayer && cache.GetTextureOption() == textureOption && cache.DivergenceId == divergenceId && cache.GetBuffMomentCardId() == buff.CardIDFrom;
		});
	}

	private void MakeCardLogItemNoConsumeEp(BattleCardBase card, Transform contentsParent, ref ItemCursor itemCursor)
	{
		BattleLogItem.CardTextureOption textureOption = ((!card.IsEvolution) ? BattleLogItem.CardTextureOption.ForceNormal : BattleLogItem.CardTextureOption.ForceEvolution);
		BattleLogItem battleLogItem = BattleLogManager.CreateBuffLogItem(card, card, null, card.IsPlayer, useSmall: false, textureOption);
		battleLogItem.UpdateLogType(Wizard.Battle.UI.LogType.NotConsumeEp);
		battleLogItem.transform.SetParent(contentsParent);
		battleLogItem.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetCenterOffset(47f);
		battleLogItem.transform.localPosition = new Vector3(0f, y, 0f);
		battleLogItem.gameObject.SetActive(value: true);
		_drawLogList.Add(battleLogItem.gameObject);
		battleLogItem.SetSelectSpriteActive(setActive: false);
	}

	private void MakeMyRotationBonusItem(BattleCardBase classCard, BattlePlayerBase.MyRotationBonusCondition myRotationBonusCondition, bool needSeparator, ref ItemCursor itemCursor)
	{
		MyRotationBonusItem myRotationBonusItem = _cacheMyRotationLogList.FirstOrDefault(delegate(MyRotationBonusItem cache)
		{
			if (cache.gameObject.activeSelf)
			{
				return false;
			}
			return myRotationBonusCondition.MyRotationBonus.AbilityId == cache.MyRotationBonusCondition.MyRotationBonus.AbilityId && classCard.IsPlayer == cache.IsPlayer;
		});
		if (myRotationBonusItem == null)
		{
			if (_cacheLogList.Count > 50)
			{
				for (int num = _cacheLogList.Count - 1; num >= 0; num--)
				{
					BattleLogItem battleLogItem = _cacheLogList[num];
					if (!battleLogItem.gameObject.activeSelf)
					{
						UnityEngine.Object.Destroy(battleLogItem.gameObject);
						_cacheLogList.RemoveAt(num);
					}
				}
			}
			myRotationBonusItem = BattleLogManager.CreateMyRotationBonusItem(myRotationBonusCondition, classCard.IsPlayer, needSeparator);
			_cacheMyRotationLogList.Add(myRotationBonusItem);
		}
		else
		{
			myRotationBonusItem.setIconActive();
		}
		myRotationBonusItem.transform.SetParent(_myRotationBonusContentsParent);
		myRotationBonusItem.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetCenterOffset(54f);
		myRotationBonusItem.transform.localPosition = new Vector3(0f, y, 0f);
		myRotationBonusItem.gameObject.SetActive(value: true);
		_drawLogList.Add(myRotationBonusItem.gameObject);
	}

	private bool IsSameBuffLog(BuffInfo buffA, BuffInfo buffB)
	{
		if (buffA.IsCopied != buffB.IsCopied)
		{
			return false;
		}
		if (buffA.IsCopied)
		{
			return buffA.PreviousOwner == buffB.PreviousOwner;
		}
		BattleCardBase ownerCard = buffA.SkillFrom.SkillPrm.ownerCard;
		BattleCardBase ownerCard2 = buffB.SkillFrom.SkillPrm.ownerCard;
		if (!ownerCard.EquelsID(ownerCard2))
		{
			return false;
		}
		if (ownerCard.CardId != buffA.CardIDFrom && buffA.CardIDFrom != buffB.CardIDFrom)
		{
			return false;
		}
		if (ownerCard.IsChoiceBraveSkillCard || ownerCard2.IsChoiceBraveSkillCard)
		{
			return ownerCard == ownerCard2;
		}
		if (buffA.PreviousOwner != null && buffB.PreviousOwner != null)
		{
			return buffA.PreviousOwner.CardId == buffB.PreviousOwner.CardId;
		}
		return buffA.PreviousOwner == buffB.PreviousOwner;
	}

	private float SetupBuffContent(BattleCardBase targetCard, Transform contentsParent, ref ItemCursor itemCursor)
	{
		List<BuffInfo> buffInfoList = targetCard.BuffInfoList;
		List<BuffInfo> source = ((!GameMgr.GetIns().IsNewReplayBattle) ? GetDistinctBuffList(buffInfoList) : targetCard.ReplayBuffInfoList);
		if (GameMgr.GetIns().IsNewReplayBattle)
		{
			for (int i = 0; i < targetCard.ReplayNoConsumeEpBuffInfoNameList.Count; i++)
			{
				MakeCardLogItemNoConsumeEp(targetCard.ReplayNoConsumeEpBuffInfoNameList[i], contentsParent, ref itemCursor);
			}
		}
		else if (IsNeedNoConsumeEp(targetCard))
		{
			IEnumerable<BattleCardBase> source2 = targetCard.SelfBattlePlayer.InPlayCards.Where((BattleCardBase c) => c.SkillApplyInformation.NotConsumeEpModifierInfoList.Any((NotConsumeEpModifierInfo b) => b.TargetCard == null && b.CheckNotConsumedCard(targetCard)));
			for (int num = 0; num < source2.Count(); num++)
			{
				MakeCardLogItemNoConsumeEp(source2.ElementAt(num), contentsParent, ref itemCursor);
			}
		}
		List<BuffInfo> list = source.Where((BuffInfo b) => !b.IsCopied && !b.IsSaveBurialRiteSkill && !b.IsGetonSkill && b.SpecialSkillInfo == null).ToList();
		for (int num2 = 0; num2 < list.Count; num2++)
		{
			MakeCardLogItem(list[num2], contentsParent, ref itemCursor);
		}
		List<BuffInfo> list2 = source.Where((BuffInfo b) => b.IsCopied).ToList();
		if (list2.Count > 0)
		{
			MakeHeadlineLabel(ref _copiedLabel, Data.SystemText.Get("BattleLog_0266"), contentsParent, ref itemCursor);
			MakeLogItems(list2, contentsParent, ref itemCursor);
		}
		List<BuffInfo> list3 = source.Where((BuffInfo b) => b.IsSaveBurialRiteSkill).ToList();
		if (list3.Count > 0)
		{
			MakeHeadlineLabel(ref _saveBurialRiteLabel, Data.SystemText.Get("BattleLog_0269"), contentsParent, ref itemCursor);
			MakeLogItems(list3, contentsParent, ref itemCursor);
		}
		List<BuffInfo> list4 = source.Where((BuffInfo b) => b.IsGetonSkill).ToList();
		if (list4.Count > 0)
		{
			MakeHeadlineLabel(ref _getonCardLabel, Data.SystemText.Get("BattleLog_0272"), contentsParent, ref itemCursor);
			MakeLogItems(list4, contentsParent, ref itemCursor);
		}
		if ((!GameMgr.GetIns().IsNewReplayBattle) ? BuffDetailInfoUI.NeedBuffDetailText(targetCard) : (targetCard.ReplayBuffInfoLabelList.Count > 0))
		{
			if (_buffDetailInfoUI == null)
			{
				_buffDetailInfoUI = (UnityEngine.Object.Instantiate(Resources.Load("Prefab/UI/Log/SkillDetailLabel")) as GameObject).GetComponent<BuffDetailInfoUI>();
				_buffDetailInfoUI.Initialize();
			}
			_buffDetailInfoUI.gameObject.SetActive(value: true);
			_buffDetailInfoUI.transform.SetParent(contentsParent);
			_buffDetailInfoUI.transform.localScale = Vector3.one;
			_drawLogList.Add(_buffDetailInfoUI.gameObject);
			if (GameMgr.GetIns().IsNewReplayBattle)
			{
				_buffDetailInfoUI.SetBuffDetailLabelInReplay(targetCard.ReplayBuffInfoLabelList, targetCard);
			}
			else
			{
				_buffDetailInfoUI.SetBuffDetailLabel(targetCard);
			}
			float y = itemCursor.AddAndGetTopOffset(_buffDetailInfoUI.Height);
			_buffDetailInfoUI.transform.localPosition = new Vector3(0f, y, 0f);
		}
		return itemCursor.Height;
	}

	public List<BuffInfo> GetDistinctBuffList(List<BuffInfo> buffInfoList)
	{
		List<BuffInfo> list = new List<BuffInfo>();
		int i;
		for (i = 0; i < buffInfoList.Count; i++)
		{
			if (buffInfoList[i].IsReserveTokenDrawSkill)
			{
				BuffInfo buffInfo = list.LastOrDefault();
				if (buffInfo == null || buffInfoList[i].SkillFrom.GetAttachSkill == null || buffInfo.SkillFrom.SkillPrm.ownerCard.Index == buffInfoList[i].SkillFrom.GetAttachSkill.SkillPrm.ownerCard.Index || (buffInfo.SkillFrom.GetAttachSkill != null && buffInfo.SkillFrom.GetAttachSkill.SkillPrm.ownerCard.Index == buffInfoList[i].SkillFrom.GetAttachSkill.SkillPrm.ownerCard.Index && buffInfo.SkillFrom.HasIndividualId))
				{
					list.Add(buffInfoList[i]);
					continue;
				}
				BuffInfo buffInfo2 = list.LastOrDefault((BuffInfo b) => b.SkillFrom.SkillPrm.ownerCard.Index == buffInfoList[i].SkillFrom.GetAttachSkill.SkillPrm.ownerCard.Index || (b.SkillFrom.GetAttachSkill != null && b.SkillFrom.GetAttachSkill.SkillPrm.ownerCard.Index == buffInfoList[i].SkillFrom.GetAttachSkill.SkillPrm.ownerCard.Index && b.SkillFrom.HasIndividualId));
				if (buffInfo2 == null)
				{
					buffInfo2 = list.LastOrDefault((BuffInfo b) => b.IsReserveTokenDrawSkill || b.SkillFrom.SkillPrm.ownerCard.BaseParameter.BaseCardId == buffInfoList[i].SkillFrom.SkillPrm.ownerCard.BaseParameter.BaseCardId);
				}
				list.Insert(list.IndexOf(buffInfo2) + 1, buffInfoList[i]);
			}
			else if ((!(buffInfoList[i].SkillFrom is Skill_token_draw_modifier) || !list.Any((BuffInfo b) => b.BaseCardIDFrom == buffInfoList[i].BaseCardIDFrom)) && !list.Any((BuffInfo b) => IsSameBuffLog(b, buffInfoList[i])))
			{
				list.Add(buffInfoList[i]);
			}
		}
		return list;
	}

	public List<NetworkBattleReceiver.ReplayBuffInfoLabel> GetBuffDetailLabel(BattleCardBase card)
	{
		List<NetworkBattleReceiver.ReplayBuffInfoLabel> list = new List<NetworkBattleReceiver.ReplayBuffInfoLabel>();
		if (!BuffDetailInfoUI.NeedBuffDetailText(card))
		{
			return list;
		}
		List<SkillBase> allBuffSkills = BuffDetailInfoUI.GetAllBuffSkills(card, card.BuffInfoList.Select((BuffInfo b) => b.SkillFrom).ToList());
		if (card.Cost != card.BaseCost)
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Cost));
		}
		if (allBuffSkills.Any((SkillBase s) => s is Skill_powerup || s is Skill_power_down) && (card.GetCurrentAtkBuff() != 0 || card.GetCurrentLifeBuff() != 0))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.StatusBuff));
		}
		bool flag = false;
		if (allBuffSkills.Any((SkillBase s) => s is Skill_quick && (!card.IsInHand || s.OnWhenPlayStart == 0)))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Quick));
			flag = true;
		}
		bool flag2 = false;
		if (allBuffSkills.Any((SkillBase s) => s is Skill_rush && (!card.IsInHand || s.OnWhenPlayStart == 0)))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Rush));
			flag2 = true;
		}
		bool flag3 = false;
		if (allBuffSkills.Any((SkillBase s) => s is Skill_killer && (!card.IsInHand || s.OnWhenPlayStart == 0)))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Killer));
			flag3 = true;
		}
		bool flag4 = false;
		if (allBuffSkills.Any((SkillBase s) => s is Skill_drain && (!card.IsInHand || s.OnWhenPlayStart == 0)))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Drain));
			flag4 = true;
		}
		if (allBuffSkills.Any((SkillBase s) => s is Skill_attack_count && (!card.IsInHand || s.OnWhenPlayStart == 0)))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.AttackCount, card.MaxAttackableCount));
		}
		if (allBuffSkills.Any((SkillBase s) => s is Skill_ignore_guard && (!card.IsInHand || s.OnWhenPlayStart == 0)))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.IgnoreGuard));
		}
		if (allBuffSkills.Any((SkillBase s) => s is Skill_consume_ep_modifier && (!card.IsInHand || s.OnWhenPlayStart == 0)) || BuffDetailInfoUI.NeedNoConsumeEpText(card))
		{
			list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.ConsumeEpModifier));
		}
		if (BuffDetailInfoUI.ExistCopiedSkillNeedDetailText(card))
		{
			IEnumerable<BuffInfo> source = card.BuffInfoList.Where((BuffInfo b) => b.IsCopied);
			for (int num = 0; num < source.Count(); num++)
			{
				if (!(source.ElementAt(num).SkillFrom is SkillBaseCopy skillBaseCopy))
				{
					continue;
				}
				switch (skillBaseCopy.SkillType)
				{
				case "rush":
					if (!flag2)
					{
						list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Rush));
					}
					break;
				case "quick":
					if (!flag)
					{
						list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Quick));
					}
					break;
				case "killer":
					if (!flag3)
					{
						list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Killer));
					}
					break;
				case "drain":
					if (!flag4)
					{
						list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.Drain));
					}
					break;
				}
			}
		}
		IEnumerable<Skill_shield> source2 = from s in allBuffSkills
			where s is Skill_shield && (!card.IsInHand || s.OnWhenPlayStart == 0)
			select (Skill_shield)s;
		if (source2.Any())
		{
			if (source2.Any((Skill_shield s) => s.IsAllDamageShield))
			{
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.AllDamageShield));
			}
			if (source2.Any((Skill_shield s) => s.IsNextDamageShield))
			{
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.NextDamageShield));
			}
			if (source2.Any((Skill_shield s) => s.IsSkillDamageShield))
			{
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.SkillDamageShield));
			}
			if (source2.Any((Skill_shield s) => s.IsSpellDamageShield))
			{
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.SpellDamageShield));
			}
		}
		List<Skill_damage_cut> source3 = (from s in allBuffSkills
			where s is Skill_damage_cut && (!card.IsInHand || s.OnWhenPlayStart == 0)
			select (Skill_damage_cut)s).ToList();
		if (source3.Any())
		{
			if (source3.Any((Skill_damage_cut s) => s.IsAllDamageCut))
			{
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.AllDamageCut, source3.Where((Skill_damage_cut s) => s.IsAllDamageCut).Sum((Skill_damage_cut s) => s.CutAmount)));
			}
			if (source3.Any((Skill_damage_cut s) => s.IsNextDamageCut))
			{
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.NextDamageCut, source3.Where((Skill_damage_cut s) => s.IsNextDamageCut).Sum((Skill_damage_cut s) => s.CutAmount)));
			}
			if (source3.Any((Skill_damage_cut s) => s.IsSkillDamageCut))
			{
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.SkillDamageCut, source3.Where((Skill_damage_cut s) => s.IsSkillDamageCut).Sum((Skill_damage_cut s) => s.CutAmount)));
			}
			if (source3.Any((Skill_damage_cut s) => s.IsDamageClipping))
			{
				List<int> list2 = (from s in source3
					where s.ClippingMax != int.MaxValue
					select s.ClippingMax).ToList();
				list2.AddRange(from s in source3
					where s.LifeLowerLimit != -1
					select s.SkillPrm.ownerCard.Life - 1);
				list.Add(new NetworkBattleReceiver.ReplayBuffInfoLabel(NetworkBattleReceiver.ReplayBuffInfoTextType.DamageClipping, list2.Min()));
			}
		}
		return list;
	}

	private float SetupMyRotationBonusContent(BattleCardBase targetCard, List<BattlePlayerBase.MyRotationBonusCondition> myRotationBonusList)
	{
		ItemCursor itemCursor = new ItemCursor(0f);
		if (myRotationBonusList != null)
		{
			for (int i = 0; i < myRotationBonusList.Count; i++)
			{
				MakeMyRotationBonusItem(targetCard, myRotationBonusList[i], i > 0, ref itemCursor);
			}
		}
		return itemCursor.Height;
	}

	private float SetupAvatarBattleBonusContent(BattleCardBase targetCard, AvatarBattleInfo avatarBattleInfo)
	{
		ItemCursor itemCursor = new ItemCursor(0f);
		if (avatarBattleInfo == null)
		{
			return itemCursor.Height;
		}
		MakeAvatarBattleBonusTitleLogItem(Data.SystemText.Get("Battle_0522"), isBuffTitle: false, ref itemCursor);
		AvatarBattleInfo.AvatarBattleBonus bonus = avatarBattleInfo.Bonus;
		string allAbilityDesc = bonus.PassiveAbilityDesc + string.Join("", bonus.AbilityDesc);
		MakeAvatarBattlePassiveBonusLogItem(targetCard, allAbilityDesc, ref itemCursor);
		for (int i = 0; i < targetCard.SelfBattlePlayer.ChoiceBraveSkillDescInfoList.Count(); i++)
		{
			bool isNeedSeparator = _battleMgr.BattlePlayer.BattleView.IsShowCantChoiceBraveText || bonus.PassiveAbilityDesc != string.Empty || i != 0;
			MakeAvatarBattleBonusLogItem(targetCard.SelfBattlePlayer.ChoiceBraveSkillDescInfoList[i], allAbilityDesc, isNeedSeparator, targetCard, ref itemCursor);
		}
		if (CurrentShowRequest == ShowRequest.CHOICE_BRAVE_AND_BUFF)
		{
			string buffTitleText = Data.SystemText.Get("Battle_0495");
			ItemCursor itemCursor2 = itemCursor.Clone();
			MakeAvatarBattleBonusTitleLogItem(buffTitleText, isBuffTitle: true, ref itemCursor);
			float height = itemCursor.Height;
			SetupBuffContent(targetCard, _avatarBattleBonusContentsParent, ref itemCursor);
			if (itemCursor.Height - height <= 0f)
			{
				_cacheAvatarBattleTitleList.FirstOrDefault((AvatarBattleTitleItem cache) => cache.TitleText == buffTitleText).gameObject.SetActive(value: false);
				itemCursor = itemCursor2;
			}
		}
		return itemCursor.Height;
	}

	private float MakeAvatarBattleBonusTitleLogItem(string titleText, bool isBuffTitle, ref ItemCursor itemCursor)
	{
		AvatarBattleTitleItem avatarBattleTitleItem = _cacheAvatarBattleTitleList.FirstOrDefault((AvatarBattleTitleItem cache) => cache.TitleText == titleText);
		if (avatarBattleTitleItem == null)
		{
			avatarBattleTitleItem = ((!isBuffTitle) ? BattleLogManager.CreateAvatarBattleBonusTitleItem(titleText, _avatarBattleBonusScrollView) : BattleLogManager.CreateAvatarBattleBuffTitleItem(titleText, _avatarBattleBonusScrollView));
			_cacheAvatarBattleTitleList.Add(avatarBattleTitleItem);
		}
		avatarBattleTitleItem.transform.SetParent(_avatarBattleBonusContentsParent);
		avatarBattleTitleItem.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetCenterOffset(avatarBattleTitleItem.Height);
		avatarBattleTitleItem.transform.localPosition = new Vector3(0f, y, 0f);
		avatarBattleTitleItem.gameObject.SetActive(value: true);
		_drawLogList.Add(avatarBattleTitleItem.gameObject);
		return itemCursor.Height;
	}

	private float MakeAvatarBattleBonusLogItem(BattlePlayerBase.AvatarBattleDescInfo skillDescInfo, string allAbilityDesc, bool isNeedSeparator, BattleCardBase targetCard, ref ItemCursor itemCursor)
	{
		AvatarBattleBonusItem avatarBattleBonusItem = _cacheAvatarBattleBonusList.FirstOrDefault((AvatarBattleBonusItem cache) => cache.SkillDescInfo == skillDescInfo);
		if (avatarBattleBonusItem == null)
		{
			avatarBattleBonusItem = BattleLogManager.CreateAvatarBattleBonusItem(skillDescInfo, _avatarBattleBonusScrollView, isNeedSeparator, targetCard);
			if (BattleKeywordInfoListMgr.GetKeywords(allAbilityDesc).Any((string word) => Data.Master.BattleKeyWordDic.ContainsKey(word)))
			{
				UIEventListener.Get(avatarBattleBonusItem.DescLabel.gameObject).onClick = delegate(GameObject obj)
				{
					battleButtonControl.OnPressKeyBtn(allAbilityDesc, obj);
				};
				BattlePlayerView.SetKeyWordColor(avatarBattleBonusItem.DescLabel.gameObject, avatarBattleBonusItem.DescLabel);
			}
			_cacheAvatarBattleBonusList.Add(avatarBattleBonusItem);
		}
		else
		{
			avatarBattleBonusItem.SetText(targetCard, isNeedSeparator);
		}
		avatarBattleBonusItem.transform.SetParent(_avatarBattleBonusContentsParent);
		avatarBattleBonusItem.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetCenterOffset(avatarBattleBonusItem.Height);
		avatarBattleBonusItem.transform.localPosition = new Vector3(0f, y, 0f);
		avatarBattleBonusItem.gameObject.SetActive(value: true);
		_drawLogList.Add(avatarBattleBonusItem.gameObject);
		return itemCursor.Height;
	}

	private float MakeAvatarBattlePassiveBonusLogItem(BattleCardBase targetCard, string allAbilityDesc, ref ItemCursor itemCursor)
	{
		BattlePlayerBase.AvatarBattleDescInfo passiveSkillDescInfo = targetCard.SelfBattlePlayer.AvatarBattlePassiveSkillDescInfo;
		if (!_battleMgr.BattlePlayer.BattleView.IsShowCantChoiceBraveText && (passiveSkillDescInfo == null || passiveSkillDescInfo.DescText == string.Empty))
		{
			return itemCursor.Height;
		}
		AvatarBattlePassiveBonusItem avatarBattlePassiveBonusItem = _cacheAvatarBattlePassiveBonusList.FirstOrDefault((AvatarBattlePassiveBonusItem cache) => cache.SkillDescInfo == passiveSkillDescInfo);
		if (avatarBattlePassiveBonusItem == null)
		{
			avatarBattlePassiveBonusItem = BattleLogManager.CreateAvatarBattlePassiveBonusItem(passiveSkillDescInfo, targetCard, _avatarBattleBonusScrollView);
			if (BattleKeywordInfoListMgr.GetKeywords(allAbilityDesc).Any((string word) => Data.Master.BattleKeyWordDic.ContainsKey(word)))
			{
				UIEventListener.Get(avatarBattlePassiveBonusItem.DescLabel.gameObject).onClick = delegate(GameObject obj)
				{
					battleButtonControl.OnPressKeyBtn(allAbilityDesc, obj);
				};
				BattlePlayerView.SetKeyWordColor(avatarBattlePassiveBonusItem.DescLabel.gameObject, avatarBattlePassiveBonusItem.DescLabel);
			}
			_cacheAvatarBattlePassiveBonusList.Add(avatarBattlePassiveBonusItem);
		}
		else
		{
			avatarBattlePassiveBonusItem.SetText(targetCard);
		}
		avatarBattlePassiveBonusItem.transform.SetParent(_avatarBattleBonusContentsParent);
		avatarBattlePassiveBonusItem.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetCenterOffset(avatarBattlePassiveBonusItem.DescLabel.height);
		avatarBattlePassiveBonusItem.transform.localPosition = new Vector3(0f, y, 0f);
		avatarBattlePassiveBonusItem.gameObject.SetActive(value: true);
		_drawLogList.Add(avatarBattlePassiveBonusItem.gameObject);
		return itemCursor.Height;
	}

	private float SetupBossRushSpecialSkillContent(BattleCardBase targetCard, List<BossRushSpecialSkill> bossRushSpecialSkillList)
	{
		ItemCursor itemCursor = new ItemCursor(0f);
		for (int i = 0; i < bossRushSpecialSkillList.Count(); i++)
		{
			if (targetCard.SelfBattlePlayer.IsPlayer)
			{
				MakePlayerBossRushSpecialSkillLogItem(targetCard, bossRushSpecialSkillList.ElementAt(i), ref itemCursor);
			}
			else
			{
				MakeEnemyBossRushSpecialSkillLogItem(targetCard, bossRushSpecialSkillList.ElementAt(i), ref itemCursor);
			}
		}
		return itemCursor.Height;
	}

	private void MakePlayerBossRushSpecialSkillLogItem(BattleCardBase classCard, BossRushSpecialSkill bossRushSpecialSkill, ref ItemCursor itemCursor)
	{
		BattleLogItem battleLogItem = _cachePlayerBossRushSkillList.FirstOrDefault((BattleLogItem cache) => cache.BossRushSpecialSkill != null && cache.BossRushSpecialSkill.OriginalCardId == bossRushSpecialSkill.OriginalCardId);
		if (battleLogItem == null)
		{
			if (_cacheLogList.Count + _cachePlayerBossRushSkillList.Count > 50)
			{
				for (int num = _cachePlayerBossRushSkillList.Count - 1; num >= 0; num--)
				{
					BattleLogItem battleLogItem2 = _cachePlayerBossRushSkillList[num];
					if (!battleLogItem2.gameObject.activeSelf)
					{
						UnityEngine.Object.Destroy(battleLogItem2.gameObject);
						_cacheLogList.RemoveAt(num);
					}
				}
			}
			BuffInfo buffInfo = classCard.BuffInfoList.FirstOrDefault((BuffInfo b) => b.SpecialSkillInfo.OriginalCardId == bossRushSpecialSkill.OriginalCardId);
			if (buffInfo != null)
			{
				battleLogItem = BattleLogManager.CreateBossRushPlayerSpecialSkillLogItem(buffInfo.SkillFrom.SkillPrm.ownerCard, bossRushSpecialSkill);
			}
			_cachePlayerBossRushSkillList.Add(battleLogItem);
		}
		battleLogItem.transform.SetParent(_bossRushSpecialSkillContentsParent);
		battleLogItem.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetCenterOffset(47f);
		battleLogItem.transform.localPosition = new Vector3(0f, y, 0f);
		battleLogItem.gameObject.SetActive(value: true);
		_drawLogList.Add(battleLogItem.gameObject);
		battleLogItem.SetSelectSpriteActive(setActive: false);
	}

	private void MakeEnemyBossRushSpecialSkillLogItem(BattleCardBase classCard, BossRushSpecialSkill bossRushSpecialSkill, ref ItemCursor itemCursor)
	{
		BossRushEnemySpecialSkillItem bossRushEnemySpecialSkillItem = _cacheEnemyBossRushSkillList.FirstOrDefault((BossRushEnemySpecialSkillItem cache) => cache.BossRushSpecialSkill != null && cache.BossRushSpecialSkill.OriginalCardId == bossRushSpecialSkill.OriginalCardId);
		if (bossRushEnemySpecialSkillItem == null)
		{
			BuffInfo buffInfo = classCard.BuffInfoList.FirstOrDefault((BuffInfo b) => b.SpecialSkillInfo.OriginalCardId == bossRushSpecialSkill.OriginalCardId);
			if (buffInfo != null)
			{
				bossRushEnemySpecialSkillItem = BattleLogManager.CreateEnemyBossRushSpecialSkillLogItem(buffInfo.SkillFrom.SkillPrm.ownerCard, bossRushSpecialSkill);
				if (BattleKeywordInfoListMgr.GetKeywords(bossRushSpecialSkill.SkillDescText).Any((string word) => Data.Master.BattleKeyWordDic.ContainsKey(word)))
				{
					UIEventListener.Get(bossRushEnemySpecialSkillItem.DescLabel.gameObject).onClick = delegate(GameObject obj)
					{
						battleButtonControl.OnPressKeyBtn(bossRushSpecialSkill.SkillDescText, obj);
					};
					BattlePlayerView.SetKeyWordColor(bossRushEnemySpecialSkillItem.DescLabel.gameObject, bossRushEnemySpecialSkillItem.DescLabel);
				}
			}
			_cacheEnemyBossRushSkillList.Add(bossRushEnemySpecialSkillItem);
		}
		bossRushEnemySpecialSkillItem.transform.SetParent(_bossRushSpecialSkillContentsParent);
		bossRushEnemySpecialSkillItem.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetCenterOffset(bossRushEnemySpecialSkillItem.DescLabel.height);
		bossRushEnemySpecialSkillItem.transform.localPosition = new Vector3(0f, y, 0f);
		bossRushEnemySpecialSkillItem.gameObject.SetActive(value: true);
		_drawLogList.Add(bossRushEnemySpecialSkillItem.gameObject);
	}

	public static bool IsNeedNoConsumeEp(BattleCardBase targetCard)
	{
		if (targetCard.SelfBattlePlayer.CheckNotConsumeEpCard(targetCard))
		{
			return targetCard.SelfBattlePlayer.InPlayCards.Any((BattleCardBase c) => c.SkillApplyInformation.NotConsumeEpModifierInfoList.Any((NotConsumeEpModifierInfo b) => b.TargetCard == null && b.CheckNotConsumedCard(targetCard)));
		}
		return false;
	}

	private void MakeHeadlineLabel(ref GameObject labelObject, string labelText, Transform contentsParent, ref ItemCursor itemCursor)
	{
		if (labelObject == null)
		{
			labelObject = UnityEngine.Object.Instantiate(Resources.Load("Prefab/UI/Log/AdvancedSkillLabel")) as GameObject;
			labelObject.GetComponentInChildren<UILabel>().text = labelText;
		}
		labelObject.SetActive(value: true);
		labelObject.transform.SetParent(contentsParent);
		labelObject.transform.localScale = Vector3.one;
		float y = itemCursor.AddAndGetTopOffset(44f);
		labelObject.transform.localPosition = new Vector3(0f, y, 0f);
		_drawLogList.Add(labelObject);
	}

	private void MakeLogItems(List<BuffInfo> buffList, Transform contentsParent, ref ItemCursor itemCursor)
	{
		for (int i = 0; i < buffList.Count; i++)
		{
			MakeCardLogItem(buffList[i], contentsParent, ref itemCursor);
		}
	}

	private float SetupMyRotationBonusPanel(BattleCardBase targetCard, List<BattlePlayerBase.MyRotationBonusCondition> myRotationBonusList, bool hasLowerContents)
	{
		float num = SetupMyRotationBonusContent(targetCard, myRotationBonusList);
		bool flag = num > 0f;
		_myRotationBonusContentsPanel.gameObject.SetActive(flag);
		_myRotationBonusBorderLine.gameObject.SetActive(hasLowerContents);
		if (!flag)
		{
			return num;
		}
		_myRotationBonusTitleLabel.text = Data.SystemText.Get("Battle_0518");
		num -= _myRotationBonusContentsParent.localPosition.y;
		if (hasLowerContents)
		{
			_myRotationBonusBorderLine.transform.localPosition = new Vector3(0f, 0f - num - 6f);
			num += (float)_myRotationBonusBorderLine.height + 6f;
		}
		return num;
	}

	private float SetupAvatarBattleBonusPanel(BattleCardBase targetCard, AvatarBattleInfo avatarBattleInfo, bool isShowAvatarBattleBonus)
	{
		float num = SetupAvatarBattleBonusContent(targetCard, avatarBattleInfo);
		bool num2 = num > 0f;
		_avatarBattleBonusContentsPanel.gameObject.SetActive(isShowAvatarBattleBonus);
		if (!num2 || !isShowAvatarBattleBonus)
		{
			return 0f;
		}
		_avatarBattleBonusBPDescriptionLabel.text = Data.SystemText.Get("Battle_0523");
		Vector3 localPosition = _avatarBattleBonusBPDescriptionLabel.transform.localPosition;
		Vector3 localPosition2 = _avatarBattleBonusBPSprite.transform.localPosition;
		_avatarBattleBonusBPDescriptionLabel.transform.localPosition = new Vector3((float)_avatarBattleBonusBPDescriptionLabel.width / 2f, localPosition.y, localPosition.z);
		_avatarBattleBonusBPSprite.transform.localPosition = new Vector3((float)_avatarBattleBonusBPDescriptionLabel.width + (float)_avatarBattleBonusBPSprite.width / 2f, localPosition2.y, localPosition2.z);
		_avatarBattleBonusBPLabel.text = targetCard.SelfBattlePlayer.Bp.ToString();
		return num;
	}

	private float SetupBossRushSkillPanel(BattleCardBase targetCard, List<BossRushSpecialSkill> bossRushSpecialSkillList, float upperContentsHeight, bool hasLowerContents)
	{
		float num = SetupBossRushSpecialSkillContent(targetCard, bossRushSpecialSkillList);
		bool flag = num > 0f;
		_bossRushSpecialSkillContentsPanel.gameObject.SetActive(flag);
		if (!flag)
		{
			return num;
		}
		_bossRushSpecialSkillTitleLabel.text = Data.SystemText.Get(_card.SelfBattlePlayer.IsPlayer ? "BossRush_0029" : "BossRush_0028");
		num -= _bossRushSpecialSkillContentsParent.localPosition.y;
		_bossRushSpecialSkillContentsPanel.transform.localPosition = new Vector3(0f, 0f - upperContentsHeight);
		if (hasLowerContents)
		{
			num += 6f;
		}
		return num;
	}

	private float SetupBuffSkillPanel(BattleCardBase targetCard, float upperContentsHeight, bool isShowAvatarBattleBonus)
	{
		if (isShowAvatarBattleBonus)
		{
			_buffPanel.gameObject.SetActive(value: false);
			return 0f;
		}
		ItemCursor itemCursor = new ItemCursor(0f);
		float num = SetupBuffContent(targetCard, _buffContentsParent, ref itemCursor);
		bool active = num > 0f;
		_buffPanel.gameObject.SetActive(active);
		if (num <= 0f)
		{
			return num;
		}
		_buffTitleLabel.text = Data.SystemText.Get(_card.IsClass ? "Battle_0495" : "Battle_0443");
		num -= _buffContentsParent.transform.localPosition.y;
		_buffPanel.transform.localPosition = new Vector3(0f, -(int)upperContentsHeight);
		_buffPanel.topAnchor.absolute = -(int)upperContentsHeight;
		return num;
	}

	private void SetupAllBuffPanel(BattleCardBase targetCard, float heightOffset, List<BattlePlayerBase.MyRotationBonusCondition> myRotationBonusList, List<BossRushSpecialSkill> bossRushSkillList, AvatarBattleInfo avatarBattleInfo, bool isUpdate, bool isShowAvatarBattleBonus = false)
	{
		for (int i = 0; i < _drawLogList.Count; i++)
		{
			_drawLogList[i].SetActive(value: false);
		}
		_drawLogList.Clear();
		bool flag = bossRushSkillList.Count > 0;
		bool flag2 = NeedBuffSkillPanel(targetCard);
		float num = 0f;
		num += SetupMyRotationBonusPanel(targetCard, myRotationBonusList, flag || flag2);
		num += SetupBossRushSkillPanel(targetCard, bossRushSkillList, num, flag2);
		num += SetupAvatarBattleBonusPanel(targetCard, avatarBattleInfo, isShowAvatarBattleBonus);
		num += SetupBuffSkillPanel(targetCard, num, isShowAvatarBattleBonus);
		num += 8f;
		_buffPanelSprite.gameObject.SetActive(flag2 || myRotationBonusList.Count > 0 || bossRushSkillList.Count > 0 || isShowAvatarBattleBonus);
		float num2 = 598f + heightOffset;
		num2 = ((!_card.IsUnit) ? (num2 - _nonFollowerPanel._bg.localSize.y) : (num2 - (_followerEvoPanel._bg.localSize.y + _followerPanel._bg.localSize.y)));
		bool active = num2 < num;
		UIScrollView component = _buffContentsPanel.GetComponent<UIScrollView>();
		component.InvalidateBounds();
		component.ResetPosition();
		component.enabled = active;
		_buffScrollBar.gameObject.SetActive(active);
		float num3 = Mathf.Min(num, num2);
		_buffPanelSprite.height = (int)num3;
		_buffPanelCollider.center = new Vector3(_buffPanelCollider.center.x, (0f - num3) / 2f);
		_buffPanelCollider.size = new Vector3(_buffPanelCollider.size.x, num3);
		_buffScrollView.UpdateScrollbars();
		_buffScrollView.RestrictWithinBounds(instant: true);
		_buffScrollView.ResetPosition();
		if (isShowAvatarBattleBonus)
		{
			_bgDragScrollView.scrollView = _avatarBattleBonusScrollView;
		}
		else
		{
			_bgDragScrollView.scrollView = _buffScrollView;
		}
		_avatarBattleBonusScrollView.InvalidateBounds();
		_avatarBattleBonusScrollView.enabled = active;
		_avatarBattleBonusScrollBar.gameObject.SetActive(active);
		_avatarBattleBonusScrollView.UpdateScrollbars();
		if (!isUpdate)
		{
			_avatarBattleBonusScrollView.RestrictWithinBounds(instant: true);
			_avatarBattleBonusScrollView.ResetPosition();
		}
	}

	private bool NeedBuffSkillPanel(BattleCardBase card)
	{
		if (GameMgr.GetIns().IsNewReplayBattle)
		{
			if (card.ReplayNoConsumeEpBuffInfoNameList.Count <= 0 && card.ReplayBuffInfoList.Count() <= 0)
			{
				return card.ReplayBuffInfoLabelList.Count > 0;
			}
			return true;
		}
		bool num = IsNeedNoConsumeEp(card) && card.SelfBattlePlayer.InPlayCards.Where((BattleCardBase c) => c.SkillApplyInformation.NotConsumeEpModifierInfoList.Any((NotConsumeEpModifierInfo b) => b.TargetCard == null && b.CheckNotConsumedCard(card))).Count() > 0;
		bool flag = (from b in GetDistinctBuffList(card.BuffInfoList)
			where b.SpecialSkillInfo == null && !BuffDetailInfoUI.IsNotShowDamageCutLifeLowerLimitBuffDetail(b.SkillFrom)
			select b).Count() > 0;
		bool flag2 = BuffDetailInfoUI.NeedBuffDetailText(card);
		return num || flag || flag2;
	}

	private IEnumerator RepositionBuffContent()
	{
		yield return null;
		_buffScrollView.ResetPosition();
		_buffScrollView.UpdateScrollbars();
	}

	private string GetBuffFromName(int baseCardID)
	{
		if (baseCardID == 0)
		{
			return Data.SystemText.Get("BattleLog_0097");
		}
		return CardMaster.GetInstanceForBattle().GetCardParameterFromId(baseCardID).CardName;
	}

	private void AddCardEvent(BattleCardBase card)
	{
		if (card != null)
		{
			card.OnDestroy += OnDestroyCard;
			card.OnBanish += OnDestroyCard;
			card.OnReturnCard += OnDestroyCard;
			card.OnMetamorphose += OnDestroyCard;
			card.OnGetOn += OnDestroyCard;
			if (card.IsClass)
			{
				((ClassBattleCardBase)card).OnRetire += OnDestroyCard;
			}
		}
	}

	private void RemoveCardEvent(BattleCardBase card)
	{
		if (card != null)
		{
			card.OnDestroy -= OnDestroyCard;
			card.OnBanish -= OnDestroyCard;
			card.OnReturnCard -= OnDestroyCard;
			card.OnMetamorphose -= OnDestroyCard;
			card.OnGetOn -= OnDestroyCard;
			if (card.IsClass)
			{
				((ClassBattleCardBase)card).OnRetire -= OnDestroyCard;
			}
		}
	}

	private VfxBase OnDestroyCard(BattleCardBase card, SkillProcessor skill)
	{
		if (_card == card)
		{
			return InstantVfx.Create(Hide);
		}
		return NullVfx.GetInstance();
	}

	public void ShowKeySubPanel(int page)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
	}

	public void HideKeySubPanel()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
	}

	public void SetKeyBtnActive(List<bool> hasKeyword)
	{
		if (hasKeyword.Count != 0)
		{
			_hasKeyword = hasKeyword[0];
			if (hasKeyword.Count > 1 && (bool)_nextPanel)
			{
				List<bool> keyBtnActive = new List<bool>(hasKeyword.GetRange(1, hasKeyword.Count - 1));
				_nextPanel.SetKeyBtnActive(keyBtnActive);
			}
		}
	}

	public static void LoadCardHeaderTexture(int cardId, bool isUnit, UITexture headerUITexture, bool isEvolution = false, bool isBattleLogHeader = false, Action<Texture> cbOnLoaded = null, List<NewReplayBattleMgr.BattleLogTextureInfo> battleLogTextureInfo = null)
	{
		CardMaster instanceForBattle = CardMaster.GetInstanceForBattle();
		CardParameter cardParameterFromId = instanceForBattle.GetCardParameterFromId(cardId);
		ResourcesManager resMgr = Toolbox.ResourcesManager;
		string text = cardParameterFromId.ResourceCardId.ToString();
		ResourcesManager.AssetLoadPathType assetLoadPathType = ResourcesManager.AssetLoadPathType.UnitHeader;
		ResourcesManager.AssetLoadPathType assetLoadPathType2 = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
		if (text.Length > 9)
		{
			assetLoadPathType = ResourcesManager.AssetLoadPathType.UnitHeader;
			assetLoadPathType2 = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
		}
		else if (isUnit || ((CardMaster.IsMutationCardCheck(instanceForBattle.GetCardParameterFromId(cardId).BaseCardId) || CardMaster.IsChoiceBraveCardCheck(cardId)) && instanceForBattle.GetCardParameterFromId(cardParameterFromId.ResourceCardId).CharType == CardBasePrm.CharaType.NORMAL))
		{
			assetLoadPathType = ResourcesManager.AssetLoadPathType.UnitHeader;
			text = (isEvolution ? (text + "1") : (text + "0"));
			assetLoadPathType2 = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
		}
		else
		{
			assetLoadPathType = ResourcesManager.AssetLoadPathType.OtherHeader;
			text += "0";
			assetLoadPathType2 = ResourcesManager.AssetLoadPathType.SpellCardMaterial;
		}
		string cardAssetPath = resMgr.GetAssetTypePath(cardParameterFromId.ResourceCardId.ToString(), assetLoadPathType2);
		string logHeaderAssetPath = resMgr.GetAssetTypePath(text, assetLoadPathType, isfetch: true);
		if (resMgr.IsLoadedAssetBundleAndObjectArrayExist(cardAssetPath))
		{
			Texture texture = resMgr.LoadObject<Texture>(logHeaderAssetPath);
			headerUITexture.mainTexture = texture;
			cbOnLoaded.Call(texture);
			return;
		}
		if (!isBattleLogHeader && loadHeaderCoroutine.ContainsKey(cardAssetPath))
		{
			Coroutine coroutine = loadHeaderCoroutine[cardAssetPath]._coroutine;
			BattleCoroutine.GetInstance().StopCoroutine(coroutine);
			loadHeaderCoroutine.Remove(cardAssetPath);
		}
		Action action = delegate
		{
			Texture texture2 = resMgr.LoadObject<Texture>(logHeaderAssetPath);
			headerUITexture.mainTexture = texture2;
			cbOnLoaded.Call(texture2);
		};
		if (loadHeaderCoroutine.ContainsKey(cardAssetPath))
		{
			loadHeaderCoroutine[cardAssetPath]._actions.Add(action);
			return;
		}
		if (battleLogTextureInfo != null)
		{
			battleLogTextureInfo.Add(new NewReplayBattleMgr.BattleLogTextureInfo(cardAssetPath, logHeaderAssetPath, headerUITexture, cbOnLoaded));
			return;
		}
		CoroutineActions coroutineActions = new CoroutineActions(action);
		coroutineActions._coroutine = BattleCoroutine.GetInstance().StartCoroutine(resMgr.LoadAssetAsync(cardAssetPath, delegate
		{
			foreach (Action action2 in coroutineActions._actions)
			{
				action2();
			}
			loadHeaderCoroutine.Remove(cardAssetPath);
		}));
		Toolbox.ResourcesManager.BattleListAssetPathList.Add(cardAssetPath);
		loadHeaderCoroutine.Add(cardAssetPath, coroutineActions);
	}

	public static void LoadClassHeaderTexture(int cardId, UITexture headerUITexture, Action<Texture> cbOnLoaded = null, bool isEvolve = false)
	{
		ResourcesManager resMgr = Toolbox.ResourcesManager;
		ResourcesManager.AssetLoadPathType resourceType = ResourcesManager.AssetLoadPathType.UnitHeader;
		resourceType = ResourcesManager.AssetLoadPathType.ClassCharaHeader;
		int skin_id = GameMgr.GetIns().GetDataMgr().GetCharaPrmByCharaId(cardId)
			.skin_id;
		string cardNameBgPath = ((skin_id < 10) ? ("log_class_0" + skin_id) : ("log_class_" + skin_id));
		if (isEvolve)
		{
			cardNameBgPath += "_evolve";
		}
		string cardAssetName = resMgr.GetAssetTypePath(cardNameBgPath, resourceType);
		BattleCoroutine.GetInstance().StartCoroutine(resMgr.LoadAssetAsync(cardAssetName, delegate
		{
			Texture texture = resMgr.LoadObject<Texture>(resMgr.GetAssetTypePath(cardNameBgPath, resourceType, isfetch: true));
			headerUITexture.mainTexture = texture;
			cbOnLoaded.Call(texture);
			Toolbox.ResourcesManager.BattleListAssetPathList.Add(cardAssetName);
		}));
	}

	public void SetScreenPosition(bool right)
	{
		UIAnchor component = base.transform.Find("AnchorL").GetComponent<UIAnchor>();
		if ((bool)component)
		{
			if (right)
			{
				float num = -0.3633333f;
				float num2 = -0.222f - num * 0.4f;
				component.relativeOffset.x = num * base.transform.localScale.x + num2;
			}
			else
			{
				component.relativeOffset.x = 0f;
			}
			component.side = (right ? UIAnchor.Side.TopRight : UIAnchor.Side.TopLeft);
			component.enabled = true;
		}
	}

	private void SetParent(DetailPanelControl parent)
	{
		_parentPanel = parent;
		GameObject obj = base.transform.Find("AnchorL").gameObject;
		UIAnchor component = obj.GetComponent<UIAnchor>();
		if ((bool)component)
		{
			UnityEngine.Object.Destroy(component);
		}
		UIWidget uIWidget = obj.AddMissingComponent<UIWidget>();
		uIWidget.height = 1;
		uIWidget.width = 1;
		UIWidget lastBottomWidget = _parentPanel.GetLastBottomWidget();
		uIWidget.topAnchor.target = lastBottomWidget.transform;
		uIWidget.topAnchor.absolute = 1;
	}

	private UIWidget GetLastBottomWidget()
	{
		if (_buffPanelSprite.gameObject.activeInHierarchy)
		{
			return _buffPanelSprite;
		}
		if (_nonFollowerPanel._bg.gameObject.activeInHierarchy)
		{
			return _nonFollowerPanel._bg;
		}
		if (_followerEvoPanel._bg.gameObject.activeInHierarchy)
		{
			return _followerEvoPanel._bg;
		}
		return _followerPanel._bg;
	}

	private void UpdateParentAnchor()
	{
		if ((bool)_parentPanel)
		{
			GameObject gameObject = base.transform.Find("AnchorL").gameObject;
			UIWidget uIWidget = gameObject.AddMissingComponent<UIWidget>();
			UIWidget lastBottomWidget = _parentPanel.GetLastBottomWidget();
			if (lastBottomWidget != uIWidget.topAnchor.target)
			{
				uIWidget.height = 1;
				uIWidget.width = 1;
				uIWidget.topAnchor.target = lastBottomWidget.transform;
				uIWidget.ResetAndUpdateAnchors();
				uIWidget.topAnchor.absolute = 0;
				uIWidget.topAnchor.relative = 0f;
				Vector3 localPosition = gameObject.transform.localPosition;
				localPosition.x = _parentPanel.transform.Find("AnchorL").localPosition.x;
				gameObject.transform.localPosition = localPosition;
			}
		}
	}

	public void SetSize(float percent)
	{
		float num = percent / 100f;
		base.transform.localScale = new Vector3(num, num, num);
		UIAnchor component = base.transform.Find("AnchorL").GetComponent<UIAnchor>();
		if ((bool)component)
		{
			float num2;
			float num3;
			if (component.side == UIAnchor.Side.TopRight)
			{
				num2 = -0.3633333f;
				num3 = -0.222f - num2 * 0.4f;
				component.relativeOffset.x = num2 * base.transform.localScale.x + num3;
			}
			component.relativeOffset.y = 0f;
			num2 = 106.666664f;
			num3 = -30f - num2 * 0.4f;
			component.pixelOffset.y = num2 * num + num3;
			component.enabled = true;
		}
		if ((bool)_nextPanel)
		{
			_nextPanel.SetSize(percent);
		}
	}
}
