using System;
using UnityEngine;

namespace Leap.Unity
{
	[Serializable]
	public class EyeType
	{
		public EyeType(EyeType.OrderType type)
		{
			this._orderType = type;
		}

		public EyeType.OrderType Type
		{
			get
			{
				return this._orderType;
			}
		}

		public bool IsLeftEye
		{
			get
			{
				if (!this._hasBegun)
				{
					throw new Exception("Cannot call IsLeftEye or IsRightEye before BeginCamera has been called!");
				}
				switch (this._orderType)
				{
				case EyeType.OrderType.LEFT:
					return true;
				case EyeType.OrderType.RIGHT:
					return false;
				case EyeType.OrderType.CENTER:
					return this._isOnFirst;
				default:
					throw new Exception("Unexpected order type " + this._orderType);
				}
			}
		}

		public bool IsRightEye
		{
			get
			{
				return !this.IsLeftEye;
			}
		}

		public void BeginCamera()
		{
			if (!this._hasBegun)
			{
				this._isOnFirst = true;
				this._hasBegun = true;
			}
			else
			{
				this._isOnFirst = !this._isOnFirst;
			}
		}

		public void Reset()
		{
			this._hasBegun = false;
		}

		private const string TARGET_EYE_PROPERTY_NAME = "m_TargetEye";

		private const int TARGET_EYE_LEFT_INDEX = 1;

		private const int TARGET_EYE_RIGHT_INDEX = 2;

		private const int TARGET_EYE_CENTER_INDEX = 3;

		[SerializeField]
		private EyeType.OrderType _orderType = EyeType.OrderType.LEFT;

		private bool _isOnFirst;

		private bool _hasBegun;

		public enum OrderType
		{
			LEFT = 1,
			RIGHT,
			CENTER
		}
	}
}
