using System;
using UnityEngine;

namespace LOS
{
	// Token: 0x02000103 RID: 259
	[ExecuteInEditMode]
	[RequireComponent(typeof(Camera))]
	[AddComponentMenu("Line of Sight/LOS Buffer Storage")]
	public class LOSBufferStorage : MonoBehaviour
	{
		// Token: 0x17000028 RID: 40
		// (get) Token: 0x060015E0 RID: 5600 RVA: 0x0019C45F File Offset: 0x0019A65F
		public RenderTexture BufferTexture
		{
			get
			{
				return this.m_Buffer;
			}
		}

		// Token: 0x060015E1 RID: 5601 RVA: 0x0019C467 File Offset: 0x0019A667
		private void OnEnable()
		{
		}

		// Token: 0x060015E2 RID: 5602 RVA: 0x0019C469 File Offset: 0x0019A669
		private void OnDisable()
		{
			this.DestroyBuffer();
		}

		// Token: 0x060015E3 RID: 5603 RVA: 0x0019C474 File Offset: 0x0019A674
		private void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			if (this.m_Buffer == null || this.m_Buffer.width != source.width || this.m_Buffer.height != source.height || this.m_Buffer.depth != source.depth)
			{
				this.DestroyBuffer();
				this.m_Buffer = new RenderTexture(source.width, source.height, source.depth);
				this.m_Buffer.hideFlags = HideFlags.HideAndDontSave;
			}
			Graphics.Blit(source, this.m_Buffer);
			Graphics.Blit(source, destination);
		}

		// Token: 0x060015E4 RID: 5604 RVA: 0x0019C50B File Offset: 0x0019A70B
		private void DestroyBuffer()
		{
			if (this.m_Buffer != null)
			{
				Object.DestroyImmediate(this.m_Buffer);
				this.m_Buffer = null;
			}
		}

		// Token: 0x04002614 RID: 9748
		private RenderTexture m_Buffer;
	}
}
