using System;
using System.Collections;
using System.Collections.Generic;
using PlayerStatus;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class SceneFacilityManagement : MonoBehaviour
{
	private FacilityManager FacilityMgr
	{
		get
		{
			if (this.m_FacilityMgr == null)
			{
				this.m_FacilityMgr = GameMain.Instance.FacilityMgr;
			}
			return this.m_FacilityMgr;
		}
	}

	public FacilityInfoUI UIFacilityInfoBottomViewer
	{
		get
		{
			return this.m_UIFacilityInfoConstruction;
		}
	}

	public bool enableSetUpCameraAndBG
	{
		get
		{
			return this.m_EnableSetUpCameraAndBG;
		}
		set
		{
			this.m_EnableSetUpCameraAndBG = value;
		}
	}

	public long nowMoney
	{
		get
		{
			Status status = GameMain.Instance.CharacterMgr.status;
			return status.money;
		}
		set
		{
			Status status = GameMain.Instance.CharacterMgr.status;
			status.money = value;
			this.UpdateTextNumber(this.m_UITextNowMoney, value);
		}
	}

	public long nowCost
	{
		get
		{
			return this.m_NowCost;
		}
		set
		{
			this.m_NowCost = value;
			this.UpdateTextNumber(this.m_UITextNowCost, value);
		}
	}

	private void Awake()
	{
		if (this.m_StartDestroyEventObject != null)
		{
			this.m_StartDestroyEventObject.m_EventOnStart.AddListener(delegate()
			{
				GameMain.Instance.SoundMgr.PlayBGM(this.m_PlayBGM, 0.5f, true);
			});
		}
	}

	private void Start()
	{
		if (this.m_UIClubStatusViewer)
		{
			this.m_UIClubStatusViewer.gameObject.SetActive(false);
		}
		if (this.enableSetUpCameraAndBG)
		{
			this.SetUpBackGroundAndCamera();
		}
		this.UpdateTextNumber(this.m_UITextNowMoney, this.nowMoney);
		this.UpdateTextNumber(this.m_UITextNowCost, this.nowCost);
		this.m_UITextNowMoney.transform.parent.gameObject.SetActive(false);
		this.m_UITextNowCost.transform.parent.gameObject.SetActive(false);
		int typeID = FacilityDataTable.GetFacilityStatusArray(true)[0].typeID;
		this.m_CreatingFacility = GameMain.Instance.FacilityMgr.CreateNewFacility(typeID);
		this.m_CreatingFacility.transform.SetParent(base.transform, false);
		this.OpenFacilityUIConstruction();
		this.GetTagBackup();
	}

	private void SetUpBackGroundAndCamera()
	{
		GameMain.Instance.BgMgr.ChangeBg("EmpireClub_Entrance");
		GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color));
		CameraMain mainCamera = GameMain.Instance.MainCamera;
		GameMain.Instance.MainLight.Reset();
		mainCamera.Reset(CameraMain.CameraType.Target, false);
		mainCamera.SetTargetPos(new Vector3(0f, 5.5f, 11f), true);
		mainCamera.SetDistance(1.4f, true);
		mainCamera.SetAroundAngle(new Vector2(180f, 3f), true);
		mainCamera.SetTargetOffset(Vector3.zero, false);
	}

	private void UpdateTextNumber(Text text, long number)
	{
		text.text = string.Format("{0:#,0}", number);
	}

	public long CalcNowCost()
	{
		long num = 0L;
		Dictionary<int, Facility> nextDayFacilityArray = this.FacilityMgr.GetNextDayFacilityArray();
		List<Facility> list = new List<Facility>(nextDayFacilityArray.Values);
		for (int i = 0; i < list.Count; i++)
		{
			Facility facility = list[i];
			if (facility != null)
			{
				num += (long)FacilityDataTable.GetFacilityDefaultCost(facility.param.typeID, true);
			}
		}
		return num;
	}

	public void OpenDialog(string messageText, SystemDialog.TYPE openType, Action actionOK, Action actionCANCEL)
	{
		uGUIUtility.SetActiveEventSystem(false);
		GameMain.Instance.SysDlg.Show(messageText, openType, delegate
		{
			GameMain.Instance.SysDlg.Close();
			uGUIUtility.SetActiveEventSystem(true);
			if (actionOK != null)
			{
				actionOK();
			}
		}, delegate
		{
			GameMain.Instance.SysDlg.Close();
			uGUIUtility.SetActiveEventSystem(true);
			if (actionCANCEL != null)
			{
				actionCANCEL();
			}
		});
	}

	private void ButtonEvent_OK_OpenMainMenu()
	{
		this.ButtonEventSceneClose();
	}

	private void SetMoneyParamWindowVisible(bool isVisible)
	{
		Transform parent = this.m_UITextNowMoney.transform.parent;
		if (parent)
		{
			parent.gameObject.SetActive(isVisible);
		}
	}

	public void OpenFacilityUIMaidSchedule()
	{
		this.m_UIMainMenu.gameObject.SetActive(true);
		this.m_UIFacilityDetails.gameObject.SetActive(true);
		this.m_UIFacilityPowerUpList.gameObject.SetActive(false);
		this.m_UIFacilityTypeList.gameObject.SetActive(false);
		this.m_UIFacilityCostume.gameObject.SetActive(false);
		this.m_UIFacilityInfoMiniWindow.gameObject.SetActive(false);
		this.m_UIButtonOK.gameObject.SetActive(true);
		this.m_UIButtonRESET.gameObject.SetActive(true);
		this.m_UIButtonCANCEL.gameObject.SetActive(false);
		this.m_UIToggleVisibleFacilityInfo.gameObject.SetActive(true);
		if (this.m_UIClubStatusViewer)
		{
			this.m_UIClubStatusViewer.gameObject.SetActive(false);
		}
		this.SetMoneyParamWindowVisible(true);
		this.nowMoney = this.nowMoney;
		this.nowCost = this.CalcNowCost();
		this.m_UIToggleVisibleFacilityInfo.isOn = false;
		this.m_UIButtonOK.onClick.RemoveAllListeners();
		this.m_UIButtonOK.onClick.AddListener(new UnityAction(this.ButtonEvent_OK_OpenMainMenu));
		this.SetOKButtonEnable(true);
		this.m_UIFacilityInfoConstruction.gameObject.SetActive(false);
		this.m_UIButtonRESET.interactable = (this.FacilityMgr.GetNextDayFacilityArray().Count > 0);
		int facilityCountMax = this.FacilityMgr.FacilityCountMax;
		uGUIListViewer component = this.m_UIFacilityDetails.GetComponent<uGUIListViewer>();
		component.Show<Transform>(facilityCountMax, delegate(int i, Transform trans)
		{
			GameObject gameObject = trans.gameObject;
			SceneFacilityManagement.FacilityDetailsUI facilityDetailsUI = gameObject.AddComponent<SceneFacilityManagement.FacilityDetailsUI>();
			Facility facility = this.FacilityMgr.GetFacility(i);
			if (facility == null)
			{
				facilityDetailsUI.m_Button.gameObject.SetActive(false);
				facilityDetailsUI.m_FacilityInfoUI.imageFacilityThumbnail.color = new Color(0f, 0f, 0f, 0.25f);
				ColorBlock colors = facilityDetailsUI.m_Toggle.colors;
				Color highlightedColor = colors.highlightedColor;
				highlightedColor.a = 0f;
				colors.highlightedColor = highlightedColor;
				facilityDetailsUI.m_Toggle.colors = colors;
			}
			else
			{
				facilityDetailsUI.m_FacilityInfoUI.imageFacilityThumbnail.color = new Color(1f, 1f, 1f, 1f);
			}
			FacilityInfoUI component2 = trans.GetComponent<FacilityInfoUI>();
			component2.SetFacilityInfo(facility, false);
			component2.SetNameChangeEnable(facility != null);
			facilityDetailsUI.m_Toggle.onValueChanged.RemoveAllListeners();
			facilityDetailsUI.m_Toggle.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				this.m_SelectingFacilityIndex = i;
				if (!this.m_UIFacilityInfoConstruction.gameObject.activeSelf)
				{
					this.m_UIFacilityInfoConstruction.gameObject.SetActive(true);
				}
				this.m_UIFacilityInfoConstruction.SetFacilityInfo(facility, false);
				this.m_UIButtonDestroyFacility.interactable = (facility != null);
			});
			if (i == this.m_SelectingFacilityIndex)
			{
				Selectable componentInChildren = trans.GetComponentInChildren<Selectable>();
				if (componentInChildren.interactable)
				{
					uGUIUtility.SetSelectedGameObject(gameObject);
					facilityDetailsUI.m_Toggle.isOn = true;
				}
			}
		});
	}

	public void OpenFacilityUIConstruction(bool isOn)
	{
		if (!isOn)
		{
			return;
		}
		this.OpenFacilityUIConstruction();
	}

	public void OpenFacilityUIConstruction()
	{
		this.m_UIMainMenu.gameObject.SetActive(true);
		this.m_UIFacilityDetails.gameObject.SetActive(true);
		this.m_UIFacilityPowerUpList.gameObject.SetActive(false);
		this.m_UIFacilityTypeList.gameObject.SetActive(false);
		this.m_UIFacilityCostume.gameObject.SetActive(false);
		this.m_UIFacilityInfoMiniWindow.gameObject.SetActive(false);
		this.m_UIButtonOK.gameObject.SetActive(true);
		this.m_UIButtonRESET.gameObject.SetActive(true);
		this.m_UIButtonCANCEL.gameObject.SetActive(false);
		this.m_UIToggleVisibleFacilityInfo.gameObject.SetActive(true);
		if (this.m_UIClubStatusViewer)
		{
			this.m_UIClubStatusViewer.gameObject.SetActive(false);
		}
		this.SetMoneyParamWindowVisible(true);
		this.nowMoney = this.nowMoney;
		this.nowCost = this.CalcNowCost();
		this.m_UIToggleVisibleFacilityInfo.isOn = false;
		this.m_UIButtonOK.onClick.RemoveAllListeners();
		this.m_UIButtonOK.onClick.AddListener(new UnityAction(this.ButtonEvent_OK_OpenMainMenu));
		this.SetOKButtonEnable(true);
		this.m_UIFacilityInfoConstruction.gameObject.SetActive(false);
		this.m_UIButtonRESET.interactable = (this.FacilityMgr.GetNextDayFacilityArray().Count > 0);
		int facilityCountMax = this.FacilityMgr.FacilityCountMax;
		uGUIListViewer component = this.m_UIFacilityDetails.GetComponent<uGUIListViewer>();
		component.Show<Transform>(facilityCountMax, delegate(int i, Transform trans)
		{
			GameObject gameObject = trans.gameObject;
			SceneFacilityManagement.FacilityDetailsUI facilityDetailsUI = gameObject.AddComponent<SceneFacilityManagement.FacilityDetailsUI>();
			Facility facility = null;
			if (this.FacilityMgr.GetNextDayFacilityExist(i))
			{
				facility = this.FacilityMgr.GetNextDayFacility(i);
				facilityDetailsUI.m_ChangeImage.SetActive(facility != null);
				facilityDetailsUI.m_DeleteImage.SetActive(facility == null && this.FacilityMgr.GetFacility(i) != null);
				if (facility == null)
				{
					facility = this.FacilityMgr.GetFacility(i);
				}
			}
			else
			{
				facility = this.FacilityMgr.GetFacility(i);
			}
			if (facility == null)
			{
				facilityDetailsUI.m_Button.gameObject.SetActive(false);
				facilityDetailsUI.m_FacilityInfoUI.imageFacilityThumbnail.color = new Color(0f, 0f, 0f, 0.25f);
				ColorBlock colors = facilityDetailsUI.m_Toggle.colors;
				Color highlightedColor = colors.highlightedColor;
				highlightedColor.a = 0f;
				colors.highlightedColor = highlightedColor;
				facilityDetailsUI.m_Toggle.colors = colors;
			}
			else
			{
				facilityDetailsUI.m_FacilityInfoUI.imageFacilityThumbnail.color = new Color(1f, 1f, 1f, 1f);
			}
			FacilityInfoUI component2 = trans.GetComponent<FacilityInfoUI>();
			component2.SetFacilityInfo(facility, false);
			component2.SetNameChangeEnable(facility != null);
			facilityDetailsUI.m_Toggle.onValueChanged.RemoveAllListeners();
			facilityDetailsUI.m_Toggle.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				this.m_SelectingFacilityIndex = i;
				if (!this.m_UIFacilityInfoConstruction.gameObject.activeSelf)
				{
					this.m_UIFacilityInfoConstruction.gameObject.SetActive(true);
				}
				this.m_UIFacilityInfoConstruction.SetFacilityInfo(facility, false);
				this.m_UIButtonDestroyFacility.interactable = (facility != null);
			});
			if (i == this.m_SelectingFacilityIndex)
			{
				Selectable componentInChildren = trans.GetComponentInChildren<Selectable>();
				if (componentInChildren.interactable)
				{
					uGUIUtility.SetSelectedGameObject(gameObject);
					facilityDetailsUI.m_Toggle.isOn = true;
				}
			}
		});
	}

	public void ButtonEvent_FacilityReplace()
	{
		int selectingFacilityIndex = this.m_SelectingFacilityIndex;
		Facility facility;
		if (this.FacilityMgr.GetNextDayFacilityExist(selectingFacilityIndex))
		{
			facility = this.FacilityMgr.GetNextDayFacility(selectingFacilityIndex);
		}
		else
		{
			facility = this.FacilityMgr.GetFacility(selectingFacilityIndex);
		}
		string messageText = string.Empty;
		if (facility == null)
		{
			messageText = "空き部屋に施設を配置しますか？";
		}
		else
		{
			messageText = "『" + facility.facilityName + "』\nが配置されています。\n施設を変更しますか？";
		}
		if (facility && !FacilityDataTable.GetFacilityCanBeDestroy(facility.param.typeID, true))
		{
			this.OpenDialog("『" + facility.facilityName + "』\nは変更出来ない施設です。", SystemDialog.TYPE.OK, null, null);
		}
		else
		{
			this.OpenDialog(messageText, SystemDialog.TYPE.YES_NO, delegate
			{
				this.m_CreatingFacility.param.typeID = 0;
				this.ShowFacilityTypeList();
				this.m_UIButtonRESET.gameObject.SetActive(false);
				this.m_UIToggleVisibleFacilityInfo.gameObject.SetActive(false);
				this.m_UIMainMenu.gameObject.SetActive(false);
				this.SetMoneyParamWindowVisible(true);
			}, null);
		}
	}

	public void ToggleEvent_VisibleFacilityInfo(bool b)
	{
		uGUIListViewer component = this.m_UIFacilityDetails.GetComponent<uGUIListViewer>();
		GameObject[] itemArray = component.ItemArray;
		if (itemArray == null)
		{
			return;
		}
		foreach (GameObject gameObject in itemArray)
		{
			SceneFacilityManagement.FacilityDetailsUI component2 = gameObject.GetComponent<SceneFacilityManagement.FacilityDetailsUI>();
			component2.m_ParentInfo.SetActive(b);
		}
	}

	public void ShowFacilityTypeList()
	{
		this.m_UIFacilityDetails.gameObject.SetActive(false);
		this.m_UIFacilityTypeList.gameObject.SetActive(true);
		this.m_UIFacilityPowerUpList.gameObject.SetActive(false);
		this.m_UIButtonCANCEL.gameObject.SetActive(true);
		this.m_UIButtonCANCEL.onClick.RemoveAllListeners();
		this.m_UIButtonCANCEL.onClick.AddListener(new UnityAction(this.OpenFacilityUIConstruction));
		this.m_UIButtonCANCEL.onClick.AddListener(delegate()
		{
			this.m_UIMainMenu.gameObject.SetActive(true);
		});
		this.m_UIButtonOK.onClick.RemoveAllListeners();
		this.m_UIButtonOK.onClick.AddListener(new UnityAction(this.ButtonEvent_OK_FacilityConstruction));
		this.SetOKButtonEnable(this.IsOKButtonEnable());
		this.SetUpFacilityTypeList();
	}

	private void SetUpFacilityTypeList()
	{
		SceneFacilityManagement.<SetUpFacilityTypeList>c__AnonStorey4 <SetUpFacilityTypeList>c__AnonStorey = new SceneFacilityManagement.<SetUpFacilityTypeList>c__AnonStorey4();
		<SetUpFacilityTypeList>c__AnonStorey.$this = this;
		uGUIListViewer component = this.m_UIFacilityTypeList.GetComponent<uGUIListViewer>();
		Facility facility;
		if (this.FacilityMgr.GetNextDayFacilityExist(this.m_SelectingFacilityIndex))
		{
			facility = this.FacilityMgr.GetNextDayFacility(this.m_SelectingFacilityIndex);
		}
		else
		{
			facility = this.FacilityMgr.GetFacility(this.m_SelectingFacilityIndex);
		}
		int num = -1;
		if (facility)
		{
			num = facility.param.typeID;
		}
		Facility.FacilityStatus[] facilityStatusArray = FacilityDataTable.GetFacilityStatusArray(true);
		<SetUpFacilityTypeList>c__AnonStorey.canBePlaceFacilityDataArray = new List<Facility.FacilityStatus>();
		Facility value;
		for (int j = 0; j < facilityStatusArray.Length; j++)
		{
			int typeID = facilityStatusArray[j].typeID;
			FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.GetFacilityDefaultData(typeID, true);
			if (num != typeID)
			{
				if (!FacilityDataTable.GetFacilityDefaultPlacement(typeID, true))
				{
					if (GameMain.Instance.CharacterMgr.status.lockNTRPlay)
					{
						if (!facilityDefaultData.isEnableNTR)
						{
							goto IL_280;
						}
					}
					else if (facilityDefaultData.isOnlyNTR)
					{
						goto IL_280;
					}
					if (facilityDefaultData.name == "カジノ")
					{
						if (this.FacilityMgr.IsExistTypeFacility(facilityDefaultData.ID))
						{
							goto IL_280;
						}
						bool flag = false;
						foreach (KeyValuePair<int, Facility> keyValuePair in this.FacilityMgr.GetNextDayFacilityArray())
						{
							value = keyValuePair.Value;
							if (value != null && value.defaultName == "カジノ")
							{
								flag = true;
								break;
							}
						}
						if (flag)
						{
							goto IL_280;
						}
					}
					else if (facilityDefaultData.name == "高級カジノ")
					{
						if (this.FacilityMgr.IsExistTypeFacility(facilityDefaultData.ID))
						{
							goto IL_280;
						}
						bool flag2 = false;
						foreach (KeyValuePair<int, Facility> keyValuePair2 in this.FacilityMgr.GetNextDayFacilityArray())
						{
							Facility value2 = keyValuePair2.Value;
							if (value2 != null && value2.defaultName == "高級カジノ")
							{
								flag2 = true;
								break;
							}
						}
						if (flag2)
						{
							goto IL_280;
						}
					}
					<SetUpFacilityTypeList>c__AnonStorey.canBePlaceFacilityDataArray.Add(facilityStatusArray[j]);
				}
			}
			IL_280:;
		}
		component.Show<Transform>(<SetUpFacilityTypeList>c__AnonStorey.canBePlaceFacilityDataArray.Count, delegate(int i, Transform trans)
		{
			Facility.FacilityStatus facilityStatus = <SetUpFacilityTypeList>c__AnonStorey.canBePlaceFacilityDataArray[i];
			Toggle componentInChildren = trans.GetComponentInChildren<Toggle>();
			Text componentInChildren2 = trans.GetComponentInChildren<Text>();
			componentInChildren2.text = facilityStatus.name;
			componentInChildren.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				<SetUpFacilityTypeList>c__AnonStorey.m_CreatingFacility.Init(facilityStatus.typeID);
				<SetUpFacilityTypeList>c__AnonStorey.ShowFacilityPowerUpList(<SetUpFacilityTypeList>c__AnonStorey.m_CreatingFacility);
				long num2 = <SetUpFacilityTypeList>c__AnonStorey.CalcNowCost();
				num2 += (long)FacilityDataTable.GetFacilityDefaultCost(facilityStatus.typeID, true);
				if (<SetUpFacilityTypeList>c__AnonStorey.FacilityMgr.GetNextDayFacilityExist(<SetUpFacilityTypeList>c__AnonStorey.m_SelectingFacilityIndex))
				{
					Facility nextDayFacility = <SetUpFacilityTypeList>c__AnonStorey.FacilityMgr.GetNextDayFacility(<SetUpFacilityTypeList>c__AnonStorey.m_SelectingFacilityIndex);
					if (nextDayFacility)
					{
						num2 -= (long)FacilityDataTable.GetFacilityDefaultCost(nextDayFacility.param.typeID, true);
					}
				}
				<SetUpFacilityTypeList>c__AnonStorey.nowCost = num2;
				<SetUpFacilityTypeList>c__AnonStorey.m_CreatingFacility.Init(facilityStatus.typeID);
				<SetUpFacilityTypeList>c__AnonStorey.SetOKButtonEnable(<SetUpFacilityTypeList>c__AnonStorey.IsOKButtonEnable());
				if (!<SetUpFacilityTypeList>c__AnonStorey.m_UIFacilityInfoMiniWindow.gameObject.activeSelf)
				{
					<SetUpFacilityTypeList>c__AnonStorey.m_UIFacilityInfoMiniWindow.gameObject.SetActive(true);
				}
				<SetUpFacilityTypeList>c__AnonStorey.m_UIFacilityInfoMiniWindow.SetFacilityInfo(<SetUpFacilityTypeList>c__AnonStorey.m_CreatingFacility, true);
				<SetUpFacilityTypeList>c__AnonStorey.m_UIFacilityInfoMiniWindow.viewType = FacilityInfoUI.ViewType.ConstructMode;
			});
		});
	}

	public void ResetFacilityTypeList()
	{
		uGUIListViewer component = this.m_UIFacilityTypeList.GetComponent<uGUIListViewer>();
		component.ResetList();
	}

	private void ShowFacilityPowerUpList(Facility facility)
	{
		this.m_UIFacilityPowerUpList.gameObject.SetActive(true);
		this.SetUpFacilityPowerUpList(facility);
	}

	private void SetUpFacilityPowerUpList(Facility facility)
	{
		uGUIListViewer componentInChildren = this.m_UIFacilityPowerUpList.GetComponentInChildren<uGUIListViewer>();
		if (FacilityDataTable.IsExistFacilityPowerUpRecipe(facility.param.typeID, true))
		{
			Facility.RecipeData[] recipeArray = facility.recipe;
			componentInChildren.Show<Transform>(recipeArray.Length, delegate(int i, Transform trans)
			{
				Text component = trans.Find("Text Recipe Name").GetComponent<Text>();
				Text component2 = trans.Find("Text Recipe Number").GetComponent<Text>();
				uGUIListViewer component3 = trans.Find("parent materials").GetComponent<uGUIListViewer>();
				uGUIListViewer component4 = trans.Find("parent conditions").GetComponent<uGUIListViewer>();
				uGUIListViewer component5 = trans.Find("parent default parameter").GetComponent<uGUIListViewer>();
				uGUIListViewer component6 = trans.Find("parent additional parameter").GetComponent<uGUIListViewer>();
				Facility.PowerUpRecipe facilityPowerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(recipeArray[i].id);
				component.text = facilityPowerUpRecipe.name;
				component2.text = string.Format("RECIPE {0}", i + 1);
				this.SetUpRecipeMaterialList(component3, recipeArray[i]);
				this.SetUpRecipeConditionList(component4, recipeArray[i].id);
				this.SetUpFacilityParams(component5, recipeArray[i].defaultParameter);
				this.SetUpFacilityParams(component6, recipeArray[i].additionalParameter);
			});
		}
		else
		{
			componentInChildren.Show<Transform>(1, delegate(int i, Transform trans)
			{
				Text component = trans.Find("Text Recipe Name").GetComponent<Text>();
				Text component2 = trans.Find("Text Recipe Number").GetComponent<Text>();
				uGUIListViewer component3 = trans.Find("parent materials").GetComponent<uGUIListViewer>();
				uGUIListViewer component4 = trans.Find("parent conditions").GetComponent<uGUIListViewer>();
				uGUIListViewer component5 = trans.Find("parent default parameter").GetComponent<uGUIListViewer>();
				uGUIListViewer component6 = trans.Find("parent additional parameter").GetComponent<uGUIListViewer>();
				component.text = "レシピ無し";
				component2.text = string.Empty;
				component3.ResetList();
				component4.ResetList();
				component5.ResetList();
				component6.ResetList();
			});
		}
	}

	public void ResetFacilityPowerUpList()
	{
		uGUIListViewer componentInChildren = this.m_UIFacilityPowerUpList.GetComponentInChildren<uGUIListViewer>();
		if (componentInChildren)
		{
			componentInChildren.ResetList();
		}
		else
		{
			Debug.LogWarningFormat("{0}\u3000には「{1}」コンポーネントが無い", new object[]
			{
				this.m_UIFacilityPowerUpList.name,
				typeof(uGUIListViewer)
			});
		}
	}

	private void SetUpRecipeMaterialList(uGUIListViewer listViewer, Facility.RecipeData recipeData)
	{
		Facility.PowerUpRecipe facilityPowerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(recipeData.id);
		int[] materialCategoryIDArray = facilityPowerUpRecipe.materialCategoryIDArray;
		listViewer.Show<Transform>(materialCategoryIDArray.Length, delegate(int i, Transform trans)
		{
			int categoryID = materialCategoryIDArray[i];
			int materialID = recipeData.materialIDArray[i];
			Text component = trans.Find("Text Category Name").GetComponent<Text>();
			Text component2 = trans.Find("Text Category Number").GetComponent<Text>();
			Text component3 = trans.Find("Text Material Name").GetComponent<Text>();
			string facilityPowerUpMaterialCategoryName = FacilityDataTable.GetFacilityPowerUpMaterialCategoryName(categoryID);
			string text = string.Empty;
			if (FacilityDataTable.IsExistPowerUpMaterial(materialID))
			{
				text = FacilityDataTable.GetFacilityPowerUpMaterial(materialID).name;
			}
			component.text = facilityPowerUpMaterialCategoryName;
			component3.text = text;
			component2.text = string.Format("CATEGORY {0}", i + 1);
		});
	}

	private void SetUpRecipeConditionList(uGUIListViewer listViewer, int recipeID)
	{
		FacilityDataTable.FacilityRecipeData data = FacilityDataTable.GetFacilityRecipeData(recipeID);
		listViewer.Show<Transform>(data.conditions.Length, delegate(int i, Transform trans)
		{
			Text[] componentsInChildren = trans.GetComponentsInChildren<Text>();
			componentsInChildren[0].text = data.conditions[i];
			componentsInChildren[1].text = (i + 1).ToString();
		});
	}

	private void SetUpFacilityParams(uGUIListViewer listViewer, Facility.FacilityParameter parameter)
	{
		List<KeyValuePair<string, int>> paramList = new List<KeyValuePair<string, int>>();
		for (int j = 0; j < parameter.Length; j++)
		{
			if (parameter[j] > 0)
			{
				paramList.Add(new KeyValuePair<string, int>(parameter.GetParameterName(j), parameter[j]));
			}
		}
		listViewer.Show<Transform>(paramList.Count, delegate(int i, Transform trans)
		{
			Text componentInChildren = trans.GetComponentInChildren<Text>();
			KeyValuePair<string, int> keyValuePair = paramList[i];
			componentInChildren.text = string.Format("{0}  +{1}", keyValuePair.Key, keyValuePair.Value);
		});
	}

	public void ButtonEvent_OK_FacilityConstruction()
	{
		Facility facility;
		if (this.FacilityMgr.GetNextDayFacilityExist(this.m_SelectingFacilityIndex))
		{
			facility = this.FacilityMgr.GetNextDayFacility(this.m_SelectingFacilityIndex);
		}
		else
		{
			facility = this.FacilityMgr.GetFacility(this.m_SelectingFacilityIndex);
		}
		long num = this.CalcNowCost();
		num += (long)FacilityDataTable.GetFacilityDefaultCost(this.m_CreatingFacility.param.typeID, true);
		if (this.FacilityMgr.GetNextDayFacilityExist(this.m_SelectingFacilityIndex))
		{
			Facility nextDayFacility = this.FacilityMgr.GetNextDayFacility(this.m_SelectingFacilityIndex);
			if (nextDayFacility)
			{
				num -= (long)FacilityDataTable.GetFacilityDefaultCost(nextDayFacility.param.typeID, true);
			}
		}
		if (num > this.nowMoney)
		{
			this.OpenDialog("資金が不足する設定は出来ません。", SystemDialog.TYPE.OK, null, null);
			return;
		}
		string messageText = string.Empty;
		if (facility)
		{
			messageText = string.Concat(new string[]
			{
				"『",
				facility.facilityName,
				"』\nを、\n『",
				this.m_CreatingFacility.defaultName,
				"』\nに設定します。\nよろしいですか？"
			});
		}
		else
		{
			messageText = "『" + this.m_CreatingFacility.defaultName + "』\nを設定します。\nよろしいですか？";
		}
		this.OpenDialog(messageText, SystemDialog.TYPE.YES_NO, delegate
		{
			Facility nextDayFacility2 = this.FacilityMgr.CreateNewFacility(this.m_CreatingFacility.param.typeID);
			this.FacilityMgr.SetNextDayFacility(this.m_SelectingFacilityIndex, nextDayFacility2);
			this.OpenDialog("『" + this.m_CreatingFacility.defaultName + "』\nを設定しました。", SystemDialog.TYPE.OK, delegate
			{
				this.ResetFacilityTypeList();
				this.ResetFacilityPowerUpList();
			}, null);
			this.m_CreatingFacility.param.typeID = 0;
			this.OpenFacilityUIConstruction();
		}, delegate
		{
		});
	}

	private bool IsOKButtonEnable()
	{
		return !(this.m_CreatingFacility == null) && FacilityDataTable.IsExistFacilityData(this.m_CreatingFacility.param.typeID, true);
	}

	private void SetOKButtonEnable(bool b)
	{
		this.m_UIButtonOK.interactable = b;
	}

	public void ButtonEvent_RESET_FacilityConstruction()
	{
		string messageText = "施設の設定をリセットします。\nよろしいですか？";
		this.OpenDialog(messageText, SystemDialog.TYPE.YES_NO, delegate
		{
			this.OpenDialog("施設の設定をリセットしました。", SystemDialog.TYPE.OK, delegate
			{
				this.ResetFacilityTypeList();
				this.ResetFacilityPowerUpList();
			}, null);
			this.FacilityMgr.ClearNextDayFacilityArray();
			this.OpenFacilityUIConstruction();
			this.m_CreatingFacility.param.typeID = 0;
			this.nowCost = this.CalcNowCost();
		}, delegate
		{
		});
	}

	private bool CheckFacilityCanBeDestroy(Facility facility)
	{
		return FacilityDataTable.GetFacilityCanBeDestroy(facility.param.typeID, true);
	}

	public void OpenDialogFacilityDestroy()
	{
		Facility facility;
		if (this.FacilityMgr.GetNextDayFacilityExist(this.m_SelectingFacilityIndex))
		{
			facility = this.FacilityMgr.GetNextDayFacility(this.m_SelectingFacilityIndex);
		}
		else
		{
			facility = this.FacilityMgr.GetFacility(this.m_SelectingFacilityIndex);
		}
		if (facility == null)
		{
			Debug.Log("[FacilityUIDestroy]撤去したい施設としてnullが指定されました");
			return;
		}
		string facilityName = facility.facilityName;
		if (this.CheckFacilityCanBeDestroy(facility))
		{
			this.OpenDialog("『" + facilityName + "』\nを撤去します。\nよろしいですか？\n※施設強化及び服装設定もリセットされます", SystemDialog.TYPE.YES_NO, delegate
			{
				this.FacilityMgr.SetNextDayFacility(this.m_SelectingFacilityIndex, null);
				this.OpenDialog("『" + facilityName + "』\nを撤去予定に設定しました。", SystemDialog.TYPE.OK, null, null);
				this.OpenFacilityUIConstruction();
			}, delegate
			{
			});
		}
		else
		{
			this.OpenDialog("『" + facilityName + "』\nは撤去出来ない施設です。", SystemDialog.TYPE.OK, null, null);
		}
	}

	public void OpenNowFacilityList(bool isOn)
	{
		SceneFacilityManagement.<OpenNowFacilityList>c__AnonStoreyB <OpenNowFacilityList>c__AnonStoreyB = new SceneFacilityManagement.<OpenNowFacilityList>c__AnonStoreyB();
		<OpenNowFacilityList>c__AnonStoreyB.$this = this;
		if (!isOn)
		{
			return;
		}
		this.m_UIFacilityDetails.gameObject.SetActive(false);
		this.m_UIFacilityPowerUpList.gameObject.SetActive(false);
		this.m_UIFacilityCostume.gameObject.SetActive(false);
		this.m_UIButtonOK.gameObject.SetActive(true);
		this.m_UIButtonRESET.gameObject.SetActive(false);
		this.m_UIButtonCANCEL.gameObject.SetActive(false);
		this.m_UIToggleVisibleFacilityInfo.gameObject.SetActive(false);
		if (this.m_UIClubStatusViewer)
		{
			this.m_UIClubStatusViewer.gameObject.SetActive(false);
		}
		this.m_UIFacilityTypeList.gameObject.SetActive(true);
		this.m_UIFacilityInfoMiniWindow.gameObject.SetActive(false);
		this.SetMoneyParamWindowVisible(false);
		this.m_UIButtonOK.onClick.RemoveAllListeners();
		this.m_UIButtonOK.onClick.AddListener(new UnityAction(this.ButtonEvent_OK_OpenMainMenu));
		this.SetOKButtonEnable(true);
		Facility[] facilityArray = this.FacilityMgr.GetFacilityArray();
		<OpenNowFacilityList>c__AnonStoreyB.enableFacilityArray = new List<Facility>();
		for (int j = 0; j < facilityArray.Length; j++)
		{
			if (facilityArray[j])
			{
				<OpenNowFacilityList>c__AnonStoreyB.enableFacilityArray.Add(facilityArray[j]);
			}
		}
		uGUIListViewer component = this.m_UIFacilityTypeList.GetComponent<uGUIListViewer>();
		component.Show<Transform>(<OpenNowFacilityList>c__AnonStoreyB.enableFacilityArray.Count, delegate(int i, Transform trans)
		{
			Text componentInChildren = trans.GetComponentInChildren<Text>();
			Toggle componentInChildren2 = trans.GetComponentInChildren<Toggle>();
			componentInChildren.text = <OpenNowFacilityList>c__AnonStoreyB.enableFacilityArray[i].facilityName;
			componentInChildren2.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				<OpenNowFacilityList>c__AnonStoreyB.ShowFacilityPowerUpList(<OpenNowFacilityList>c__AnonStoreyB.enableFacilityArray[i]);
				if (!<OpenNowFacilityList>c__AnonStoreyB.m_UIFacilityInfoMiniWindow.gameObject.activeSelf)
				{
					<OpenNowFacilityList>c__AnonStoreyB.m_UIFacilityInfoMiniWindow.gameObject.SetActive(true);
				}
				<OpenNowFacilityList>c__AnonStoreyB.m_UIFacilityInfoMiniWindow.SetFacilityInfo(<OpenNowFacilityList>c__AnonStoreyB.enableFacilityArray[i], true);
				<OpenNowFacilityList>c__AnonStoreyB.m_UIFacilityInfoMiniWindow.viewType = FacilityInfoUI.ViewType.DefaultMode;
			});
		});
	}

	public void OpenFacilityInfoList(bool isOn)
	{
		SceneFacilityManagement.<OpenFacilityInfoList>c__AnonStoreyD <OpenFacilityInfoList>c__AnonStoreyD = new SceneFacilityManagement.<OpenFacilityInfoList>c__AnonStoreyD();
		<OpenFacilityInfoList>c__AnonStoreyD.$this = this;
		if (!isOn)
		{
			return;
		}
		this.m_UIFacilityDetails.gameObject.SetActive(false);
		this.m_UIFacilityPowerUpList.gameObject.SetActive(false);
		this.m_UIFacilityCostume.gameObject.SetActive(false);
		this.m_UIButtonOK.gameObject.SetActive(true);
		this.m_UIButtonRESET.gameObject.SetActive(false);
		this.m_UIButtonCANCEL.gameObject.SetActive(false);
		this.m_UIToggleVisibleFacilityInfo.gameObject.SetActive(false);
		if (this.m_UIClubStatusViewer)
		{
			this.m_UIClubStatusViewer.gameObject.SetActive(false);
		}
		this.m_UIFacilityTypeList.gameObject.SetActive(true);
		this.m_UIFacilityInfoMiniWindow.gameObject.SetActive(false);
		this.SetMoneyParamWindowVisible(false);
		this.m_UIButtonOK.onClick.RemoveAllListeners();
		this.m_UIButtonOK.onClick.AddListener(new UnityAction(this.ButtonEvent_OK_OpenMainMenu));
		this.SetOKButtonEnable(true);
		Facility.FacilityStatus[] facilityStatusArray = FacilityDataTable.GetFacilityStatusArray(true);
		<OpenFacilityInfoList>c__AnonStoreyD.enableFacilityArray = new List<Facility.FacilityStatus>();
		for (int j = 0; j < facilityStatusArray.Length; j++)
		{
			FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.GetFacilityDefaultData(facilityStatusArray[j].typeID, true);
			if (!facilityDefaultData.isDefaultPlace)
			{
				if (GameMain.Instance.CharacterMgr.status.lockNTRPlay)
				{
					if (!facilityDefaultData.isEnableNTR)
					{
						goto IL_18C;
					}
				}
				else if (facilityDefaultData.isOnlyNTR)
				{
					goto IL_18C;
				}
				<OpenFacilityInfoList>c__AnonStoreyD.enableFacilityArray.Add(facilityStatusArray[j]);
			}
			IL_18C:;
		}
		uGUIListViewer component = this.m_UIFacilityTypeList.GetComponent<uGUIListViewer>();
		component.Show<Transform>(<OpenFacilityInfoList>c__AnonStoreyD.enableFacilityArray.Count, delegate(int i, Transform trans)
		{
			Text componentInChildren = trans.GetComponentInChildren<Text>();
			Toggle componentInChildren2 = trans.GetComponentInChildren<Toggle>();
			componentInChildren.text = <OpenFacilityInfoList>c__AnonStoreyD.enableFacilityArray[i].name;
			componentInChildren2.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				<OpenFacilityInfoList>c__AnonStoreyD.m_CreatingFacility.Init(<OpenFacilityInfoList>c__AnonStoreyD.enableFacilityArray[i].typeID);
				<OpenFacilityInfoList>c__AnonStoreyD.ShowFacilityPowerUpList(<OpenFacilityInfoList>c__AnonStoreyD.m_CreatingFacility);
				if (!<OpenFacilityInfoList>c__AnonStoreyD.m_UIFacilityInfoMiniWindow.gameObject.activeSelf)
				{
					<OpenFacilityInfoList>c__AnonStoreyD.m_UIFacilityInfoMiniWindow.gameObject.SetActive(true);
				}
				<OpenFacilityInfoList>c__AnonStoreyD.m_UIFacilityInfoMiniWindow.SetFacilityInfo(<OpenFacilityInfoList>c__AnonStoreyD.m_CreatingFacility, true);
				<OpenFacilityInfoList>c__AnonStoreyD.m_UIFacilityInfoMiniWindow.viewType = FacilityInfoUI.ViewType.ConstructMode;
			});
		});
	}

	public void OpenFacilityCostumeSettingWindow(bool isOn)
	{
		if (!isOn)
		{
			return;
		}
		this.OpenFacilityCostumeSettingWindow();
	}

	public void OpenFacilityCostumeSettingWindow()
	{
		SceneFacilityManagement.<OpenFacilityCostumeSettingWindow>c__AnonStoreyF <OpenFacilityCostumeSettingWindow>c__AnonStoreyF = new SceneFacilityManagement.<OpenFacilityCostumeSettingWindow>c__AnonStoreyF();
		<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.$this = this;
		this.nowCost = this.CalcNowCost();
		this.m_UIFacilityDetails.gameObject.SetActive(false);
		this.m_UIFacilityPowerUpList.gameObject.SetActive(false);
		this.m_UIButtonOK.gameObject.SetActive(true);
		this.m_UIButtonRESET.gameObject.SetActive(false);
		this.m_UIButtonCANCEL.gameObject.SetActive(false);
		this.m_UIToggleVisibleFacilityInfo.gameObject.SetActive(false);
		if (this.m_UIClubStatusViewer)
		{
			this.m_UIClubStatusViewer.gameObject.SetActive(false);
		}
		this.m_UIFacilityTypeList.gameObject.SetActive(true);
		this.m_UIFacilityInfoMiniWindow.gameObject.SetActive(false);
		this.SetMoneyParamWindowVisible(false);
		this.m_UIButtonOK.onClick.RemoveAllListeners();
		this.m_UIButtonOK.onClick.AddListener(new UnityAction(this.ButtonEvent_OK_OpenMainMenu));
		this.SetOKButtonEnable(true);
		Facility[] facilityArray = this.FacilityMgr.GetFacilityArray();
		<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.enableFacilityArray = new List<Facility>();
		for (int j = 0; j < facilityArray.Length; j++)
		{
			Facility facility = null;
			if (this.FacilityMgr.GetNextDayFacilityExist(j))
			{
				facility = this.FacilityMgr.GetNextDayFacility(j);
			}
			else if (facilityArray[j])
			{
				facility = facilityArray[j];
			}
			if (facility != null)
			{
				<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.enableFacilityArray.Add(facility);
			}
		}
		uGUIListViewer component = this.m_UIFacilityTypeList.GetComponent<uGUIListViewer>();
		<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.tempSelectFacility = GameMain.Instance.FacilityMgr.tempSelectFacility;
		component.Show<Transform>(<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.enableFacilityArray.Count, delegate(int i, Transform trans)
		{
			Text componentInChildren = trans.GetComponentInChildren<Text>();
			Toggle componentInChildren2 = trans.GetComponentInChildren<Toggle>();
			componentInChildren.text = <OpenFacilityCostumeSettingWindow>c__AnonStoreyF.enableFacilityArray[i].facilityName;
			componentInChildren2.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.OpenCostumeSettingWindow(<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.enableFacilityArray[i]);
				if (!<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.m_UIFacilityInfoMiniWindow.gameObject.activeSelf)
				{
					<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.m_UIFacilityInfoMiniWindow.gameObject.SetActive(true);
				}
				<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.m_UIFacilityInfoMiniWindow.SetFacilityInfo(<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.enableFacilityArray[i], true);
				<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.m_UIFacilityInfoMiniWindow.viewType = FacilityInfoUI.ViewType.DefaultMode;
			});
			if (<OpenFacilityCostumeSettingWindow>c__AnonStoreyF.tempSelectFacility != null && <OpenFacilityCostumeSettingWindow>c__AnonStoreyF.enableFacilityArray[i] == <OpenFacilityCostumeSettingWindow>c__AnonStoreyF.tempSelectFacility)
			{
				componentInChildren2.isOn = true;
			}
		});
	}

	private void OpenCostumeSettingWindow(Facility facility)
	{
		SceneFacilityManagement.m_CostumeEditFacilityIndex = GameMain.Instance.FacilityMgr.GetFacilityIndex(facility);
		GameMain.Instance.FacilityMgr.tempSelectFacility = facility;
		this.m_UIFacilityCostume.gameObject.SetActive(true);
		Facility.CostumeType typeCostume = facility.typeCostume;
		Toggle[] componentsInChildren = this.m_UIFacilityCostume.GetComponentsInChildren<Toggle>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			int num = i;
			Toggle toggle = componentsInChildren[num];
			Facility.CostumeType toggleType = (Facility.CostumeType)num;
			toggle.onValueChanged.RemoveAllListeners();
			toggle.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				facility.typeCostume = toggleType;
				this.m_UIButtonBeginCostumeSetting.interactable = (toggleType == Facility.CostumeType.Edit);
				Transform transform = this.m_UIFacilityCostume.Find("image thumbnail");
				if (transform != null)
				{
					RawImage component = transform.GetComponent<RawImage>();
					bool flag = facility.IsExistEditCostumeThumbnail();
					if (toggleType == Facility.CostumeType.Edit)
					{
						flag = facility.IsExistEditCostumeThumbnail();
					}
					else if (toggleType == Facility.CostumeType.Default)
					{
						flag = !string.IsNullOrEmpty(facility.defaultCostumeThumbnailName);
					}
					bool flag2 = (toggleType == Facility.CostumeType.Edit || toggleType == Facility.CostumeType.Default) && flag;
					if (transform.gameObject.activeSelf != flag2)
					{
						transform.gameObject.SetActive(flag2);
					}
					if (component.texture != null && string.IsNullOrEmpty(component.texture.name))
					{
						try
						{
							UnityEngine.Object.DestroyImmediate(component.texture, false);
						}
						catch
						{
							component.texture = null;
						}
					}
					if (flag2)
					{
						Texture2D texture = null;
						if (toggleType == Facility.CostumeType.Edit)
						{
							texture = facility.GetEditCostumeThumbnail();
						}
						else if (toggleType == Facility.CostumeType.Default)
						{
							texture = facility.GetDefaultCostumeThumbnail();
						}
						component.texture = texture;
					}
					else
					{
						component.texture = null;
					}
				}
				else
				{
					NDebug.Assert("メイドのサムネイル表示オブジェクトがありません", false);
				}
			});
		}
		for (int j = 0; j < componentsInChildren.Length; j++)
		{
			Toggle toggle2 = componentsInChildren[j];
			Facility.CostumeType costumeType = (Facility.CostumeType)j;
			toggle2.isOn = (typeCostume == costumeType);
			toggle2.onValueChanged.Invoke(toggle2.isOn);
		}
		this.m_UIButtonBeginCostumeSetting.interactable = (typeCostume == Facility.CostumeType.Edit);
	}

	public void ButtonEventBeginCostumeSetting()
	{
		GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate
		{
			this.UpdateMaidPropOfCostume(SceneFacilityManagement.m_CostumeEditFacilityIndex, delegate
			{
				ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
				scriptMgr.adv_kag.JumpLabel(this.m_strScriptEditLabel);
				scriptMgr.adv_kag.Exec();
			});
		}, true, default(Color));
	}

	public void ButtonEventSceneClose()
	{
		if (string.IsNullOrEmpty(this.m_strScriptReturnLabel))
		{
			Debug.Log("[SceneFacilityManagement]シーン終了時に飛ぶラベルがありませんでした");
			return;
		}
		GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate
		{
			ScriptManager scriptMgr = GameMain.Instance.ScriptMgr;
			scriptMgr.adv_kag.JumpLabel(this.m_strScriptReturnLabel);
			scriptMgr.adv_kag.Exec();
		}, true, default(Color));
	}

	private void GetTagBackup()
	{
		Dictionary<string, string> tag_backup = GameMain.Instance.ScriptMgr.adv_kag.tag_backup;
		string a;
		if (tag_backup != null && tag_backup.TryGetValue("name", out a) && a == "SceneFacilityManagement")
		{
			if (!tag_backup.TryGetValue("label", out this.m_strScriptReturnLabel))
			{
				this.m_strScriptReturnLabel = "*施設の管理画面を抜ける";
			}
			if (!tag_backup.TryGetValue("label_edit", out this.m_strScriptEditLabel))
			{
				this.m_strScriptEditLabel = "*施設のコスチュームのエディットを開く";
			}
			if (tag_backup.ContainsKey("update_costume"))
			{
				this.UpdateFacilityCostume(SceneFacilityManagement.m_CostumeEditFacilityIndex);
				this.OpenFacilityCostumeSettingWindow();
				this.OpenCostumeSettingWindow(GameMain.Instance.FacilityMgr.tempSelectFacility);
			}
			else
			{
				SceneFacilityManagement.m_CostumeEditFacilityIndex = -1;
				GameMain.Instance.FacilityMgr.tempSelectFacility = null;
			}
		}
	}

	private void UpdateFacilityCostume(int facilityIndex)
	{
		FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
		Facility facility = facilityMgr.GetNextDayFacility(facilityIndex);
		if (facility == null)
		{
			facility = facilityMgr.GetFacility(facilityIndex);
			if (facility == null)
			{
				Debug.LogWarning(string.Format("[SceneFacilityManagement]インデックス[{0}]番目の施設は存在しない", facilityIndex));
				return;
			}
		}
		Maid maidLeader = this.GetMaidLeader();
		if (maidLeader == null)
		{
			NDebug.Warning("メイド長が見つかりません");
			return;
		}
		facility.UpdateEditCostumeToMaidCostume(maidLeader);
		MPN[] facilityCostumeEnableMPN = FacilityDataTable.GetFacilityCostumeEnableMPN();
		for (int i = 0; i < facilityCostumeEnableMPN.Length; i++)
		{
			maidLeader.ResetProp(facilityCostumeEnableMPN[i], true);
		}
		maidLeader.AllProcPropSeqStart();
		maidLeader.Visible = false;
		Debug.Log(string.Format("[SceneFacilityManagement]施設「{0}」の指定コスチュームの更新終了", facility.facilityName));
	}

	private void UpdateMaidPropOfCostume(int facilityIndex, Action callback = null)
	{
		FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
		Facility facility = facilityMgr.GetNextDayFacility(facilityIndex);
		if (facility == null)
		{
			facility = facilityMgr.GetFacility(facilityIndex);
			if (facility == null)
			{
				Debug.LogWarning(string.Format("[SceneFacilityManagement]インデックス[{0}]番目の施設は存在しない", facilityIndex));
				if (callback != null)
				{
					callback();
				}
				return;
			}
		}
		Maid maid = this.GetMaidLeader();
		if (maid == null)
		{
			NDebug.Warning("メイド長が見つかりません");
			if (callback != null)
			{
				callback();
			}
			return;
		}
		GameMain.Instance.CharacterMgr.SetActiveMaid(maid, 0);
		maid.Visible = true;
		maid.AllProcPropSeqStart();
		base.StartCoroutine(this.coroutine_WaitmaidPropBusy(maid, delegate
		{
			facility.UpdateMaidCostumeToEditCostume(maid, true);
			maid.AllProcPropSeqStart();
			this.StartCoroutine(this.coroutine_WaitmaidPropBusy(maid, callback));
		}));
	}

	private IEnumerator coroutine_WaitmaidPropBusy(Maid maid, Action callback)
	{
		while (maid.IsBusy)
		{
			yield return null;
		}
		if (callback != null)
		{
			callback();
		}
		yield break;
	}

	private Maid GetMaidLeader()
	{
		Maid maid = null;
		CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
		for (int i = 0; i < characterMgr.GetMaidCount(); i++)
		{
			Maid maid2 = characterMgr.GetMaid(i);
			if (maid2 != null && maid2.status.leader)
			{
				maid = maid2;
				break;
			}
		}
		if (maid == null)
		{
			for (int j = 0; j < characterMgr.GetStockMaidCount(); j++)
			{
				Maid stockMaid = characterMgr.GetStockMaid(j);
				if (stockMaid != null && stockMaid.status.leader)
				{
					maid = stockMaid;
					break;
				}
			}
		}
		if (maid == null)
		{
			for (int k = 0; k < characterMgr.GetMaidCount(); k++)
			{
				Maid maid3 = characterMgr.GetMaid(k);
				if (maid3 != null)
				{
					maid = maid3;
					break;
				}
			}
		}
		if (maid == null)
		{
			for (int l = 0; l < characterMgr.GetStockMaidCount(); l++)
			{
				Maid stockMaid2 = characterMgr.GetStockMaid(l);
				if (stockMaid2 != null)
				{
					maid = stockMaid2;
					break;
				}
			}
		}
		return maid;
	}

	private FacilityManager m_FacilityMgr;

	[SerializeField]
	private Text m_UITextNowMoney;

	[SerializeField]
	private Text m_UITextNowCost;

	[SerializeField]
	private RectTransform m_UIMainMenu;

	[SerializeField]
	private RectTransform m_UIFacilityDetails;

	[SerializeField]
	private RectTransform m_UIFacilityTypeList;

	[SerializeField]
	private RectTransform m_UIFacilityCostume;

	[SerializeField]
	private RectTransform m_UIFacilityPowerUpList;

	[SerializeField]
	private FacilityInfoUI m_UIFacilityInfoConstruction;

	[SerializeField]
	private FacilityInfoUI m_UIFacilityInfoMiniWindow;

	[SerializeField]
	private Button m_UIButtonOK;

	[SerializeField]
	private Button m_UIButtonCANCEL;

	[SerializeField]
	private Button m_UIButtonRESET;

	[SerializeField]
	private Button m_UIButtonDestroyFacility;

	[SerializeField]
	private Toggle m_UIToggleVisibleFacilityInfo;

	[SerializeField]
	private Button m_UIButtonBeginCostumeSetting;

	[SerializeField]
	private StatusViewer m_UIClubStatusViewer;

	[SerializeField]
	private bool m_EnableSetUpCameraAndBG = true;

	private Facility m_CreatingFacility;

	private int m_SelectingFacilityIndex;

	private static int m_CostumeEditFacilityIndex = -1;

	[SerializeField]
	private StartDestroyEventObject m_StartDestroyEventObject;

	private string m_PlayBGM = "BGM009.ogg";

	private long m_NowCost;

	private string m_strScriptReturnLabel = string.Empty;

	private string m_strScriptEditLabel = string.Empty;

	private class FacilityDetailsUI : MonoBehaviour
	{
		private void Awake()
		{
			this.m_FacilityInfoUI = base.GetComponent<FacilityInfoUI>();
			this.m_Toggle = base.GetComponent<Toggle>();
			this.m_Button = base.GetComponentInChildren<Button>();
			this.m_ChangeImage = base.transform.Find("Image Change").gameObject;
			this.m_DeleteImage = base.transform.Find("Image Delete").gameObject;
			this.m_ParentInfo = base.transform.Find("Parent Info").gameObject;
			this.m_ChangeImage.SetActive(false);
			this.m_DeleteImage.SetActive(false);
			this.m_ParentInfo.SetActive(false);
			InputField facilityNameUI = this.m_FacilityInfoUI.textFacilityName;
			facilityNameUI.onEndEdit.RemoveAllListeners();
			facilityNameUI.onEndEdit.AddListener(delegate(string value)
			{
				Facility facility = this.m_FacilityInfoUI.facility;
				value = value.Trim();
				if (string.IsNullOrEmpty(value))
				{
					facilityNameUI.text = facility.facilityName;
					return;
				}
				facility.facilityName = value;
				facilityNameUI.enabled = false;
			});
			this.m_Button.onClick.AddListener(delegate()
			{
				facilityNameUI.enabled = true;
				facilityNameUI.interactable = true;
				facilityNameUI.ActivateInputField();
			});
		}

		private void Start()
		{
			InputField textFacilityName = this.m_FacilityInfoUI.textFacilityName;
			textFacilityName.interactable = false;
		}

		public FacilityInfoUI m_FacilityInfoUI;

		public Toggle m_Toggle;

		public Button m_Button;

		public GameObject m_ChangeImage;

		public GameObject m_DeleteImage;

		public GameObject m_ParentInfo;
	}
}
