using System;
using UnityEngine;

// Token: 0x0200000B RID: 11
public class FOWRevealer : MonoBehaviour
{
	// Token: 0x0600008F RID: 143 RVA: 0x0000CC1B File Offset: 0x0000AE1B
	protected virtual void Start()
	{
		this.mTrans = base.transform;
		this.mRevealer = FOWSystem.CreateRevealer();
	}

	// Token: 0x06000090 RID: 144 RVA: 0x0000CC34 File Offset: 0x0000AE34
	protected virtual void OnDisable()
	{
		if (this.temporary && this.tempCount < 15)
		{
			return;
		}
		if (this.mRevealer != null)
		{
			this.mRevealer.isActive = false;
		}
	}

	// Token: 0x06000091 RID: 145 RVA: 0x0000CC5D File Offset: 0x0000AE5D
	protected virtual void OnDestroy()
	{
		if (this.mRevealer != null)
		{
			FOWSystem.DeleteRevealer(this.mRevealer);
			this.mRevealer = null;
		}
	}

	// Token: 0x06000092 RID: 146 RVA: 0x0000CC7C File Offset: 0x0000AE7C
	protected virtual void LateUpdate()
	{
		if (this.isActive)
		{
			if (this.lineOfSightCheck != FOWSystem.LOSChecks.OnlyOnce)
			{
				this.mRevealer.isValid = false;
			}
			if (this.main || Records.x.mainMenuOpen)
			{
				if (!this.character)
				{
					this.character = base.gameObject.GetComponent<Character>();
				}
				if (this.character)
				{
					this.character.UpdateCC();
					if (this.character.mainSelected)
					{
						this.range = new Vector2(0.1f, this.character.stats.SightRadius(false, false, true));
					}
					else
					{
						this.range = new Vector2(1f, 4f);
					}
				}
			}
			this.mRevealer.pos = this.mTrans.position + new Vector3(0f, 3f, 0f);
			this.mRevealer.inner = this.range.x;
			this.mRevealer.outer = this.range.y;
			this.mRevealer.los = this.lineOfSightCheck;
			this.mRevealer.isActive = true;
			if (this.temporary && this.tempCount > 15)
			{
				base.gameObject.SetActive(false);
			}
			if (this.temporary)
			{
				this.tempCount++;
				return;
			}
		}
		else if (this.mRevealer.isActive)
		{
			this.mRevealer.isActive = false;
			this.mRevealer.isValid = false;
		}
	}

	// Token: 0x06000093 RID: 147 RVA: 0x0000CE0C File Offset: 0x0000B00C
	public void Rebuild()
	{
		this.mRevealer.isValid = false;
	}

	// Token: 0x040001EA RID: 490
	private Transform mTrans;

	// Token: 0x040001EB RID: 491
	public Character character;

	// Token: 0x040001EC RID: 492
	private string currentTimeOfDay;

	// Token: 0x040001ED RID: 493
	public bool main;

	// Token: 0x040001EE RID: 494
	public Vector2 range;

	// Token: 0x040001EF RID: 495
	public FOWSystem.LOSChecks lineOfSightCheck = FOWSystem.LOSChecks.EveryUpdate;

	// Token: 0x040001F0 RID: 496
	public bool isActive = true;

	// Token: 0x040001F1 RID: 497
	public bool temporary;

	// Token: 0x040001F2 RID: 498
	private int tempCount;

	// Token: 0x040001F3 RID: 499
	protected FOWSystem.Revealer mRevealer;
}
