using System;
using UnityEngine;
using UnityEngine.UI;

public class FacilityUIPreviewParams : MonoBehaviour
{
	public void Show(int id)
	{
		this.SetupRecipeDefaultEffect(id);
	}

	public void UpdateAdditionalParams(Facility.FacilityParameter parameter)
	{
		this.SetupRecipeAdditionalEffect(parameter);
	}

	public void UpdateAdditionalParamsComparison(Facility.FacilityParameter previous, Facility.FacilityParameter next)
	{
		this.SetupRecipeAdditionalEffectComparison(previous, next);
	}

	public void ResetDefaultParam()
	{
		this.m_ParentDefaultEffect.ResetList();
	}

	public void ResetAdditionalParam()
	{
		this.m_ParentAdditionalEffect.ResetList();
	}

	private void SetupRecipeDefaultEffect(int id)
	{
		Facility.PowerUpRecipe recipe = FacilityDataTable.GetFacilityPowerUpRecipe(id);
		this.m_ParentDefaultEffect.Show<Text>(recipe.parameter.Length, delegate(int i, Text text)
		{
			Facility.FacilityParameter parameter = recipe.parameter;
			int num = parameter[i];
			if (num <= 0)
			{
				text.gameObject.SetActive(false);
			}
			string parameterName = parameter.GetParameterName(i);
			text.text = string.Format("{0}  +{1}", parameterName, num);
			Image componentInChildren = text.GetComponentInChildren<Image>();
			componentInChildren.enabled = (i % 2 == 0);
		});
	}

	private void SetupRecipeAdditionalEffect(Facility.FacilityParameter parameter)
	{
		int itemCount = 0;
		this.m_ParentAdditionalEffect.Show<Text>(parameter.Length, delegate(int i, Text text)
		{
			if (parameter[i] <= 0)
			{
				text.gameObject.SetActive(false);
				return;
			}
			itemCount++;
			string parameterName = parameter.GetParameterName(i);
			int num = parameter[i];
			text.text = string.Format("{0}  +{1}", parameterName, num);
			Image componentInChildren = text.GetComponentInChildren<Image>();
			componentInChildren.enabled = (itemCount % 2 == 1);
		});
	}

	private void SetupRecipeAdditionalEffectComparison(Facility.FacilityParameter previous, Facility.FacilityParameter next)
	{
		Facility.FacilityParameter compatison = next - previous;
		int itemCount = 0;
		this.m_ParentAdditionalEffect.Show<Text>(next.Length, delegate(int i, Text text)
		{
			if (previous[i] == 0 && next[i] == 0)
			{
				text.gameObject.SetActive(false);
				return;
			}
			itemCount++;
			string parameterName = next.GetParameterName(i);
			int num = next[i];
			text.text = string.Format("{0}  +{1}", parameterName, num);
			Image componentInChildren = text.GetComponentInChildren<Image>();
			componentInChildren.enabled = (itemCount % 2 == 1);
			if (compatison[i] == 0)
			{
				text.color = Color.white;
			}
			else if (compatison[i] < 0)
			{
				text.color = Color.magenta;
			}
			else if (compatison[i] > 0)
			{
				text.color = Color.cyan;
			}
		});
	}

	[SerializeField]
	private uGUIListViewer m_ParentDefaultEffect;

	[SerializeField]
	private uGUIListViewer m_ParentAdditionalEffect;
}
