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

// Token: 0x020000B0 RID: 176
public class Huddle : MonoBehaviour
{
	// Token: 0x06001073 RID: 4211 RVA: 0x0013B1CB File Offset: 0x001393CB
	private void Start()
	{
		this.contents.SetActive(false);
	}

	// Token: 0x06001074 RID: 4212 RVA: 0x0013B1DC File Offset: 0x001393DC
	public void StartMenu()
	{
		this.cam.enabled = true;
		this.huddleWorldObject.SetActive(true);
		this.contents.SetActive(true);
		Links.x.characterSheet.characterCamera.SetActive(true);
		this.SetupHuddleButtons();
		this.on = true;
		int num = 0;
		for (int i = 0; i < this.party.Count; i++)
		{
			if (this.party[i] && num < 5)
			{
				num++;
				Transform transform = null;
				if (num == 1)
				{
					transform = this.playerPoint1;
				}
				if (num == 2)
				{
					transform = this.playerPoint2;
				}
				if (num == 3)
				{
					transform = this.playerPoint3;
				}
				if (num == 4)
				{
					transform = this.playerPoint4;
				}
				if (num == 5)
				{
					transform = this.playerPoint5;
				}
				GameObject gameObject = Links.x.archives.InstantiateBody(this.party[i].stats.model, transform);
				gameObject.transform.localPosition = Vector3.zero;
				gameObject.transform.localRotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
				Body component = gameObject.GetComponent<Body>();
				component.model = this.party[i].stats.model;
				string text = this.party[i].animationPrefix + this.party[i].invRow1._CharacterAnimation;
				AnimatorOverrideController overrideController = Links.x.archives.GetOverrideController(text);
				component.anim.runtimeAnimatorController = overrideController;
				component.inMenu = true;
				component.isPortrait = false;
				component.gameObject.layer = 5;
				component.name = component.model;
				component.GatherRenderers(true);
				this.models.Add(gameObject);
			}
		}
	}

	// Token: 0x06001075 RID: 4213 RVA: 0x0013B3AC File Offset: 0x001395AC
	public void SetupHuddleButtons()
	{
		this.party = Links.x.party;
		int num = 0;
		for (int i = 0; i < this.iconsMain.Count; i++)
		{
			this.iconsMain[i].Setup(Links.x.protagonist);
		}
		for (int j = 0; j < this.party.Count; j++)
		{
			if (this.party[j] && this.party[j] != Links.x.protagonist)
			{
				num++;
				if (num == 1)
				{
					for (int k = 0; k < this.iconsCompanion1.Count; k++)
					{
						this.iconsCompanion1[k].Setup(this.party[j]);
					}
				}
				if (num == 2)
				{
					for (int l = 0; l < this.iconsCompanion2.Count; l++)
					{
						this.iconsCompanion2[l].Setup(this.party[j]);
					}
				}
				if (num == 3)
				{
					for (int m = 0; m < this.iconsCompanion3.Count; m++)
					{
						this.iconsCompanion3[m].Setup(this.party[j]);
					}
				}
				if (num == 4)
				{
					for (int n = 0; n < this.iconsCompanion4.Count; n++)
					{
						this.iconsCompanion4[n].Setup(this.party[j]);
					}
				}
			}
		}
	}

	// Token: 0x06001076 RID: 4214 RVA: 0x0013B540 File Offset: 0x00139740
	public void EndMenu()
	{
		this.cam.enabled = false;
		this.huddleWorldObject.SetActive(false);
		this.contents.SetActive(false);
		Links.x.characterSheet.characterCamera.SetActive(false);
		for (int i = 0; i < this.models.Count; i++)
		{
			if (this.models[i])
			{
				Links.x.archives.RecycleBody(this.models[i], this.models[i].GetComponent<Body>().model, base.gameObject.name);
			}
		}
		this.models.Clear();
		this.on = false;
	}

	// Token: 0x04001B53 RID: 6995
	public Transform playerPoint1;

	// Token: 0x04001B54 RID: 6996
	public Transform playerPoint2;

	// Token: 0x04001B55 RID: 6997
	public Transform playerPoint3;

	// Token: 0x04001B56 RID: 6998
	public Transform playerPoint4;

	// Token: 0x04001B57 RID: 6999
	public Transform playerPoint5;

	// Token: 0x04001B58 RID: 7000
	public Camera cam;

	// Token: 0x04001B59 RID: 7001
	public GameObject huddleWorldObject;

	// Token: 0x04001B5A RID: 7002
	public GameObject contents;

	// Token: 0x04001B5B RID: 7003
	public bool on;

	// Token: 0x04001B5C RID: 7004
	public List<HuddleButton> iconsMain = new List<HuddleButton>();

	// Token: 0x04001B5D RID: 7005
	public List<HuddleButton> iconsCompanion1 = new List<HuddleButton>();

	// Token: 0x04001B5E RID: 7006
	public List<HuddleButton> iconsCompanion2 = new List<HuddleButton>();

	// Token: 0x04001B5F RID: 7007
	public List<HuddleButton> iconsCompanion3 = new List<HuddleButton>();

	// Token: 0x04001B60 RID: 7008
	public List<HuddleButton> iconsCompanion4 = new List<HuddleButton>();

	// Token: 0x04001B61 RID: 7009
	private List<Character> party;

	// Token: 0x04001B62 RID: 7010
	private List<GameObject> models = new List<GameObject>();
}
