using System;
using UnityEngine;

public class ONSPAudioSource : MonoBehaviour
{
	public bool EnableSpatialization
	{
		get
		{
			return this.enableSpatialization;
		}
		set
		{
			this.enableSpatialization = value;
		}
	}

	public float Gain
	{
		get
		{
			return this.gain;
		}
		set
		{
			this.gain = Mathf.Clamp(value, 0f, 24f);
		}
	}

	public bool UseInvSqr
	{
		get
		{
			return this.useInvSqr;
		}
		set
		{
			this.useInvSqr = value;
		}
	}

	public float Near
	{
		get
		{
			return this.near;
		}
		set
		{
			this.near = Mathf.Clamp(value, 0f, 1000000f);
		}
	}

	public float Far
	{
		get
		{
			return this.far;
		}
		set
		{
			this.far = Mathf.Clamp(value, 0f, 1000000f);
		}
	}

	public bool DisableRfl
	{
		get
		{
			return this.disableRfl;
		}
		set
		{
			this.disableRfl = value;
		}
	}

	private void Awake()
	{
		AudioSource component = base.GetComponent<AudioSource>();
		this.SetParameters(ref component);
	}

	private void Start()
	{
	}

	private void Update()
	{
		AudioSource component = base.GetComponent<AudioSource>();
		this.SetParameters(ref component);
	}

	public void SetParameters(ref AudioSource source)
	{
		if (!Application.isPlaying || AudioListener.pause || !source.isPlaying || !source.isActiveAndEnabled)
		{
			source.spatialize = false;
			return;
		}
		source.spatialize = this.enableSpatialization;
		source.SetSpatializerFloat(0, this.gain);
		if (this.useInvSqr)
		{
			source.SetSpatializerFloat(1, 1f);
		}
		else
		{
			source.SetSpatializerFloat(1, 0f);
		}
		source.SetSpatializerFloat(2, this.near);
		source.SetSpatializerFloat(3, this.far);
		if (this.disableRfl)
		{
			source.SetSpatializerFloat(4, 1f);
		}
		else
		{
			source.SetSpatializerFloat(4, 0f);
		}
	}

	[SerializeField]
	private bool enableSpatialization = true;

	[SerializeField]
	private float gain;

	[SerializeField]
	private bool useInvSqr;

	[SerializeField]
	private float near = 1f;

	[SerializeField]
	private float far = 10f;

	[SerializeField]
	private bool disableRfl;
}
