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

// Token: 0x02000031 RID: 49
public class GameSecondCounter : MonoBehaviour
{
	// Token: 0x060007C9 RID: 1993 RVA: 0x000AD338 File Offset: 0x000AB538
	private void Start()
	{
		this.currentEffects = Links.x.cellar.currentEffects;
		this.currentTileEffects = Links.x.cellar.currentTileEffects;
		this.currentPickups = Links.x.cellar.pickups;
	}

	// Token: 0x060007CA RID: 1994 RVA: 0x000AD384 File Offset: 0x000AB584
	private void Update()
	{
		if ((!Records.x.pocketPause && Links.x.gaia.sceneLoaded && !Records.x.removeControls && !Records.x.paused) || Records.x.partyCamping)
		{
			int num = this.currentEffects.Count;
			this.effects.Clear();
			for (int i = 0; i < num; i++)
			{
				if (i < this.currentEffects.Count)
				{
					this.effects.Add(this.currentEffects[i]);
				}
			}
			for (int j = 0; j < this.effects.Count; j++)
			{
				this.effects[j].UpdateEffectTime();
			}
			num = this.currentTileEffects.Count;
			bool flag = false;
			this.tileEffects.Clear();
			for (int k = 0; k < num; k++)
			{
				if (k < this.currentTileEffects.Count)
				{
					if (this.currentTileEffects[k])
					{
						this.tileEffects.Add(this.currentTileEffects[k]);
					}
					else
					{
						flag = true;
					}
				}
			}
			if (flag)
			{
				this.currentTileEffects.RemoveAll((TileEffects item) => item == null);
			}
			num = this.currentPickups.Count;
			this.pickups.Clear();
			for (int l = 0; l < num; l++)
			{
				this.pickups.Add(this.currentPickups[l]);
			}
			for (int m = 0; m < num; m++)
			{
				this.pickups[m].UpdateTime();
			}
		}
	}

	// Token: 0x060007CB RID: 1995 RVA: 0x000AD53C File Offset: 0x000AB73C
	public void RemoveAllTimeEffects()
	{
		int num = this.currentTileEffects.Count;
		this.tileEffects.Clear();
		for (int i = 0; i < num; i++)
		{
			if (this.currentTileEffects[i])
			{
				this.tileEffects.Add(this.currentTileEffects[i]);
			}
		}
		for (int j = 0; j < this.tileEffects.Count; j++)
		{
			if (Records.x.editor)
			{
				Debug.Log("removing tile effects " + this.tileEffects[j].effect._DisplayName);
			}
			bool flag = true;
			if (this.tileEffects[j].paganRow != null && this.tileEffects[j].paganRow._Slider1.Contains("Summon") && !this.tileEffects[j].needsCreatureSave)
			{
				flag = false;
			}
			if (flag)
			{
				this.tileEffects[j].Remove();
			}
		}
		this.currentTileEffects.RemoveAll((TileEffects item) => item == null);
		num = this.currentPickups.Count;
		this.pickups.Clear();
		for (int k = 0; k < num; k++)
		{
			if (this.currentPickups[k])
			{
				this.pickups.Add(this.currentPickups[k]);
			}
		}
		num = this.pickups.Count;
		for (int l = 0; l < num; l++)
		{
			this.pickups[l].End();
		}
	}

	// Token: 0x04000C15 RID: 3093
	private List<Effects> currentEffects;

	// Token: 0x04000C16 RID: 3094
	private List<TileEffects> currentTileEffects;

	// Token: 0x04000C17 RID: 3095
	private List<Effects> effects = new List<Effects>();

	// Token: 0x04000C18 RID: 3096
	private List<TileEffects> tileEffects = new List<TileEffects>();

	// Token: 0x04000C19 RID: 3097
	private List<Pickups> currentPickups;

	// Token: 0x04000C1A RID: 3098
	private List<Pickups> pickups = new List<Pickups>();
}
