using System;
using UnityEngine;

public class WindowPartsSpotLight : MonoBehaviour
{
	public void Awake()
	{
		this.partsTransForm.onChangeAxisVisibleType.Add(new Action(this.OnChangeAxisVisibleType));
		this.spotAngleInput.onChangeValue.Add(delegate(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
		{
			if (this.light == null)
			{
				return;
			}
			this.spotAngle = (int)val;
			this.light.spotAngle = val;
		});
		this.intensityInput.onChangeValue.Add(delegate(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
		{
			if (this.light == null)
			{
				return;
			}
			this.light.intensity = val;
			this.intensity = val;
		});
		this.rangeInput.onChangeValue.Add(delegate(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val)
		{
			if (this.light == null)
			{
				return;
			}
			this.light.range = val;
			this.range = val;
		});
		this.colorInput.onChangeValue.Add(delegate(WindowPartsInputColorrPalette input_object, Color color)
		{
			if (this.light == null)
			{
				return;
			}
			this.light.color = color;
			this.color = color;
			this.updateButtonFunction();
		});
	}

	public void Init(Light light, PhotoTransTargetObject targetObject, Action updateButtonFunction)
	{
		this.light = light;
		this.targetObject = targetObject;
		this.updateButtonFunction = updateButtonFunction;
		this.partsTransForm.SetObject(targetObject.obj, new Vector3(0f, 1f, 0f), Vector3.zero, Vector3.one);
		this.spotAngle = (int)light.spotAngle;
		this.intensity = light.intensity;
		this.range = light.range;
		this.color = light.color;
		this.UpdateGui();
	}

	public void UpdateGui()
	{
		this.OnChangeAxisVisibleType();
		PhotoSliderAndInput sliderAndInput = this.spotAngleInput.GetSliderAndInput("str");
		PhotoSliderAndInput sliderAndInput2 = this.intensityInput.GetSliderAndInput("str");
		PhotoSliderAndInput sliderAndInput3 = this.rangeInput.GetSliderAndInput("str");
		sliderAndInput.value = (float)this.spotAngle;
		sliderAndInput2.value = this.intensity;
		sliderAndInput3.value = this.range;
		this.colorInput.value = this.color;
	}

	protected void OnChangeAxisVisibleType()
	{
		if (this.targetObject == null)
		{
			return;
		}
		WindowPartsTransform.AxisVisibleType axis_visible_type = this.partsTransForm.axis_visible_type;
		PhotoTransTargetObject photoTransTargetObject = this.targetObject;
		if (axis_visible_type == WindowPartsTransform.AxisVisibleType.UnVisible || photoTransTargetObject == null || photoTransTargetObject.obj == null)
		{
			if (photoTransTargetObject.axis_obj != null)
			{
				photoTransTargetObject.axis_obj.Visible = false;
			}
			if (photoTransTargetObject.rotate_obj != null)
			{
				photoTransTargetObject.rotate_obj.Visible = false;
			}
		}
		else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Position)
		{
			if (photoTransTargetObject.axis_obj != null)
			{
				photoTransTargetObject.axis_obj.Visible = true;
			}
			if (photoTransTargetObject.rotate_obj != null)
			{
				photoTransTargetObject.rotate_obj.Visible = false;
			}
		}
		else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Rotate)
		{
			if (photoTransTargetObject.axis_obj != null)
			{
				photoTransTargetObject.axis_obj.Visible = false;
			}
			if (photoTransTargetObject.rotate_obj != null)
			{
				photoTransTargetObject.rotate_obj.Visible = true;
			}
		}
	}

	[SerializeField]
	private WindowPartsTransform partsTransForm;

	[SerializeField]
	private WindowPartsInputSliderSet spotAngleInput;

	[SerializeField]
	private WindowPartsInputSliderSet intensityInput;

	[SerializeField]
	private WindowPartsInputSliderSet rangeInput;

	[SerializeField]
	private WindowPartsInputColorrPalette colorInput;

	private Light light;

	private PhotoTransTargetObject targetObject;

	private Action updateButtonFunction;

	private int spotAngle;

	private float intensity;

	private float range;

	private Color color;
}
