using System;
using UnityEngine;
using UnityEngine.UI;

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

	public void Show()
	{
		this.SetupFacilityListButton();
	}

	private void SetupFacilityListButton()
	{
		Facility[] facilityArray = this.FacilityMgr.GetFacilityArray();
		this.m_uGUIListViewer.Show<Transform>(facilityArray.Length, delegate(int i, Transform trans)
		{
			Facility facility = facilityArray[i];
			if (!facility)
			{
				UnityEngine.Object.Destroy(trans.gameObject);
				return;
			}
			Facility.FacilityStatus param = facility.param;
			int typeID = param.typeID;
			string name = param.name;
			Text componentInChildren = trans.GetComponentInChildren<Text>();
			Toggle componentInChildren2 = trans.GetComponentInChildren<Toggle>();
			componentInChildren.text = name;
			componentInChildren2.onValueChanged.RemoveAllListeners();
			componentInChildren2.onValueChanged.AddListener(delegate(bool isOn)
			{
				if (!isOn)
				{
					return;
				}
				<SetupFacilityListButton>c__AnonStorey.m_Manager.OpenFacilityUIPowerUpList(facility);
				<SetupFacilityListButton>c__AnonStorey.m_Manager.UpdateFacilityInfo(facility);
			});
		});
	}

	[SerializeField]
	private FacilityPowerUpManager m_Manager;

	[SerializeField]
	private uGUIListViewer m_uGUIListViewer;

	private FacilityManager m_FacilityMgr;
}
