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

// Token: 0x020000D0 RID: 208
public class RenderPortraits : MonoBehaviour
{
	// Token: 0x06001334 RID: 4916 RVA: 0x00172CB3 File Offset: 0x00170EB3
	private void Start()
	{
	}

	// Token: 0x06001335 RID: 4917 RVA: 0x00172CB8 File Offset: 0x00170EB8
	private void Update()
	{
		if (this.waitingCharacters.Count > 0)
		{
			this.StartCharacter(this.waitingCharacters[0], this.waitingCharacterXML[0], this.waitingPortrait[0], this.waitingCanReplace[0], this.waitingTimeline[0], this.waitingImage[0], this.waitingGameCard[0], this.waitingCompanionIcon[0]);
			this.waitingCharacters.RemoveAt(0);
			this.waitingCharacterXML.RemoveAt(0);
			this.waitingPortrait.RemoveAt(0);
			this.waitingCanReplace.RemoveAt(0);
			this.waitingTimeline.RemoveAt(0);
			this.waitingImage.RemoveAt(0);
			this.waitingGameCard.RemoveAt(0);
			this.waitingCompanionIcon.RemoveAt(0);
		}
	}

	// Token: 0x06001336 RID: 4918 RVA: 0x00172D9C File Offset: 0x00170F9C
	public void ToggleCrossFades(bool state)
	{
		int num = 0;
		foreach (Character character in this.characters)
		{
			if (character && character.party && this.setups[num])
			{
				this.setups[num].ToggleCrossFade(state);
			}
			num++;
		}
	}

	// Token: 0x06001337 RID: 4919 RVA: 0x00172E24 File Offset: 0x00171024
	public void AddCharacter(Character character, string characterXml, Portrait portrait, bool canReplace, TimelineIcon icon, RawImage img, GameCard gameCard, CompanionIcon companionIcon)
	{
		int num = this.characters.IndexOf(character);
		if (num > -1 && character && (img || companionIcon))
		{
			this.SetImages(num, character, characterXml, portrait, icon, img, gameCard, companionIcon, this.cameras[num].targetTexture);
			return;
		}
		int num2 = this.waitingCharacters.IndexOf(character);
		if (num2 == -1 || !character)
		{
			this.waitingCharacters.Add(character);
			this.waitingCharacterXML.Add(characterXml);
			this.waitingPortrait.Add(portrait);
			this.waitingCanReplace.Add(canReplace);
			this.waitingTimeline.Add(icon);
			this.waitingImage.Add(img);
			this.waitingGameCard.Add(gameCard);
			this.waitingCompanionIcon.Add(companionIcon);
			return;
		}
		this.waitingCharacters[num2] = character;
		this.waitingCharacterXML[num2] = characterXml;
		this.waitingPortrait[num2] = portrait;
		this.waitingCanReplace[num2] = canReplace;
		this.waitingTimeline[num2] = icon;
		this.waitingImage[num2] = img;
		this.waitingGameCard[num2] = gameCard;
		this.waitingCompanionIcon[num2] = companionIcon;
	}

	// Token: 0x06001338 RID: 4920 RVA: 0x00172F6C File Offset: 0x0017116C
	public void StartCharacter(Character character, string characterXml, Portrait portrait, bool canReplace, TimelineIcon icon, RawImage img, GameCard gameCard, CompanionIcon companionIcon)
	{
		int num = this.characters.IndexOf(character);
		if (num > -1 && this.setups[num] && this.setups[num].savedCharacter != character)
		{
			num = -1;
			this.RemoveCharacter(character, characterXml, null);
			Debug.Log("Error with render portrait indexes, removing character " + ((character != null) ? character.ToString() : null));
		}
		if (!character)
		{
			num = -1;
		}
		RenderTexture renderTexture = null;
		bool flag = false;
		bool flag2 = false;
		string text;
		string text2;
		Library.Characters characters;
		string text3;
		float num2;
		string text4;
		string text5;
		if (character)
		{
			if (character.party || character.isBoro)
			{
				flag2 = true;
			}
			flag = true;
			text = character.stats.model;
			text2 = character.stats.headModel;
			characters = character.stats.characterRow;
			text3 = character.stats.race;
			num2 = character.stats.sex;
			text4 = character.stats.skinTexture;
			text5 = character.stats.hairTexture;
		}
		else
		{
			characters = Links.x.library.GetPCRowFromName(characterXml);
			text = characters._Model;
			text2 = characters._ModelHead;
			text3 = characters._Race;
			num2 = characters._Sex;
			text4 = characters._SkinTexture;
			text5 = characters._HairTexture;
		}
		if (gameCard && num > -1 && (Records.x.IsFelon(character) || Records.x.IsVictim(character)))
		{
			gameCard.texturesIdle = this.texturesIdle[num];
			gameCard.portrait.texture = this.texturesIdle[num];
			gameCard.SetPortrait(this.texturesIdle[num]);
			return;
		}
		if (this.characters.Contains(character) && character && !character.party)
		{
			this.RemoveCharacter(character, character.stats.xmlName, null);
			num = -1;
		}
		if (num == -1)
		{
			this.characters.Add(character);
			this.charactersXml.Add(characterXml);
			this.modelNames.Add(text);
			this.headModelNames.Add(text2);
			Transform transform = this.playerPoint;
			GameObject gameObject = Links.x.archives.InstantiateBody(text, transform);
			gameObject.transform.localRotation = Quaternion.Euler(Vector3.zero);
			if (this.forHudPortraits)
			{
				gameObject.transform.localRotation = Quaternion.Euler(new Vector3(0f, this.FromPortraitIndex(0), 0f));
			}
			else if (!gameCard)
			{
				gameObject.transform.localRotation = Quaternion.Euler(this.rot);
			}
			Body component = gameObject.GetComponent<Body>();
			component.Reset();
			component.model = text;
			string text6;
			if (flag)
			{
				text6 = character.animationPrefix + "_Unarmed";
				if (!character.stats.animal)
				{
					text6 = "_Volling_Dialogue_Basic";
				}
			}
			else
			{
				text6 = characters._AnimationPrefix + "_Unarmed";
			}
			AnimatorOverrideController overrideController = Links.x.archives.GetOverrideController(text6);
			if (!component.anim)
			{
				component.anim = component.gameObject.GetComponent<Animator>();
			}
			component.anim.runtimeAnimatorController = overrideController;
			component.anim.updateMode = AnimatorUpdateMode.UnscaledTime;
			component.isPortrait = true;
			if (this.forHudPortraits)
			{
				component.portrait = true;
			}
			else
			{
				component.portrait = false;
			}
			component.inMenu = false;
			component.gameObject.layer = 26;
			component.name = text;
			component.SetupHead(text2);
			component.GatherRenderers(true);
			bool flag3 = true;
			if (character && character.party)
			{
				flag3 = false;
			}
			if (flag)
			{
				component.SetupTextures(text3, num2, character.stats.characterRow, text4, text5, flag3);
				if (overrideController.name.Contains("Volling") || Links.x.creation)
				{
					component.anim.Play("Look Around Less", -1, Random.Range(0f, 1f));
				}
			}
			else
			{
				component.SetupTextures(text3, num2, characters, text4, text5, flag3);
			}
			component.SetMagicaClothState(true);
			component.gameObject.SetActive(false);
			Transform head = component.GetHead();
			Camera camera = this.GetCamera();
			this.cameras.Add(camera);
			if (text.Contains("Sheep"))
			{
				gameObject.transform.localRotation = Quaternion.Euler(this.boroRotation);
			}
			if (flag)
			{
				int invNum = character.GetInvNum(16);
				int invNum2 = character.GetInvNum(18);
				int invNum3 = character.GetInvNum(24);
				this.SetupEquippedItems(component, invNum, invNum2, invNum3);
				if (invNum2 > 1 && !character.npc)
				{
					bool flag4 = this.forHudPortraits;
				}
			}
			this.models.Add(gameObject);
			renderTexture = this.GetRT();
			this.texturesIdle.Add(renderTexture);
			num = this.characters.Count - 1;
			if (!portrait)
			{
				component.anim.speed = 1f;
			}
			RenderPortraitSetup renderPortraitSetup = base.gameObject.AddComponent<RenderPortraitSetup>();
			this.setups.Add(renderPortraitSetup);
			renderPortraitSetup.portrait = portrait;
			renderPortraitSetup.gamecard = gameCard;
			renderPortraitSetup.cam = camera;
			renderPortraitSetup.model = gameObject;
			renderPortraitSetup.animatorOverrideController = overrideController;
			component.anim.runtimeAnimatorController = overrideController;
			if (this.forHudPortraits)
			{
				if (text3 != "Yeti")
				{
					camera.orthographicSize = this.orthoSize;
				}
				else
				{
					camera.orthographicSize = this.orthoSizeYeti;
				}
			}
			renderPortraitSetup.party = flag2;
			if (flag && !img)
			{
				renderPortraitSetup.savedCharacter = character;
			}
			renderPortraitSetup.Setup(num, characterXml, component, head, this, Random.Range(0f, 1f), renderTexture, characters);
		}
		if (num > -1 && !canReplace)
		{
			Body body = this.models[num].GetComponent<Body>();
			float num3 = this.models[num].GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime;
			RenderPortraitSetup renderPortraitSetup2;
			if (this.setups[num] == null)
			{
				renderPortraitSetup2 = base.gameObject.AddComponent<RenderPortraitSetup>();
				this.setups[num] = renderPortraitSetup2;
			}
			else
			{
				renderPortraitSetup2 = this.setups[num];
			}
			AnimatorOverrideController animatorOverrideController;
			if (this.modelNames[num] == text && this.headModelNames[num] == text2)
			{
				string text7;
				if (flag)
				{
					text7 = character.animationPrefix + "_Unarmed";
				}
				else
				{
					text7 = characters._AnimationPrefix + "_Unarmed";
				}
				if (flag)
				{
					text7 = character.animationPrefix + "_Unarmed";
					if (!character.stats.animal)
					{
						text7 = "_Volling_Dialogue_Basic";
					}
				}
				else
				{
					text7 = characters._AnimationPrefix + "_Unarmed";
				}
				animatorOverrideController = Links.x.archives.GetOverrideController(text7);
				body.anim.runtimeAnimatorController = animatorOverrideController;
				bool flag5 = true;
				if (character)
				{
					if (character.party)
					{
						flag5 = false;
					}
					if (animatorOverrideController.name.Contains("Volling") || Links.x.creation)
					{
						body.anim.Play("Look Around Less", -1, num3);
					}
				}
				if (body.headModel != text2)
				{
					body.SetupHead(text2);
				}
				if (flag)
				{
					body.SetupTextures(text3, num2, character.stats.characterRow, text4, text5, flag5);
				}
				else
				{
					body.SetupTextures(text3, num2, characters, text4, text5, flag5);
				}
			}
			else
			{
				GameObject gameObject2 = this.models[num];
				num3 = gameObject2.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime;
				if (flag)
				{
					Links.x.archives.RecycleBody(gameObject2, this.models[num].name, character.name);
				}
				else
				{
					Links.x.archives.RecycleBody(gameObject2, this.models[num].name, characterXml);
				}
				this.headTransform = this.setups[num].gameObject.transform.GetChild(1);
				Transform transform2 = this.playerPoint;
				GameObject gameObject3 = Links.x.archives.InstantiateBody(text, transform2);
				gameObject3.transform.localRotation = Quaternion.Euler(Vector3.zero);
				if (this.forHudPortraits)
				{
					gameObject3.transform.localRotation = Quaternion.Euler(new Vector3(0f, this.FromPortraitIndex(0), 0f));
				}
				else if (!gameCard)
				{
					gameObject3.transform.localRotation = Quaternion.Euler(this.rot);
				}
				body = gameObject3.GetComponent<Body>();
				body.Reset();
				body.model = text;
				string text8;
				if (flag)
				{
					text8 = character.animationPrefix + "_Unarmed";
				}
				else
				{
					text8 = characters._AnimationPrefix + "_Unarmed";
				}
				if (flag)
				{
					text8 = character.animationPrefix + "_Unarmed";
					if (!character.stats.animal)
					{
						text8 = "_Volling_Dialogue_Basic";
					}
				}
				else
				{
					text8 = characters._AnimationPrefix + "_Unarmed";
				}
				animatorOverrideController = Links.x.archives.GetOverrideController(text8);
				if (!body.anim)
				{
					body.anim = body.gameObject.GetComponent<Animator>();
				}
				body.anim.runtimeAnimatorController = animatorOverrideController;
				body.anim.updateMode = AnimatorUpdateMode.UnscaledTime;
				if (!portrait)
				{
					body.anim.speed = 1f;
				}
				body.isPortrait = true;
				body.inMenu = false;
				body.gameObject.layer = 26;
				body.name = text;
				body.SetupHead(text2);
				body.GatherRenderers(true);
				if (character && (animatorOverrideController.name.Contains("Volling") || Links.x.creation))
				{
					body.anim.Play("Look Around Less", -1, num3);
				}
				bool flag6 = true;
				if (character && character.party)
				{
					flag6 = false;
				}
				if (flag)
				{
					body.SetupTextures(text3, num2, character.stats.characterRow, text4, text5, flag6);
				}
				else
				{
					body.SetupTextures(text3, num2, characters, text4, text5, flag6);
				}
				body.SetMagicaClothState(true);
				body.gameObject.SetActive(false);
				this.models[num] = gameObject3;
				this.modelNames[num] = text;
				this.headModelNames[num] = text2;
			}
			if (renderPortraitSetup2)
			{
				if (flag)
				{
					int invNum4 = character.GetInvNum(16);
					int invNum5 = character.GetInvNum(18);
					int invNum6 = character.GetInvNum(24);
					if (!character.npc)
					{
						this.SetupEquippedItems(body, invNum4, invNum5, invNum6);
					}
				}
				renderPortraitSetup2.animatorOverrideController = animatorOverrideController;
				renderPortraitSetup2.portrait = portrait;
				renderPortraitSetup2.gamecard = gameCard;
				renderPortraitSetup2.cam = this.cameras[num];
				if (this.forHudPortraits)
				{
					if (text3 != "Yeti")
					{
						renderPortraitSetup2.cam.orthographicSize = this.orthoSize;
					}
					else
					{
						renderPortraitSetup2.cam.orthographicSize = this.orthoSizeYeti;
					}
				}
				renderPortraitSetup2.model = this.models[num];
				renderPortraitSetup2.party = flag2;
				if (flag && !img)
				{
					renderPortraitSetup2.savedCharacter = character;
				}
				renderPortraitSetup2.Setup(num, characterXml, body, body.GetHead(), this, num3, renderPortraitSetup2.texCapture, characters);
			}
		}
		if (renderTexture == null && num > -1 && num < this.setups.Count && this.setups[num])
		{
			renderTexture = this.setups[num].texCapture;
		}
		this.SetImages(num, character, characterXml, portrait, icon, img, gameCard, companionIcon, renderTexture);
	}

	// Token: 0x06001339 RID: 4921 RVA: 0x00173BA4 File Offset: 0x00171DA4
	public void CheckForModel()
	{
		for (int i = 0; i < this.setups.Count; i++)
		{
			if (this.setups[i] && this.setups[i].savedCharacter && this.setups[i].savedCharacter.party)
			{
				this.setups[i].CheckForModel();
			}
		}
	}

	// Token: 0x0600133A RID: 4922 RVA: 0x00173C1C File Offset: 0x00171E1C
	public void PlayAnimation(Character character, string animName, string bodyAnimName)
	{
		for (int i = 0; i < this.setups.Count; i++)
		{
			if (this.setups[i] && this.setups[i].savedCharacter == character)
			{
				this.setups[i].PlayAnimation(animName, bodyAnimName);
			}
		}
	}

	// Token: 0x0600133B RID: 4923 RVA: 0x00173C80 File Offset: 0x00171E80
	public void HeadBobble(Character character)
	{
		for (int i = 0; i < this.setups.Count; i++)
		{
			if (this.setups[i] && this.setups[i].savedCharacter == character)
			{
				this.setups[i].HeadBobble();
			}
		}
	}

	// Token: 0x0600133C RID: 4924 RVA: 0x00173CE0 File Offset: 0x00171EE0
	public void FreshBlinks(Character character)
	{
		for (int i = 0; i < this.setups.Count; i++)
		{
			if (this.setups[i] && this.setups[i].savedCharacter == character)
			{
				this.setups[i].FreshBlink();
			}
		}
	}

	// Token: 0x0600133D RID: 4925 RVA: 0x00173D40 File Offset: 0x00171F40
	private void SetImages(int index, Character character, string characterXml, Portrait portrait, TimelineIcon icon, RawImage img, GameCard gameCard, CompanionIcon companionIcon, RenderTexture rt)
	{
		if (characterXml.Contains("Boro"))
		{
			Links.x.hudControl.texturesIdle = rt;
			Links.x.hudControl.sheepImage.texture = rt;
		}
		if (portrait)
		{
			portrait.currIndex = 0;
			portrait.texturesIdle = rt;
			character.portrait.texturesIdle = rt;
			if (character.party)
			{
				character.portrait.skillBag.NewPortrait();
			}
			portrait.UpdatePortraitVisual();
		}
		if (icon)
		{
			icon.texturesIdle = rt;
			icon.portrait.texture = rt;
		}
		if (img)
		{
			img.texture = this.texturesIdle[index];
		}
		if (gameCard)
		{
			gameCard.currIndex = -1;
			gameCard.texturesIdle = rt;
			gameCard.portrait.texture = rt;
			gameCard.SetPortrait(rt);
		}
		if (companionIcon)
		{
			companionIcon.texturesIdle = rt;
		}
	}

	// Token: 0x0600133E RID: 4926 RVA: 0x00173E46 File Offset: 0x00172046
	private float FromPortraitIndex(int index)
	{
		return this.rot.y;
	}

	// Token: 0x0600133F RID: 4927 RVA: 0x00173E54 File Offset: 0x00172054
	public RenderTexture GetRT()
	{
		if (this.unusedTextures.Count > 0)
		{
			RenderTexture renderTexture = this.unusedTextures[0];
			this.unusedTextures.RemoveAt(0);
			return renderTexture;
		}
		int num = 256;
		int num2 = 256;
		if (this.forHudPortraits)
		{
			return new RenderTexture(num, num2, 16, RenderTextureFormat.ARGB32)
			{
				filterMode = FilterMode.Bilinear
			};
		}
		num = 290;
		num2 = 277;
		RenderTexture renderTexture2 = new RenderTexture(num, num2, 16, RenderTextureFormat.ARGB32);
		renderTexture2.filterMode = FilterMode.Bilinear;
		this.GetRTSize(renderTexture2);
		return renderTexture2;
	}

	// Token: 0x06001340 RID: 4928 RVA: 0x00173ED4 File Offset: 0x001720D4
	public void UpdateAA()
	{
		for (int i = 0; i < this.setups.Count; i++)
		{
			if (this.setups[i] && this.setups[i].cam.targetTexture)
			{
				this.UpdateRT(this.setups[i].cam.targetTexture);
			}
		}
	}

	// Token: 0x06001341 RID: 4929 RVA: 0x00173F44 File Offset: 0x00172144
	public void ToggleDownsampling(bool state)
	{
		for (int i = 0; i < this.setups.Count; i++)
		{
			if (this.setups[i])
			{
				this.setups[i].ToggleDownsampling(state);
			}
		}
	}

	// Token: 0x06001342 RID: 4930 RVA: 0x00173F8C File Offset: 0x0017218C
	public void GetRTSize(RenderTexture rt)
	{
		if (QualitySettings.antiAliasing == 0)
		{
			rt.antiAliasing = 1;
			return;
		}
		if (QualitySettings.antiAliasing == 2)
		{
			rt.antiAliasing = 2;
			return;
		}
		if (QualitySettings.antiAliasing == 4)
		{
			rt.antiAliasing = 4;
			return;
		}
		if (QualitySettings.antiAliasing == 8)
		{
			rt.antiAliasing = 8;
		}
	}

	// Token: 0x06001343 RID: 4931 RVA: 0x00173FCC File Offset: 0x001721CC
	public void UpdateRT(RenderTexture rt)
	{
		if (QualitySettings.antiAliasing == 0)
		{
			if (rt.antiAliasing != 1)
			{
			}
		}
		else if (QualitySettings.antiAliasing == 2)
		{
			if (rt.antiAliasing != 2)
			{
			}
		}
		else if (QualitySettings.antiAliasing == 4)
		{
			if (rt.antiAliasing != 4)
			{
			}
		}
		else if (QualitySettings.antiAliasing == 8 && rt.antiAliasing != 8)
		{
		}
	}

	// Token: 0x06001344 RID: 4932 RVA: 0x00174030 File Offset: 0x00172230
	public void FaceForward()
	{
		foreach (RenderPortraitSetup renderPortraitSetup in this.setups)
		{
			if (renderPortraitSetup.savedCharacter && renderPortraitSetup.savedCharacter.party)
			{
				renderPortraitSetup.FaceForward();
			}
		}
	}

	// Token: 0x06001345 RID: 4933 RVA: 0x0017409C File Offset: 0x0017229C
	public void FaceSide()
	{
		foreach (RenderPortraitSetup renderPortraitSetup in this.setups)
		{
			if (renderPortraitSetup.savedCharacter && renderPortraitSetup.savedCharacter.party)
			{
				renderPortraitSetup.FaceToTheSide();
			}
		}
	}

	// Token: 0x06001346 RID: 4934 RVA: 0x00174108 File Offset: 0x00172308
	public Camera GetCamera()
	{
		if (this.unusedCameras.Count > 0)
		{
			Camera camera = this.unusedCameras[0];
			this.unusedCameras.RemoveAt(0);
			return camera;
		}
		GameObject gameObject = Object.Instantiate<GameObject>(this.cameraExample, Vector3.zero, Quaternion.identity, base.transform);
		Camera component = gameObject.GetComponent<Camera>();
		component.depthTextureMode = DepthTextureMode.None;
		if (this.forHudPortraits)
		{
			gameObject.transform.localPosition = new Vector3(((float)this.cameras.Count + 1f) * -50f, 0f, 0f);
		}
		else
		{
			gameObject.transform.localPosition = new Vector3((float)this.cameras.Count * 50f, 0f, 0f);
		}
		gameObject.transform.localRotation = Quaternion.Euler(0f, -270f, 0f);
		this.camCount++;
		return component;
	}

	// Token: 0x06001347 RID: 4935 RVA: 0x001741FC File Offset: 0x001723FC
	public void SetupEquippedItems(Body body, int id8, int id9, int id12)
	{
		body.CreateMenuItems(id8, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector4(100f, 100f, 0f, 0f), 8, null);
		body.CreateMenuItems(id12, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector4(100f, 100f, 0f, 0f), 12, null);
	}

	// Token: 0x06001348 RID: 4936 RVA: 0x001742A4 File Offset: 0x001724A4
	public void Reloading()
	{
		for (int i = 0; i < this.characters.Count; i++)
		{
			GameObject gameObject = this.models[i];
			Links.x.archives.RecycleBody(gameObject, this.models[i].name, "rp");
			foreach (RenderPortraitSetup renderPortraitSetup in this.setups)
			{
				if (renderPortraitSetup.savedCharacter == this.characters[i])
				{
					renderPortraitSetup.Reload();
				}
			}
		}
		for (int j = 0; j < this.texturesIdle.Count; j++)
		{
			if (this.texturesIdle[j] != null)
			{
				this.unusedTextures.Add(this.texturesIdle[j]);
			}
		}
		for (int k = 0; k < this.cameras.Count; k++)
		{
			if (this.cameras[k])
			{
				this.unusedCameras.Add(this.cameras[k]);
				this.cameras[k].gameObject.SetActive(false);
			}
		}
		this.characters.Clear();
		this.charactersXml.Clear();
		this.modelNames.Clear();
		this.headModelNames.Clear();
		this.cameras.Clear();
		this.models.Clear();
		this.texturesIdle.Clear();
		this.setups.Clear();
	}

	// Token: 0x06001349 RID: 4937 RVA: 0x0017445C File Offset: 0x0017265C
	public void RemoveCharacter(Character character, string characterXmlName, Texture textureToRemove)
	{
		int num = this.characters.IndexOf(character);
		if (num == -1 || !character)
		{
			num = this.charactersXml.IndexOf(characterXmlName);
		}
		if (textureToRemove)
		{
			for (int i = 0; i < this.charactersXml.Count; i++)
			{
				if (this.charactersXml[i] == characterXmlName && textureToRemove == this.setups[i].cam.targetTexture)
				{
					num = i;
					break;
				}
			}
		}
		if (num > -1)
		{
			this.cameras[num].enabled = false;
			this.modelNames.RemoveAt(num);
			this.headModelNames.RemoveAt(num);
			GameObject gameObject = this.models[num];
			string text = this.charactersXml[num];
			if (this.characters[num])
			{
				text = this.characters[num].name;
			}
			Links.x.archives.RecycleBody(gameObject, this.models[num].name, text);
			this.models.RemoveAt(num);
			if (this.setups[num])
			{
				if (this.setups[num].cam)
				{
					Camera cam = this.setups[num].cam;
					if (cam)
					{
						RenderTexture targetTexture = this.setups[num].cam.targetTexture;
						if (targetTexture == null)
						{
							targetTexture = this.setups[num].texCapture;
						}
						this.unusedCameras.Add(cam);
						int num2 = this.cameras.IndexOf(cam);
						if (num2 > -1)
						{
							this.cameras.RemoveAt(num2);
						}
						if (targetTexture != null)
						{
							this.unusedTextures.Add(targetTexture);
							int num3 = this.texturesIdle.IndexOf(targetTexture);
							if (num3 > -1)
							{
								this.texturesIdle.RemoveAt(num3);
							}
						}
					}
				}
				this.setups[num].Reload();
			}
			this.characters.RemoveAt(num);
			this.charactersXml.RemoveAt(num);
			this.setups.RemoveAt(num);
		}
	}

	// Token: 0x04002065 RID: 8293
	public bool forHudPortraits;

	// Token: 0x04002066 RID: 8294
	public Transform playerPoint;

	// Token: 0x04002067 RID: 8295
	public Transform headTransform;

	// Token: 0x04002068 RID: 8296
	public Light directionalLight;

	// Token: 0x04002069 RID: 8297
	public List<GameObject> models = new List<GameObject>();

	// Token: 0x0400206A RID: 8298
	public List<Character> characters = new List<Character>();

	// Token: 0x0400206B RID: 8299
	public List<string> charactersXml = new List<string>();

	// Token: 0x0400206C RID: 8300
	public List<Camera> cameras = new List<Camera>();

	// Token: 0x0400206D RID: 8301
	public List<string> modelNames = new List<string>();

	// Token: 0x0400206E RID: 8302
	public List<string> headModelNames = new List<string>();

	// Token: 0x0400206F RID: 8303
	public List<RenderTexture> texturesIdle = new List<RenderTexture>();

	// Token: 0x04002070 RID: 8304
	public List<RenderTexture> unusedTextures = new List<RenderTexture>();

	// Token: 0x04002071 RID: 8305
	public List<Camera> unusedCameras = new List<Camera>();

	// Token: 0x04002072 RID: 8306
	public List<RenderPortraitSetup> setups = new List<RenderPortraitSetup>();

	// Token: 0x04002073 RID: 8307
	public List<Character> waitingCharacters = new List<Character>();

	// Token: 0x04002074 RID: 8308
	public List<string> waitingCharacterXML = new List<string>();

	// Token: 0x04002075 RID: 8309
	public List<Portrait> waitingPortrait = new List<Portrait>();

	// Token: 0x04002076 RID: 8310
	public List<bool> waitingCanReplace = new List<bool>();

	// Token: 0x04002077 RID: 8311
	public List<TimelineIcon> waitingTimeline = new List<TimelineIcon>();

	// Token: 0x04002078 RID: 8312
	public List<RawImage> waitingImage = new List<RawImage>();

	// Token: 0x04002079 RID: 8313
	public List<GameCard> waitingGameCard = new List<GameCard>();

	// Token: 0x0400207A RID: 8314
	public List<CompanionIcon> waitingCompanionIcon = new List<CompanionIcon>();

	// Token: 0x0400207B RID: 8315
	public bool takingCaptures;

	// Token: 0x0400207C RID: 8316
	public GameObject cameraExample;

	// Token: 0x0400207D RID: 8317
	private RenderTexture[] texCapture;

	// Token: 0x0400207E RID: 8318
	private int camCount;

	// Token: 0x0400207F RID: 8319
	private int camCountParty;

	// Token: 0x04002080 RID: 8320
	public Vector3 rot;

	// Token: 0x04002081 RID: 8321
	public Vector3 boroRotation;

	// Token: 0x04002082 RID: 8322
	public Vector3 sheepOffset;

	// Token: 0x04002083 RID: 8323
	public float orthoSize;

	// Token: 0x04002084 RID: 8324
	public float orthoSizeYeti;
}
