using System;
using MaidStatus;
using UnityEngine;

namespace Kasizuki
{
	public class MaidPropensitysCtrl : NGUIWindow, IStatusCtrl<Maid>
	{
		protected override void Awake()
		{
			base.Awake();
			this.m_ListViewer = base.GetComponent<uGUIListViewer>();
			this.m_IsAwaked = true;
		}

		public void SetData(Maid maid)
		{
			if (maid == null)
			{
				NDebug.Warning("情報を表示するメイドにnullが指定されました。");
				return;
			}
			this.m_TargetMaid = maid;
			this.UpdateNGUILabel();
		}

		public void UpdateMaidInfo()
		{
			if (this.m_TargetMaid == null)
			{
				NDebug.Warning("情報を表示するメイドがnullでした。SetMaid( Maid )関数で、情報を表示するメイドを指定してください。");
				return;
			}
			this.UpdateNGUILabel();
		}

		private void UpdateNGUILabel()
		{
			if (!this.m_IsAwaked)
			{
				base.gameObject.SetActive(true);
			}
			Maid targetMaid = this.m_TargetMaid;
			Status status = targetMaid.status;
			Propensity.Data[] propensitys = status.propensitys.GetValueArray();
			this.m_ListViewer.Show<Transform>(propensitys.Length, delegate(int index, Transform item)
			{
				Propensity.Data data = propensitys[index];
				UILabel componentInChildren2 = item.GetComponentInChildren<UILabel>();
				componentInChildren2.text = data.drawName;
			});
			UIGrid component = this.m_ListViewer.parentItemArea.GetComponent<UIGrid>();
			component.enabled = true;
			component.Reposition();
			UIScrollView componentInChildren = base.GetComponentInChildren<UIScrollView>();
			componentInChildren.ResetPosition();
		}

		private uGUIListViewer m_ListViewer;

		private Maid m_TargetMaid;

		private bool m_IsAwaked;
	}
}
