using System;
using System.Collections.Generic;
using UnityEngine;

namespace LOS
{
	// Token: 0x02000108 RID: 264
	public class LOSManager
	{
		// Token: 0x06001603 RID: 5635 RVA: 0x0019D056 File Offset: 0x0019B256
		private LOSManager()
		{
		}

		// Token: 0x1700002B RID: 43
		// (get) Token: 0x06001604 RID: 5636 RVA: 0x0019D084 File Offset: 0x0019B284
		public static LOSManager Instance
		{
			get
			{
				if (LOSManager.m_Instance == null)
				{
					LOSManager.m_Instance = new LOSManager();
				}
				return LOSManager.m_Instance;
			}
		}

		// Token: 0x1700002C RID: 44
		// (get) Token: 0x06001605 RID: 5637 RVA: 0x0019D09C File Offset: 0x0019B29C
		public List<LOSSource> LOSSources
		{
			get
			{
				return this.m_LOSSources;
			}
		}

		// Token: 0x1700002D RID: 45
		// (get) Token: 0x06001606 RID: 5638 RVA: 0x0019D0A4 File Offset: 0x0019B2A4
		public int ActiveCameraCount
		{
			get
			{
				int num = 0;
				using (List<LOSSource>.Enumerator enumerator = this.m_LOSSources.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						if (((ILOSSource)enumerator.Current).IsVisible)
						{
							num++;
						}
					}
				}
				return num;
			}
		}

		// Token: 0x1700002E RID: 46
		// (get) Token: 0x06001607 RID: 5639 RVA: 0x0019D100 File Offset: 0x0019B300
		public int CameraCount
		{
			get
			{
				return this.m_LOSSources.Count;
			}
		}

		// Token: 0x06001608 RID: 5640 RVA: 0x0019D10D File Offset: 0x0019B30D
		public void AddLOSSource(LOSSource source)
		{
			this.m_LOSSources.Add(source);
		}

		// Token: 0x06001609 RID: 5641 RVA: 0x0019D11B File Offset: 0x0019B31B
		public void RemoveLOSSource(LOSSource source)
		{
			this.m_LOSSources.Remove(source);
		}

		// Token: 0x0600160A RID: 5642 RVA: 0x0019D12C File Offset: 0x0019B32C
		public CullingGroup AddCullingGroup(Camera targetCamera)
		{
			if (!this.m_CullingGroups.ContainsKey(targetCamera))
			{
				CullingGroup cullingGroup = new CullingGroup();
				cullingGroup.targetCamera = targetCamera;
				cullingGroup.SetBoundingSpheres(this.m_BoundingSpheres);
				this.m_CullingGroups.Add(targetCamera, cullingGroup);
			}
			return this.m_CullingGroups[targetCamera];
		}

		// Token: 0x0600160B RID: 5643 RVA: 0x0019D179 File Offset: 0x0019B379
		public void RemoveCullingGroup(Camera targetCamera)
		{
			if (this.m_CullingGroups.ContainsKey(targetCamera))
			{
				CullingGroup cullingGroup = this.m_CullingGroups[targetCamera];
				cullingGroup.onStateChanged = null;
				cullingGroup.Dispose();
				this.m_CullingGroups.Remove(targetCamera);
			}
		}

		// Token: 0x0600160C RID: 5644 RVA: 0x0019D1B0 File Offset: 0x0019B3B0
		private CullingGroup GetCullingGroup(Camera targetCamera)
		{
			CullingGroup cullingGroup;
			this.m_CullingGroups.TryGetValue(targetCamera, out cullingGroup);
			return cullingGroup;
		}

		// Token: 0x0400261C RID: 9756
		private static LOSManager m_Instance;

		// Token: 0x0400261D RID: 9757
		private List<LOSSource> m_LOSSources = new List<LOSSource>();

		// Token: 0x0400261E RID: 9758
		private BoundingSphere[] m_BoundingSpheres = new BoundingSphere[512];

		// Token: 0x0400261F RID: 9759
		private Dictionary<Camera, CullingGroup> m_CullingGroups = new Dictionary<Camera, CullingGroup>();
	}
}
