using System;
using UnityEngine;

namespace Leap.Unity
{
	public class SceneSettings : MonoBehaviour
	{
		private void Reset()
		{
			this._shadowDistance.Value = QualitySettings.shadowDistance;
			this._gravity.Value = Physics.gravity;
			this._sleepThreshold.Value = Physics.sleepThreshold;
		}

		private void Awake()
		{
			if (this._shadowDistance.Override)
			{
				QualitySettings.shadowDistance = this._shadowDistance.Value;
			}
			if (this._gravity.Override)
			{
				Physics.gravity = this._gravity.Value;
			}
			if (this._sleepThreshold.Override)
			{
				Physics.sleepThreshold = this._sleepThreshold.Value;
			}
		}

		[SerializeField]
		private SceneSettings.ToggleFloat _shadowDistance = new SceneSettings.ToggleFloat();

		[SerializeField]
		private SceneSettings.ToggleVector3 _gravity = new SceneSettings.ToggleVector3();

		[SerializeField]
		private SceneSettings.ToggleFloat _sleepThreshold = new SceneSettings.ToggleFloat();

		public class ToggleValue<T>
		{
			public bool Override;

			public T Value;
		}

		[Serializable]
		public class ToggleFloat : SceneSettings.ToggleValue<float>
		{
		}

		[Serializable]
		public class ToggleVector3 : SceneSettings.ToggleValue<Vector3>
		{
		}
	}
}
