using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using com.workman.cm3d2.scene.dailyEtc;
using I2.Loc;
using MaidStatus;
using PlayerStatus;
using Schedule;
using UnityEngine;
using wf;

public class CharacterSelectMain : WfScreenChildren
{
	public static bool compatibilityMode
	{
		get
		{
			return DailyMgr.IsLegacy;
		}
	}

	public override void Awake()
	{
		base.Awake();
		this.explanatory_label_ = UTY.GetChildObject(base.root_obj, "ExplanatoryText/Value", false).GetComponent<UILabel>();
		GameObject childObject = UTY.GetChildObject(base.root_obj, "ButtonParent/Tower/Grid", false);
		this.button_dic_.Add("全選択", UTY.GetChildObject(childObject, "全選択", false).GetComponent<UIButton>());
		EventDelegate.Add(this.button_dic_["全選択"].onClick, new EventDelegate.Callback(this.OnSelectAllChara));
		this.button_dic_.Add("全解除", UTY.GetChildObject(childObject, "全解除", false).GetComponent<UIButton>());
		EventDelegate.Add(this.button_dic_["全解除"].onClick, new EventDelegate.Callback(this.OnSelectAllReleaseChara));
		this.button_dic_.Add("OK", UTY.GetChildObject(base.root_obj, "ButtonParent/OK", false).GetComponent<UIButton>());
		this.button_dic_.Add("Cancel", UTY.GetChildObject(base.root_obj, "ButtonParent/Cancel", false).GetComponent<UIButton>());
		this.button_dic_["Cancel"].gameObject.SetActive(false);
		foreach (KeyValuePair<string, UIButton> keyValuePair in this.button_dic_)
		{
			EventDelegate.Add(keyValuePair.Value.onClick, new EventDelegate.Callback(this.OnClickButton));
		}
		this.chara_select_mgr_ = UTY.GetChildObject(base.root_obj, "CharacterSelectPanel", false).GetComponent<CharacterSelectManager>();
		this.InitSelectedMaidPanelUI();
	}

	protected override void OnCall()
	{
		this.auto_select_ = false;
		this.wait_count_ = 0;
		this.loaded_check_maid_.Clear();
		this.select_maid_ = null;
		this.chara_mgr_ = GameMain.Instance.CharacterMgr;
		this.scene_chara_select_ = (base.parent_mgr as SceneCharacterSelect);
		NDebug.AssertNull(this.scene_chara_select_);
		this.button_dic_["全選択"].gameObject.SetActive(false);
		this.button_dic_["全解除"].gameObject.SetActive(false);
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Additional)
		{
			this.OnCallAdditionalType();
			return;
		}
		bool flag = this.scene_chara_select_.select_type != SceneCharacterSelect.SelectType.NewYotogiAdditional;
		flag &= (this.scene_chara_select_.select_type != SceneCharacterSelect.SelectType.LifeModeRecollection);
		if (flag)
		{
			for (int i = 0; i < this.chara_mgr_.GetMaidCount(); i++)
			{
				if (this.chara_mgr_.GetMaid(i) != null)
				{
					this.chara_mgr_.Deactivate(i, false);
				}
			}
		}
		else
		{
			for (int j = 0; j < this.chara_mgr_.GetMaidCount(); j++)
			{
				if (this.chara_mgr_.GetMaid(j) != null)
				{
					this.chara_mgr_.GetMaid(j).Visible = false;
				}
			}
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Communication)
		{
			NDebug.Assert("コミュキャラ選択は廃止されました", false);
			GameMain.Instance.BgMgr.ChangeBg("Syosai");
			GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(-2.526511f, 1.715126f, -2.023701f), 7.999995f, new Vector2(-128.2036f, -6.149067f));
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = ScheduleAPI.CanCommunicationMaids(true);
				for (int n = 0; n < list3.Count; n++)
				{
					draw_maid_list.Add(list3[n]);
				}
			});
			this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.auto_select_ = true;
			}
			if (!this.auto_select_)
			{
				GameMain.Instance.SoundMgr.PlayBGM("BGM015.ogg", 0.5f, true);
			}
			this.SetExplanatoryLabel("コミュニケーションを行うメイドを選択してください。");
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Yotogi || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.NewYotogi || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.NewYotogiAdditional || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Vip || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Facility)
		{
			if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Yotogi || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.NewYotogi || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.NewYotogiAdditional || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Vip)
			{
				if (!CharacterSelectMain.compatibilityMode)
				{
					GameMain.Instance.BgMgr.ChangeBg("Theater");
					GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(12.39468f, 5.495444f, 22.72065f), 0.1f, new Vector2(-6.047941f, 14.65832f));
				}
				else
				{
					GameMain.Instance.BgMgr.ChangeBg("Salon");
					GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(1.485176f, 0.5354422f, 1.606312f), 13.60001f, new Vector2(-208.1436f, -0.869565f));
				}
			}
			else
			{
				GameMain.Instance.BgMgr.ChangeBg("EmpireClub_Rotary");
				GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(6.673284f, 3.031431f, 20.00305f), 0.2f, new Vector2(562.5145f, -4.906824f));
			}
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<string> chara_guid_stock_list = SceneCharacterSelect.chara_guid_stock_list;
				for (int n = 0; n < chara_guid_stock_list.Count; n++)
				{
					Maid stockMaid2 = GameMain.Instance.CharacterMgr.GetStockMaid(chara_guid_stock_list[n]);
					if (stockMaid2 != null)
					{
						if (!CharacterSelectMain.compatibilityMode)
						{
							draw_maid_list.Add(stockMaid2);
						}
						else if (stockMaid2.status.isCompatiblePersonality)
						{
							draw_maid_list.Add(stockMaid2);
						}
					}
				}
			});
			this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			if (this.chara_select_mgr_.maid_list_count == 1 && this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Vip)
			{
				this.auto_select_ = true;
			}
			string explanatoryLabel = string.Empty;
			SceneCharacterSelect.SelectType select_type = this.scene_chara_select_.select_type;
			if (select_type != SceneCharacterSelect.SelectType.Yotogi)
			{
				if (select_type != SceneCharacterSelect.SelectType.Vip)
				{
					if (select_type != SceneCharacterSelect.SelectType.NewYotogi)
					{
						if (select_type != SceneCharacterSelect.SelectType.NewYotogiAdditional)
						{
							explanatoryLabel = "施設強化を行うメイドを選択してください。";
						}
						else
						{
							explanatoryLabel = "ハーレムのペアとなるメイドを選択してください。";
						}
					}
					else
					{
						explanatoryLabel = "GP01夜伽を行うメイドを選択してください。";
					}
				}
				else
				{
					explanatoryLabel = "Hイベントを行うメイドを選択してください。";
				}
			}
			else
			{
				explanatoryLabel = "夜伽を行うメイドを選択してください。";
			}
			this.SetExplanatoryLabel(explanatoryLabel);
			if (!this.auto_select_)
			{
				if (!CharacterSelectMain.compatibilityMode)
				{
					GameMain.Instance.SoundMgr.PlayBGM("BGM015.ogg", 0.5f, true);
				}
				else
				{
					GameMain.Instance.SoundMgr.PlayBGMLegacy("BGM014.ogg", 0.5f, true);
				}
			}
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.CompetitiveShow)
		{
			if (!CharacterSelectMain.compatibilityMode)
			{
				GameMain.Instance.BgMgr.ChangeBg("Theater");
				GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(6.502444f, 1.154878f, 27.09383f), 0.1f, new Vector2(200.2396f, -12.36027f));
			}
			else
			{
				GameMain.Instance.BgMgr.ChangeBg("Salon_Day");
				GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(1.485176f, 0.5354422f, 1.606312f), 13.60001f, new Vector2(-208.1436f, -0.869565f));
			}
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list3);
				for (int n = 0; n < list3.Count; n++)
				{
					if (!CharacterSelectMain.compatibilityMode && (list3[n].status.heroineType == HeroineType.Original || list3[n].status.heroineType == HeroineType.Transfer))
					{
						draw_maid_list.Add(list3[n]);
					}
					else if (CharacterSelectMain.compatibilityMode && list3[n].status.isCompatiblePersonality)
					{
						draw_maid_list.Add(list3[n]);
					}
				}
			});
			this.chara_select_mgr_.SetCallBackOnMultiSelect(new CharacterSelectManager.CallBackOnMultiSelect(this.OnMultiSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Multiple, this.chara_mgr_.GetStockMaidCount(), false);
			this.button_dic_["OK"].isEnabled = false;
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				Maid[] array = new Maid[1];
				List<Maid> list = new List<Maid>();
				List<Maid> list2 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list2);
				for (int k = 0; k < list2.Count; k++)
				{
					if (!CharacterSelectMain.compatibilityMode && list2[k].status.heroineType == HeroineType.Original)
					{
						list.Add(list2[k]);
					}
					else if (CharacterSelectMain.compatibilityMode && list2[k].status.isCompatiblePersonality)
					{
						list.Add(list2[k]);
					}
				}
				if (0 < list.Count)
				{
					array[0] = list[0];
				}
				if (array[0] != null)
				{
					this.OnMultiSelectChara(array);
					this.auto_select_ = true;
				}
			}
			if (!this.auto_select_)
			{
				if (!CharacterSelectMain.compatibilityMode)
				{
					GameMain.Instance.SoundMgr.PlayBGM("BGM006.ogg", 0.5f, true);
				}
				else
				{
					GameMain.Instance.SoundMgr.PlayBGMLegacy("BGM021.ogg", 0.5f, true);
				}
			}
			this.button_dic_["全選択"].gameObject.SetActive(true);
			this.button_dic_["全解除"].gameObject.SetActive(true);
			this.button_dic_["全選択"].isEnabled = true;
			this.button_dic_["全解除"].isEnabled = false;
			this.SetExplanatoryLabel("品評会を行うメイドを選択してください。");
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Free)
		{
			if (!CharacterSelectMain.compatibilityMode)
			{
				GameMain.Instance.BgMgr.ChangeBg("Theater");
				GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(12.39468f, 5.495444f, 22.72065f), 0.1f, new Vector2(-6.047941f, 14.65832f));
			}
			else
			{
				GameMain.Instance.BgMgr.ChangeBg("Syosai");
			}
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list3);
				for (int n = 0; n < list3.Count; n++)
				{
					if (!CharacterSelectMain.compatibilityMode)
					{
						draw_maid_list.Add(list3[n]);
					}
					else if (list3[n].status.isCompatiblePersonality)
					{
						draw_maid_list.Add(list3[n]);
					}
				}
			});
			this.SetExplanatoryLabel("メイドを選択してください。");
			this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.auto_select_ = true;
			}
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.TouchCharaSelect)
		{
			if (GameMain.Instance.CharacterMgr.status.isDaytime)
			{
				GameMain.Instance.BgMgr.ChangeBg(DailyAPI.dayBg);
			}
			else
			{
				GameMain.Instance.BgMgr.ChangeBg(DailyAPI.nightBg);
			}
			GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(1.32781f, 1.400725f, -0.06648348f), 0.1f, new Vector2(214.6109f, 8.136656f));
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list3);
				for (int n = 0; n < list3.Count; n++)
				{
					if (!CharacterSelectMain.compatibilityMode)
					{
						draw_maid_list.Add(list3[n]);
					}
					else if (list3[n].status.isCompatiblePersonality)
					{
						draw_maid_list.Add(list3[n]);
					}
				}
			});
			this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.auto_select_ = true;
			}
			if (!this.auto_select_)
			{
				GameMain.Instance.SoundMgr.PlayBGM("BGM015.ogg", 0.5f, true);
			}
			this.SetExplanatoryLabel("おさわりを行うメイドを選択してください。");
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.VRComSelect)
		{
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list3);
				for (int n = 0; n < list3.Count; n++)
				{
					if (!CharacterSelectMain.compatibilityMode)
					{
						draw_maid_list.Add(list3[n]);
					}
					else if (list3[n].status.isCompatiblePersonality)
					{
						draw_maid_list.Add(list3[n]);
					}
				}
			});
			this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.auto_select_ = true;
			}
			this.SetExplanatoryLabel("バカンスに連れていくメイドを選択してください。");
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.VRKaraokeSelect)
		{
			CharacterSelectManager characterSelectManager = this.chara_select_mgr_;
			if (CharacterSelectMain.<>f__mg$cache0 == null)
			{
				CharacterSelectMain.<>f__mg$cache0 = new CharacterSelectManager.CallBackMaidList(KaraokeDataManager.GetMaidListKaraoke);
			}
			characterSelectManager.SetCallBackMaidList(CharacterSelectMain.<>f__mg$cache0);
			this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.auto_select_ = true;
			}
			this.SetExplanatoryLabel("カラオケに連れていくメイドを選択してください。");
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Recollection)
		{
			if (!CharacterSelectMain.compatibilityMode)
			{
				GameMain.Instance.BgMgr.ChangeBg("ShinShitsumu_ChairRot");
				GameMain.Instance.MainCamera.SetFromScriptOnTarget(new Vector3(-0.4103856f, 1.075485f, 0.775088f), 1.6f, new Vector2(321.3178f, 3.478252f));
			}
			else
			{
				GameMain.Instance.BgMgr.ChangeBg("Syosai");
			}
			string text = "recollection_subheroine.nei";
			List<int> subMaidList = new List<int>();
			using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
			{
				using (CsvParser csvParser = new CsvParser())
				{
					bool condition = csvParser.Open(afileBase);
					NDebug.Assert(condition, text + "\nopen failed.");
					for (int l = 1; l < csvParser.max_cell_y; l++)
					{
						if (csvParser.IsCellToExistData(0, l))
						{
							int cellAsInteger = csvParser.GetCellAsInteger(0, l);
							int cellAsInteger2 = csvParser.GetCellAsInteger(2, l);
							subMaidList.Add(cellAsInteger2);
						}
					}
				}
			}
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list3);
				for (int n = 0; n < list3.Count; n++)
				{
					Maid maid2 = list3[n];
					if (maid2.status.subCharaData == null || subMaidList.Contains(maid2.status.subCharaData.id))
					{
						if (!CharacterSelectMain.compatibilityMode || maid2.status.isCompatiblePersonality)
						{
							draw_maid_list.Add(list3[n]);
						}
					}
				}
			});
			this.SetExplanatoryLabel("メイドを選択してください。");
			this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.auto_select_ = true;
			}
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.LifeMode)
		{
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list3);
				foreach (Maid item in EmpireLifeModeAPI.SelectionMaidList(list3))
				{
					draw_maid_list.Add(item);
				}
			});
			this.chara_select_mgr_.big_thumbnail.isEnabled = false;
			this.CreateSelectedMaidPanelOfLifeMode();
			this.chara_select_mgr_.SetCallBackOnMultiSelect(new CharacterSelectManager.CallBackOnMultiSelect(this.OnMultiSelectCharaLifeMode));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Multiple, EmpireLifeModeAPI.GetMaxMaidCount(), false);
			this.button_dic_["OK"].isEnabled = false;
			foreach (Maid maid in GameMain.Instance.LifeModeMgr.lifeModeAllMaidList)
			{
				this.chara_select_mgr_.SetSelectStateMaid(maid, true);
			}
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.chara_select_mgr_.SelectAllMaid();
				this.auto_select_ = true;
			}
			if (!this.auto_select_)
			{
				GameMain.Instance.SoundMgr.PlayBGM("BGM015.ogg", 0.5f, true);
			}
			this.button_dic_["全選択"].gameObject.SetActive(false);
			this.button_dic_["全解除"].gameObject.SetActive(false);
			this.SetExplanatoryLabel("ライフモードに登場するメイドを選択してください");
		}
		else if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.LifeModeRecollection)
		{
			this.chara_select_mgr_.SetCallBackMaidList(delegate(List<Maid> draw_maid_list)
			{
				List<Maid> list3 = new List<Maid>();
				CharacterSelectManager.DefaultMaidList(list3);
				foreach (Maid item in EmpireLifeModeAPI.SelectionMaidList(list3))
				{
					draw_maid_list.Add(item);
				}
			});
			this.chara_select_mgr_.big_thumbnail.isEnabled = false;
			this.CreateSelectedMaidPanelOfLifeModeRecollection();
			this.chara_select_mgr_.SetCallBackOnMultiSelect(new CharacterSelectManager.CallBackOnMultiSelect(this.OnMultiSelectCharaLifeModeRecollection));
			this.chara_select_mgr_.Create(CharacterSelectManager.Type.Multiple, EmpireLifeModeAPI.GetEnabledPersonalListOfRecollection().Count, false);
			this.button_dic_["OK"].isEnabled = false;
			if (this.chara_select_mgr_.maid_list_count == 1)
			{
				this.chara_select_mgr_.SelectAllMaid();
				this.auto_select_ = true;
			}
			if (!this.auto_select_)
			{
				GameMain.Instance.SoundMgr.PlayBGM("BGM015.ogg", 0.5f, true);
			}
			this.button_dic_["全選択"].gameObject.SetActive(false);
			this.button_dic_["全解除"].gameObject.SetActive(false);
			this.SetExplanatoryLabel("ライフモードに登場するメイドを選択してください");
		}
		CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
		for (int m = 0; m < characterMgr.GetStockMaidCount(); m++)
		{
			Maid stockMaid = characterMgr.GetStockMaid(m);
			if (stockMaid != null)
			{
				stockMaid.FaceAnime("通常", 0f, 0);
				stockMaid.FaceBlend("無し");
			}
		}
		if (flag)
		{
			GameMain.Instance.CharacterMgr.DeactivateCharaAll();
		}
	}

	private void OnCallAdditionalType()
	{
		Debug.Log("メイドをアクティブ化させるスロット : " + this.scene_chara_select_.select_maid_slot);
		CharacterSelectManager characterSelectManager = this.chara_select_mgr_;
		if (CharacterSelectMain.<>f__mg$cache1 == null)
		{
			CharacterSelectMain.<>f__mg$cache1 = new CharacterSelectManager.CallBackMaidList(KaraokeDataManager.GetMaidListAdditional);
		}
		characterSelectManager.SetCallBackMaidList(CharacterSelectMain.<>f__mg$cache1);
		this.chara_select_mgr_.SetCallBackCallBackOnSelect(new CharacterSelectManager.CallBackOnSelect(this.OnSelectChara));
		this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
		if (this.chara_select_mgr_.maid_list_count == 1)
		{
			this.auto_select_ = true;
		}
		this.SetExplanatoryLabel("*メイドの追加呼び出し*");
		CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
		for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
		{
			Maid stockMaid = characterMgr.GetStockMaid(i);
			if (stockMaid != null)
			{
				stockMaid.FaceAnime("通常", 0f, 0);
				stockMaid.FaceBlend("無し");
			}
		}
	}

	protected override bool IsCallFadeIn()
	{
		if (this.auto_select_)
		{
			base.SetFadeStatus(WfScreenChildren.FadeStatus.Wait);
			float fade_time = base.fade_time;
			base.SetFadeTime(0f);
			this.Finish();
			base.SetFadeTime(fade_time);
			return false;
		}
		this.wait_count_++;
		return 2 < this.wait_count_;
	}

	public void SetExplanatoryLabel(string text)
	{
		this.explanatory_label_.text = text;
		Localize component = this.explanatory_label_.gameObject.GetComponent<Localize>();
		component.SetTerm("SceneCharaSelect/" + text);
	}

	public void SetCancelLabel(string cancel_call_label)
	{
		this.cancel_call_label_ = cancel_call_label;
		this.button_dic_["Cancel"].gameObject.SetActive(!string.IsNullOrEmpty(this.cancel_call_label_));
	}

	private void OnSelectAllChara()
	{
		this.chara_select_mgr_.SelectAllMaid();
	}

	private void OnSelectAllReleaseChara()
	{
		this.chara_select_mgr_.SelectAllReleaseMaid();
	}

	private void OnSelectChara(Maid select_maid)
	{
		this.select_maid_ = select_maid;
	}

	private void OnSingleDanceSelectChara(Maid select_maid)
	{
		this.loaded_check_maid_.Clear();
		this.loaded_check_maid_.Add(select_maid);
	}

	private void OnMultiDanceSelectChara(Maid[] maid_array)
	{
		this.loaded_check_maid_.Clear();
		for (int i = 0; i < maid_array.Length; i++)
		{
			this.loaded_check_maid_.Add(maid_array[i]);
		}
	}

	private void OnMultiSelectChara(Maid[] maid_array)
	{
		this.loaded_check_maid_.Clear();
		bool isEnabled = false;
		bool flag = true;
		bool flag2 = true;
		for (int i = 0; i < maid_array.Length; i++)
		{
			if (maid_array[i] == null)
			{
				flag = false;
			}
			else
			{
				flag2 = false;
				isEnabled = true;
				this.loaded_check_maid_.Add(maid_array[i]);
			}
		}
		this.button_dic_["OK"].isEnabled = isEnabled;
		this.button_dic_["全選択"].isEnabled = !flag;
		this.button_dic_["全解除"].isEnabled = !flag2;
	}

	private void OnMultiSelectCharaLifeMode(Maid[] maidArray)
	{
		this.loaded_check_maid_.Clear();
		foreach (Maid maid in maidArray)
		{
			if (maid != null)
			{
				this.loaded_check_maid_.Add(maid);
			}
		}
		this.UpdateSelectedMaidPanelOfLifeMode(maidArray);
		this.button_dic_["OK"].isEnabled = (this.loaded_check_maid_.Count > 0);
	}

	private void OnMultiSelectCharaLifeModeRecollection(Maid[] maidArray)
	{
		this.loaded_check_maid_.Clear();
		foreach (Maid maid in maidArray)
		{
			if (maid != null)
			{
				this.loaded_check_maid_.Add(maid);
			}
		}
		this.UpdateSelectedMaidPanelOfLifeModeRecollection(maidArray);
		this.button_dic_["OK"].isEnabled = (this.loaded_check_maid_.Count > 0);
	}

	private void OnClickButton()
	{
		string text = string.Empty;
		foreach (KeyValuePair<string, UIButton> keyValuePair in this.button_dic_)
		{
			if (keyValuePair.Value == UIButton.current)
			{
				text = keyValuePair.Key;
				break;
			}
		}
		if (string.IsNullOrEmpty(text))
		{
			return;
		}
		if (text == "OK")
		{
			this.Finish();
		}
		else if (text == "Cancel")
		{
			if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Yotogi || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.NewYotogi)
			{
				string f_strMsg = "まだ夜伽を実行していないメイドがいます。\n夜伽を終了しますか？";
				GameMain.Instance.SysDlg.Show(f_strMsg, SystemDialog.TYPE.OK_CANCEL, delegate
				{
					GameMain.Instance.SysDlg.Close();
					this.select_maid_ = null;
					this.scene_chara_select_.move_screen.SetNextLabel(this.cancel_call_label_);
					this.Finish();
				}, null);
			}
			else
			{
				this.select_maid_ = null;
				this.scene_chara_select_.move_screen.SetNextLabel(this.cancel_call_label_);
				this.Finish();
			}
		}
	}

	private void OnOvrCamFree()
	{
		GameMain.Instance.CMSystem.SetTmpGenericFlag("ダンスOVRカメラタイプ", 0);
		this.Finish();
	}

	private void OnOvrCamMove()
	{
		GameMain.Instance.CMSystem.SetTmpGenericFlag("ダンスOVRカメラタイプ", 1);
		this.Finish();
	}

	public override bool Finish()
	{
		bool flag = base.Finish();
		if (flag && 0 < this.loaded_check_maid_.Count)
		{
			GameMain.Instance.SoundMgr.StopBGM(1.5f);
		}
		return flag;
	}

	protected override void OnFinish()
	{
		this.button_dic_["Cancel"].gameObject.SetActive(false);
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Communication && this.select_maid_ != null)
		{
			int noonWorkId = this.select_maid_.status.noonWorkId;
			this.loaded_check_maid_.Add(this.select_maid_);
			ScheduleData[] scheduleSlot = GameMain.Instance.CharacterMgr.status.scheduleSlot;
			for (int i = 0; i < scheduleSlot.Length; i++)
			{
				if (scheduleSlot[i].maid_guid == this.select_maid_.status.guid)
				{
					scheduleSlot[i].noon_communication = true;
					break;
				}
			}
			if (noonWorkId == ScheduleAPI.GetNoonTrainerWorkId())
			{
				Maid noonTraineeMaid = ScheduleAPI.GetNoonTraineeMaid();
				NDebug.Assert(noonTraineeMaid != null, "研修生を特定できませんでした");
				this.loaded_check_maid_.Add(noonTraineeMaid);
			}
			else if (noonWorkId == ScheduleAPI.GetTraineeWorkId())
			{
				Maid noonTrainerMaid = ScheduleAPI.GetNoonTrainerMaid();
				NDebug.Assert(noonTrainerMaid != null, "研修官を特定できませんでした");
				this.loaded_check_maid_.Add(noonTrainerMaid);
			}
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Yotogi || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.NewYotogi || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Vip || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Facility || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Free || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Recollection)
		{
			if (this.select_maid_ != null)
			{
				this.loaded_check_maid_.Add(this.select_maid_);
				SceneCharacterSelect.chara_guid_stock_list.Remove(this.select_maid_.status.guid);
			}
			else
			{
				SceneCharacterSelect.chara_guid_stock_list.Clear();
			}
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.CompetitiveShow)
		{
			CompetitiveShowMgr.check_maid_list.Clear();
			SceneCharacterSelect.select_maid_list.Clear();
			for (int j = 0; j < this.loaded_check_maid_.Count; j++)
			{
				SceneCharacterSelect.select_maid_list.Add(this.loaded_check_maid_[j]);
			}
			this.loaded_check_maid_.Clear();
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.TouchCharaSelect && this.select_maid_ != null)
		{
			this.loaded_check_maid_.Add(this.select_maid_);
		}
		if ((this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.VRComSelect || this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.VRKaraokeSelect) && this.select_maid_ != null)
		{
			this.loaded_check_maid_.Add(this.select_maid_);
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.Additional)
		{
			this.chara_mgr_.SetActiveMaid(this.select_maid_, this.scene_chara_select_.select_maid_slot);
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.LifeMode)
		{
			NDebug.Assert(this.loaded_check_maid_.Count > 0);
			GameMain.Instance.LifeModeMgr.SetAllMaidList(this.loaded_check_maid_);
			this.loaded_check_maid_.Clear();
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.LifeModeRecollection)
		{
			GameMain.Instance.LifeModeMgr.SetAllMaidList(this.loaded_check_maid_);
			this.loaded_check_maid_.Clear();
		}
		if (this.scene_chara_select_.select_type == SceneCharacterSelect.SelectType.NewYotogiAdditional)
		{
			this.loaded_check_maid_.Clear();
			this.loaded_check_maid_.Add(this.select_maid_);
			this.chara_mgr_.SetActiveMaid(this.loaded_check_maid_[0], 1);
			this.loaded_check_maid_[0].Visible = true;
			this.loaded_check_maid_[0].AllProcPropSeqStart();
		}
		else
		{
			for (int k = 0; k < this.loaded_check_maid_.Count; k++)
			{
				this.chara_mgr_.SetActiveMaid(this.loaded_check_maid_[k], k);
				this.loaded_check_maid_[k].Visible = true;
				this.loaded_check_maid_[k].AllProcPropSeqStart();
			}
		}
		GameMain.Instance.LoadIcon.NextLoadIcontImmediatelyDisplay();
		if (this.loaded_check_maid_.Count == 0)
		{
			base.parent_mgr.CallScreen("Move");
		}
	}

	protected override void OnFadeEnd()
	{
		if (this.loaded_check_maid_.Count == 0)
		{
			return;
		}
		bool flag = true;
		for (int i = 0; i < this.loaded_check_maid_.Count; i++)
		{
			if (this.loaded_check_maid_[i].IsBusy)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			base.parent_mgr.CallScreen("Move");
			this.loaded_check_maid_.Clear();
		}
	}

	private void InitSelectedMaidPanelUI()
	{
		this.m_SelectedMaidPanelParent = UTY.GetChildObject(base.root_obj, "SelectedMaidParent", false);
		this.m_SelectedMaidPanelGrid = UTY.GetChildObject(base.root_obj, "SelectedMaidParent/Grid", false).GetComponent<UIGrid>();
		this.m_SelectedMaidPanelListViewer = UTY.GetChildObject(base.root_obj, "SelectedMaidParent/Grid", false).GetComponent<uGUIListViewer>();
		this.m_SelectedMaidPanelButtonAutoSelect = UTY.GetChildObject(base.root_obj, "SelectedMaidParent/parent buttons/auto select", false).GetComponent<UIButton>();
		this.m_SelectedMaidPanelButtonAllRelease = UTY.GetChildObject(base.root_obj, "SelectedMaidParent/parent buttons/all release", false).GetComponent<UIButton>();
		NDebug.AssertNull(this.m_SelectedMaidPanelGrid);
		NDebug.AssertNull(this.m_SelectedMaidPanelListViewer);
		NDebug.AssertNull(this.m_SelectedMaidPanelButtonAutoSelect);
		NDebug.AssertNull(this.m_SelectedMaidPanelButtonAllRelease);
		this.m_SelectedMaidPanelParent.SetActive(false);
	}

	private void CreateSelectedMaidPanelOfLifeMode()
	{
		this.m_SelectedMaidPanelParent.SetActive(true);
		GameObject gameObject = Utility.CreatePrefab(this.m_SelectedMaidPanelGrid.gameObject, "CharacterSelect/Prefab/MaidPlateSimple", true);
		gameObject.SetActive(false);
		this.m_SelectedMaidPanelListViewer.tempItem = gameObject;
		this.m_SelectedMaidPanelListViewer.Show<MaidPlate>(21, delegate(int index, MaidPlate maidPlate)
		{
			if (EmpireLifeModeAPI.GetMaxMaidCount() <= index)
			{
				maidPlate.gameObject.SetActive(false);
			}
			else
			{
				maidPlate.gameObject.SetActive(true);
			}
			maidPlate.SetEmpty();
			UIButton uibutton = UTY.GetChildObject(maidPlate.gameObject, "Button", false).AddComponent<UIButton>();
			EventDelegate.Add(uibutton.onClick, delegate()
			{
				if (maidPlate.maid != null)
				{
					this.chara_select_mgr_.MoveGridArea(maidPlate.maid);
					this.chara_select_mgr_.SetSelectStateMaid(maidPlate.maid, false);
				}
			});
			maidPlate.GetComponentInChildren<Collider>().enabled = false;
			maidPlate.GetComponentInChildren<UIButton>().defaultColor = new Color(0f, 0f, 0f, 0.5f);
			maidPlate.GetComponentInChildren<UIPlayAnimation>().enabled = false;
		});
		EventDelegate.Add(this.m_SelectedMaidPanelButtonAutoSelect.onClick, new EventDelegate.Callback(this.OnClickButtonMaidAutoSelect));
		EventDelegate.Add(this.m_SelectedMaidPanelButtonAllRelease.onClick, new EventDelegate.Callback(this.OnClickButtonMaidAllRelease));
	}

	private void UpdateSelectedMaidPanelOfLifeMode(Maid[] nowMaidSelectState)
	{
		bool flag = false;
		int num = 0;
		while (num < nowMaidSelectState.Length && num < this.m_SelectedMaidPanelListViewer.ItemArray.Length)
		{
			GameObject gameObject = this.m_SelectedMaidPanelListViewer.ItemArray[num];
			MaidPlate component = gameObject.GetComponent<MaidPlate>();
			UIButton componentInChildren = gameObject.GetComponentInChildren<UIButton>();
			Maid maid = nowMaidSelectState[num];
			component.GetComponentInChildren<Collider>().enabled = (maid != null);
			componentInChildren.defaultColor = ((!(maid != null)) ? new Color(0f, 0f, 0f, 0.5f) : new Color(0f, 0f, 0f, 0f));
			if (maid == null)
			{
				component.SetEmpty();
				component.transform.SetAsLastSibling();
				flag = true;
			}
			if (!gameObject.activeSelf)
			{
				gameObject.SetActive(true);
				component.transform.SetAsLastSibling();
				flag = true;
			}
			if (maid != component.maid)
			{
				component.SetMaidData(maid);
				component.transform.SetAsLastSibling();
				flag = true;
			}
			num++;
		}
		if (flag)
		{
			this.m_SelectedMaidPanelGrid.Reposition();
		}
		foreach (Transform transform in this.chara_select_mgr_.MaidPlateParentGrid.GetChildList())
		{
			MaidPlate component2 = transform.GetComponent<MaidPlate>();
			if (component2.maid != null && this.loaded_check_maid_.Contains(component2.maid))
			{
				this.chara_select_mgr_.MoveNoDrawArea(component2.maid);
			}
		}
		foreach (MaidPlate maidPlate in this.chara_select_mgr_.NoDrawArea.GetComponentsInChildren<MaidPlate>())
		{
			if (maidPlate.maid != null && !this.loaded_check_maid_.Contains(maidPlate.maid))
			{
				this.chara_select_mgr_.MoveGridArea(maidPlate.maid);
			}
		}
	}

	private void OnClickButtonMaidAutoSelect()
	{
		int num = 0;
		List<Maid> list = new List<Maid>();
		List<MaidPlate> list2 = new List<MaidPlate>();
		int num2 = 0;
		while (num2 < this.m_SelectedMaidPanelListViewer.ItemArray.Length && num2 < this.chara_select_mgr_.select_max)
		{
			GameObject gameObject = this.m_SelectedMaidPanelListViewer.ItemArray[num2];
			MaidPlate component = gameObject.GetComponent<MaidPlate>();
			if (component.maid == null)
			{
				num++;
			}
			else
			{
				list.Add(component.maid);
			}
			num2++;
		}
		List<Transform> childList = this.chara_select_mgr_.MaidPlateParentGrid.GetChildList();
		for (int i = 0; i < childList.Count; i++)
		{
			MaidPlate component2 = childList[i].GetComponent<MaidPlate>();
			if (!list.Contains(component2.maid))
			{
				list2.Add(component2);
			}
		}
		foreach (MaidPlate maidPlate in from maid in list2
		orderby UnityEngine.Random.Range(0, 10)
		select maid)
		{
			if (num-- <= 0)
			{
				break;
			}
			this.chara_select_mgr_.SetSelectStateMaid(maidPlate.maid, true);
		}
	}

	private void OnClickButtonMaidAllRelease()
	{
		foreach (MaidPlate maidPlate in this.chara_select_mgr_.NoDrawArea.GetComponentsInChildren<MaidPlate>())
		{
			this.chara_select_mgr_.MoveGridArea(maidPlate.maid);
		}
		this.chara_select_mgr_.SelectAllReleaseMaid();
	}

	private void CreateSelectedMaidPanelOfLifeModeRecollection()
	{
		this.m_SelectedMaidPanelParent.SetActive(true);
		GameObject gameObject = Utility.CreatePrefab(this.m_SelectedMaidPanelGrid.gameObject, "CharacterSelect/Prefab/MaidPlateSimple", true);
		gameObject.SetActive(false);
		this.m_SelectedMaidPanelListViewer.tempItem = gameObject;
		this.m_SelectedMaidPanelListViewer.Show<MaidPlate>(EmpireLifeModeAPI.GetEnabledPersonalListOfRecollection().Count, delegate(int index, MaidPlate maidPlate)
		{
			if (EmpireLifeModeAPI.GetEnabledPersonalListOfRecollection().Count <= index)
			{
				maidPlate.gameObject.SetActive(false);
			}
			else
			{
				maidPlate.gameObject.SetActive(true);
			}
			maidPlate.SetEmpty();
			UIButton uibutton = UTY.GetChildObject(maidPlate.gameObject, "Button", false).AddComponent<UIButton>();
			EventDelegate.Add(uibutton.onClick, delegate()
			{
				if (maidPlate.maid != null)
				{
					this.chara_select_mgr_.MoveGridArea(maidPlate.maid);
					this.chara_select_mgr_.SetSelectStateMaid(maidPlate.maid, false);
				}
			});
			maidPlate.GetComponentInChildren<Collider>().enabled = false;
			maidPlate.GetComponentInChildren<UIButton>().defaultColor = new Color(0f, 0f, 0f, 0.5f);
			maidPlate.GetComponentInChildren<UIPlayAnimation>().enabled = false;
		});
		this.m_SelectedMaidPanelButtonAutoSelect.gameObject.SetActive(false);
		EventDelegate.Add(this.m_SelectedMaidPanelButtonAllRelease.onClick, new EventDelegate.Callback(this.OnClickButtonMaidAllRelease));
	}

	private void UpdateSelectedMaidPanelOfLifeModeRecollection(Maid[] nowMaidSelectState)
	{
		bool flag = false;
		int num = 0;
		while (num < nowMaidSelectState.Length && num < this.m_SelectedMaidPanelListViewer.ItemArray.Length)
		{
			GameObject gameObject = this.m_SelectedMaidPanelListViewer.ItemArray[num];
			MaidPlate component = gameObject.GetComponent<MaidPlate>();
			UIButton componentInChildren = gameObject.GetComponentInChildren<UIButton>();
			Maid maid = nowMaidSelectState[num];
			component.GetComponentInChildren<Collider>().enabled = (maid != null);
			componentInChildren.defaultColor = ((!(maid != null)) ? new Color(0f, 0f, 0f, 0.5f) : new Color(0f, 0f, 0f, 0f));
			if (maid == null)
			{
				component.SetEmpty();
				component.transform.SetAsLastSibling();
				flag = true;
			}
			if (!gameObject.activeSelf)
			{
				gameObject.SetActive(true);
				component.transform.SetAsLastSibling();
				flag = true;
			}
			if (maid != component.maid)
			{
				component.SetMaidData(maid);
				component.transform.SetAsLastSibling();
				flag = true;
			}
			num++;
		}
		if (flag)
		{
			this.m_SelectedMaidPanelGrid.Reposition();
		}
		foreach (Transform transform in this.chara_select_mgr_.MaidPlateParentGrid.GetChildList())
		{
			MaidPlate component2 = transform.GetComponent<MaidPlate>();
			if (component2.maid != null && this.loaded_check_maid_.Contains(component2.maid))
			{
				this.chara_select_mgr_.MoveNoDrawArea(component2.maid);
			}
		}
		foreach (MaidPlate maidPlate in this.chara_select_mgr_.NoDrawArea.GetComponentsInChildren<MaidPlate>())
		{
			if (maidPlate.maid != null && !this.loaded_check_maid_.Contains(maidPlate.maid))
			{
				this.chara_select_mgr_.MoveGridArea(maidPlate.maid);
			}
		}
		List<string> list = new List<string>();
		foreach (Maid maid2 in nowMaidSelectState)
		{
			if (maid2 != null && !list.Contains(maid2.status.personal.uniqueName))
			{
				list.Add(maid2.status.personal.uniqueName);
			}
		}
		foreach (Transform transform2 in this.chara_select_mgr_.MaidPlateParentGrid.GetChildList())
		{
			MaidPlate component3 = transform2.GetComponent<MaidPlate>();
			UIButton componentInChildren2 = component3.GetComponentInChildren<UIButton>(true);
			bool flag2 = true;
			if (component3.maid == null || list.Contains(component3.maid.status.personal.uniqueName))
			{
				flag2 = false;
			}
			componentInChildren2.defaultColor = ((!flag2) ? new Color(0f, 0f, 0f, 0.5f) : new Color(0f, 0f, 0f, 0f));
			componentInChildren2.gameObject.SetActive(flag2);
		}
	}

	private SceneCharacterSelect scene_chara_select_;

	private Maid select_maid_;

	private CharacterMgr chara_mgr_;

	private CharacterSelectManager chara_select_mgr_;

	private Dictionary<string, UIButton> button_dic_ = new Dictionary<string, UIButton>();

	private List<Maid> loaded_check_maid_ = new List<Maid>();

	private UILabel explanatory_label_;

	private string cancel_call_label_ = string.Empty;

	private int wait_count_;

	private bool auto_select_;

	private FFNameDialog ovr_dance_cam_dlg_;

	private GameObject m_SelectedMaidPanelParent;

	private UIGrid m_SelectedMaidPanelGrid;

	private uGUIListViewer m_SelectedMaidPanelListViewer;

	private UIButton m_SelectedMaidPanelButtonAutoSelect;

	private UIButton m_SelectedMaidPanelButtonAllRelease;

	[CompilerGenerated]
	private static CharacterSelectManager.CallBackMaidList <>f__mg$cache0;

	[CompilerGenerated]
	private static CharacterSelectManager.CallBackMaidList <>f__mg$cache1;
}
