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

// Token: 0x02000046 RID: 70
public class QuestEnd : MonoBehaviour
{
	// Token: 0x060008AE RID: 2222 RVA: 0x000BC952 File Offset: 0x000BAB52
	private void Start()
	{
		this.TurnOff();
	}

	// Token: 0x060008AF RID: 2223 RVA: 0x000BC95A File Offset: 0x000BAB5A
	public void QuestEnded(string questName)
	{
		base.StartCoroutine(this.QuestEnding(questName));
	}

	// Token: 0x060008B0 RID: 2224 RVA: 0x000BC96A File Offset: 0x000BAB6A
	private IEnumerator QuestEnding(string questName)
	{
		this.on = true;
		while (!Links.x.main)
		{
			yield return null;
		}
		while (!Links.x.gaia.sceneLoaded)
		{
			yield return null;
		}
		while (this.CannotOpen())
		{
			yield return null;
		}
		this.canvas.alpha = 0f;
		this.canvas.gameObject.SetActive(true);
		this.textAnimator.gameObject.SetActive(false);
		Links.x.gameplay.TogglePause(false);
		Records.x.RemoveControls(true);
		Records.x.SetTypingState(true);
		this.skipText.enabled = false;
		this.clickCount = 0;
		this.cam.GetComponent<Bokeh>().enabled = false;
		this.Recycle();
		this.currentParty.Clear();
		this.feedAnimator.Play("QuestEndFeed");
		if (Links.x.options.graphicsQuality >= 1)
		{
			this.l.shadows = LightShadows.Hard;
		}
		else
		{
			this.l.shadows = LightShadows.None;
		}
		if (this.renderTexture == null || this.w != Screen.width || this.h != Screen.height || this.qualitySettings != QualitySettings.antiAliasing)
		{
			if (this.renderTexture != null)
			{
				this.renderTexture.Release();
			}
			this.qualitySettings = 1;
			if (QualitySettings.antiAliasing == 2)
			{
				this.qualitySettings = 2;
			}
			if (QualitySettings.antiAliasing == 4)
			{
				this.qualitySettings = 4;
			}
			if (QualitySettings.antiAliasing == 8)
			{
				this.qualitySettings = 8;
			}
			this.w = Screen.width;
			this.h = Screen.height;
			this.renderTexture = new RenderTexture(this.w, this.h, 16, RenderTextureFormat.ARGB32);
			this.renderTexture.antiAliasing = this.qualitySettings;
			this.cam.targetTexture = this.renderTexture;
			this.img.texture = this.renderTexture;
			this.img.color = Color.white;
		}
		foreach (GameObject gameObject in this.vignetteObjects)
		{
			gameObject.SetActive(true);
		}
		this.party = Links.x.party;
		int num = 0;
		for (int j = 0; j < this.party.Count; j++)
		{
			if (this.party[j] && this.party[j].party)
			{
				this.currentParty.Add(this.party[j]);
				Character character = this.party[j];
				string model = character.stats.model;
				Transform transform = this.spot1;
				if (num == 1)
				{
					transform = this.spot2;
				}
				if (num == 2)
				{
					transform = this.spot3;
				}
				if (num == 3)
				{
					transform = this.spot4;
				}
				GameObject gameObject2 = Links.x.archives.InstantiateBody(model, transform);
				gameObject2.SetActive(true);
				Body component = gameObject2.GetComponent<Body>();
				component.Reset();
				this.bodies.Add(component);
				this.bodyNames.Add(model);
				Character character2 = character;
				component.model = model;
				component.name = model;
				component.animationPrefix = character.animationPrefix;
				if (!component.anim)
				{
					component.anim = component.gameObject.GetComponent<Animator>();
					if (!component.anim)
					{
						Debug.Log("no animator");
					}
				}
				component.inMenu = true;
				component.isPortrait = false;
				component.anim.updateMode = AnimatorUpdateMode.Normal;
				component.anim.applyRootMotion = true;
				component.gameObject.layer = 25;
				component.SetGrounderState(false);
				component.tr = component.gameObject.transform;
				component.GetHead();
				component.SetupHead(character2.stats.headModel);
				component.GatherRenderers(true);
				component.SetupTextures(character.stats.race, character.stats.sex, character.stats.characterRow, character.stats.skinTexture, character.stats.hairTexture, false);
				int invNum = character.GetInvNum(16);
				int invNum2 = character.GetInvNum(24);
				this.SetupEquippedItems(component, character.GetInvNum(0), character.GetInvNum(2), invNum, invNum2, character.GetInvNum(20), character.GetInvNum(22));
				component.anim.runtimeAnimatorController = this.levelUpController;
				gameObject2.transform.localPosition = Vector3.zero;
				string text = "LevelUp_Volling_shortsword_start";
				string name = this.party[j].animator.runtimeAnimatorController.name;
				if (name.Contains("_Volling_AxSingleHanded"))
				{
					text = "LevelUp_Volling_shortsword_start";
				}
				if (name.Contains("_Volling_Bow"))
				{
					text = "LevelUp_Volling_bow_start";
				}
				if (name.Contains("_Volling_ElyxerBag"))
				{
					text = "LevelUp_Volling_elyxer_start";
				}
				if (name.Contains("_Volling_FlailWhip"))
				{
					text = "LevelUp_Volling_flailwhip_start";
				}
				if (name.Contains("_Volling_GreatSword"))
				{
					text = "LevelUp_Volling_twohanded_start";
				}
				if (name.Contains("_Volling_Multihand"))
				{
					text = "LevelUp_Volling_multihand_start";
				}
				if (name.Contains("_Volling_PoleSpear"))
				{
					text = "LevelUp_Volling_Spear_start";
				}
				if (name.Contains("_Volling_Scepter"))
				{
					text = "LevelUp_Volling_twohanded_start";
				}
				if (name.Contains("_Volling_ScepterSingle"))
				{
					text = "LevelUp_Volling_shortsword_start";
				}
				if (name.Contains("_Volling_Shield_Blades"))
				{
					text = "LevelUp_Volling_shieldBlades_start";
				}
				if (name.Contains("_Volling_Shield_FlailWhip"))
				{
					text = "LevelUp_Volling_whipShield_start";
				}
				if (name.Contains("_Volling_Shortsword"))
				{
					text = "LevelUp_Volling_shortsword_start";
				}
				if (name.Contains("_Volling_Sling"))
				{
					text = "LevelUp_Volling_Sling_start";
				}
				if (name.Contains("_Volling_Unarmed"))
				{
					text = "LevelUp_Volling_unarmed_start";
				}
				if (name.Contains("_VollingYeti_Multihand"))
				{
					text = "LevelUp_Yeti_Multihand_start";
				}
				if (name.Contains("_VollingYeti_Shield_SwordScepter"))
				{
					text = "LevelUp_Yeti_SingleWieldShield_start";
				}
				if (name.Contains("_VollingYeti_SingleHandWield"))
				{
					text = "LevelUp_Yeti_SingleWield_start";
				}
				if (name.Contains("_VollingYeti_Spear"))
				{
					text = "LevelUp_Yeti_SingleSpear_start";
				}
				if (name.Contains("_VollingYeti_SpearDualWield"))
				{
					text = "LevelUp_Yeti_DualSpear_start";
				}
				if (name.Contains("_VollingYeti_SpearShield"))
				{
					text = "LevelUp_Yeti_SpearShield_start";
				}
				if (name.Contains("_VollingYeti_Unarmed"))
				{
					text = "LevelUp_Yeti_Unarmed_start";
				}
				component.anim.Play(text);
				component.anim.Update(0f);
				component.gameObject.layer = 25;
				gameObject2.transform.rotation = transform.rotation;
				if (component.headAnim)
				{
					component.headAnim.FreshBlink();
				}
				num++;
			}
		}
		Links.x.gaia.FadeOutPlaylist(false, 0.25f);
		Links.x.gaia.SetPlaylist("WaltzQuestEnd", true, 0f);
		yield return new WaitForSeconds(0.001f);
		this.cam.GetComponent<Bokeh>().enabled = true;
		float timeToLerp = 0.5f;
		float percentage = 0f;
		float startTime = Time.time;
		while (percentage < 1f)
		{
			percentage = (Time.time - startTime) / timeToLerp;
			this.canvas.alpha = Mathf.Lerp(0f, 1f, percentage);
			yield return null;
		}
		LayerMask i = Links.x.worldCamera.cullingMask;
		Links.x.worldCamera.cullingMask = 1073741824;
		timeToLerp = 2f;
		percentage = 0f;
		startTime = Time.time;
		while (percentage < 1f)
		{
			percentage = (Time.time - startTime) / timeToLerp;
			yield return null;
		}
		string a = "";
		string b = "";
		string c = "";
		string d = "";
		Sprite sprite = this.empty;
		string quest = this.GetQuest(questName, out a, out b, out c, out d, out sprite);
		this.texts = this.textAnimator.gameObject.GetComponentsInChildren<TextMeshPro>(true);
		for (int k = 0; k < this.texts.Length; k++)
		{
			this.texts[k].text = quest;
		}
		this.textAnimator.gameObject.SetActive(true);
		this.textAnimator.Play("LevelUpTextAnim");
		this.SetLookAt();
		timeToLerp = 1f;
		percentage = 0f;
		startTime = Time.time;
		while (percentage < 1f)
		{
			percentage = (Time.time - startTime) / timeToLerp;
			yield return null;
		}
		this.SetLookAt();
		float lastLookSwitch = Time.timeSinceLevelLoad + Random.Range(0.5f, 1f);
		timeToLerp = 1f;
		percentage = 0f;
		startTime = Time.time;
		while (percentage < 1f)
		{
			percentage = (Time.time - startTime) / timeToLerp;
			yield return null;
		}
		this.SetupSkipText();
		for (int l = 0; l < this.feedTexts.Length; l++)
		{
			if (l == 0)
			{
				this.feedTexts[l].text = a;
			}
			if (l == 1)
			{
				this.feedTexts[l].text = b;
			}
			if (l == 2)
			{
				this.feedTexts[l].text = c;
			}
			if (l == 3)
			{
				this.feedTexts[l].text = d;
			}
			this.rects[l].sizeDelta = new Vector2(this.feedTexts[l].preferredWidth + 30f, this.rects[l].sizeDelta.y);
			this.imgs[l].sprite = sprite;
		}
		this.feedAnimator.Play("QuestEndFeedPlayOut");
		while (!this.Clicked())
		{
			if (Time.timeSinceLevelLoad > lastLookSwitch)
			{
				lastLookSwitch = Time.timeSinceLevelLoad + Random.Range(0.5f, 1f);
				this.SetLookAt();
			}
			yield return null;
		}
		Links.x.worldCamera.cullingMask = i;
		timeToLerp = 0.5f;
		percentage = 0f;
		startTime = Time.time;
		while (percentage < 1f)
		{
			percentage = (Time.time - startTime) / timeToLerp;
			this.canvas.alpha = Mathf.Lerp(1f, 0f, percentage);
			yield return null;
		}
		this.canvas.alpha = 0f;
		this.canvas.gameObject.SetActive(false);
		Records.x.RemoveControls(false);
		Records.x.SetTypingState(false);
		Links.x.gaia.FadeOutPlaylist(true, 2f);
		Links.x.gaia.SetEnvironmentPlaylist(false, Links.x.main.inTown, true);
		this.Recycle();
		this.on = false;
		if (this.puzzleActions)
		{
			this.puzzleActions.StartPuzzle();
			this.puzzleActions = null;
		}
		if (this.renderTexture != null)
		{
			this.renderTexture.Release();
		}
		yield break;
	}

	// Token: 0x060008B1 RID: 2225 RVA: 0x000BC980 File Offset: 0x000BAB80
	private void SetLookAt()
	{
		for (int i = 0; i < this.bodies.Count; i++)
		{
			if (Random.Range(0, 3) == 0)
			{
				int num = 0;
				if (i == 0)
				{
					num = Random.Range(1, 4);
				}
				if (i == 1)
				{
					num = Random.Range(0, 4);
					if (num == 1)
					{
						num = Random.Range(2, 4);
					}
				}
				if (i == 2)
				{
					num = Random.Range(0, 4);
					if (num == 2)
					{
						num = Random.Range(0, 2);
					}
				}
				if (i == 3)
				{
					num = Random.Range(0, 3);
				}
				this.bodies[i].lookAtController.SetNewTarget(this.bodies[num].GetSlot(16), 0f, 0f, false);
			}
		}
	}

	// Token: 0x060008B2 RID: 2226 RVA: 0x000BCA30 File Offset: 0x000BAC30
	public void SetupEquippedItems(Body body, int id0, int id1, int id8, int id12, int id10, int id11)
	{
		if (id0 > 1)
		{
			body.CreateMenuItems(id0, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 0, null);
		}
		if (id1 > 1)
		{
			body.CreateMenuItems(id1, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 1, null);
		}
		if (id8 > 1)
		{
			body.CreateMenuItems(id8, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 8, null);
		}
		if (id12 > 1)
		{
			body.CreateMenuItems(id12, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 12, null);
		}
		if (id10 > 1)
		{
			body.CreateMenuItems(id10, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 10, null);
		}
		if (id11 > 1)
		{
			body.CreateMenuItems(id11, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 11, null);
		}
	}

	// Token: 0x060008B3 RID: 2227 RVA: 0x000BCC04 File Offset: 0x000BAE04
	private void Recycle()
	{
		for (int i = 0; i < this.bodies.Count; i++)
		{
			if (this.bodies[i])
			{
				this.bodies[i].lookAtController.EndLook();
				GameObject gameObject = this.bodies[i].gameObject;
				if (gameObject)
				{
					Links.x.archives.RecycleBody(gameObject, this.bodies[i].model, this.bodyNames[i]);
					if (gameObject)
					{
						gameObject.SetActive(false);
					}
				}
			}
		}
	}

	// Token: 0x060008B4 RID: 2228 RVA: 0x000BCCAC File Offset: 0x000BAEAC
	private bool CannotOpen()
	{
		return Records.x.inMenus || !Links.x.gaia.sceneLoaded || Records.x.paused || Records.x.saving || Links.x.rtsCamera.puzzleTarget || (Links.x.combat.inRally || Links.x.combat.inPocketAttack);
	}

	// Token: 0x060008B5 RID: 2229 RVA: 0x000BCD34 File Offset: 0x000BAF34
	private bool Clicked()
	{
		if (Links.x.joy)
		{
			if (Links.x.gameplay.cancelStart)
			{
				return true;
			}
		}
		else if (Input.GetKeyUp(KeyCode.Space))
		{
			if (this.clickCount >= 0)
			{
				return true;
			}
			this.clickCount++;
		}
		return false;
	}

	// Token: 0x060008B6 RID: 2230 RVA: 0x000BCD84 File Offset: 0x000BAF84
	private void SetupSkipText()
	{
		this.skipText.spriteAsset = Links.x.GetSpriteSheetAsset(Links.x.gameplay.currentSpriteSheetAsset);
		this.str.Clear();
		if (Links.x.mk)
		{
			this.skipText.gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector3(-10f, 35f, 0f);
			this.str.Append("<voffset=.4em><size=60><sprite=");
			int keyIconIndex = Links.x.keyControl.GetKeyIconIndex("Space");
			this.str.Append(keyIconIndex);
			this.str.Append("></size></voffset>");
		}
		else
		{
			this.skipText.gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector3(-10f, 10f, 0f);
			this.str.Append("<voffset=.4em><size=40><sprite=");
			int controllerSprite = Links.x.gameplay.GetControllerSprite("Cancel", Links.x.gameplay.controllerName);
			this.str.Append(controllerSprite);
			this.str.Append("></size></voffset>");
		}
		this.str.Append("<cspace=1em></cspace>Continue");
		this.skipText.text = this.str.ToString();
		this.skipText.enabled = true;
	}

	// Token: 0x060008B7 RID: 2231 RVA: 0x000BCEF8 File Offset: 0x000BB0F8
	public void TurnOff()
	{
		foreach (GameObject gameObject in this.vignetteObjects)
		{
			gameObject.SetActive(false);
		}
		this.textAnimator.gameObject.SetActive(false);
		this.canvas.gameObject.SetActive(false);
	}

	// Token: 0x060008B8 RID: 2232 RVA: 0x000BCF6C File Offset: 0x000BB16C
	public void OpenPuzzleAfter(PuzzleActions p)
	{
		Debug.Log("Open puzzle after");
		this.puzzleActions = p;
	}

	// Token: 0x060008B9 RID: 2233 RVA: 0x000BCF80 File Offset: 0x000BB180
	public string GetQuest(string questName, out string a, out string b, out string c, out string d, out Sprite sprite)
	{
		a = "";
		b = "";
		c = "";
		d = "";
		sprite = this.empty;
		if (questName == "GoodHarvest_Quest" || questName == "Sela_Quest" || questName == "C6_Willowmaid" || questName == "D6_Chora")
		{
			string text = "Intercessions";
			int num = 16;
			int num2 = 2;
			int num3 = 5;
			for (int i = 0; i < this.currentParty.Count; i++)
			{
				this.str.Clear();
				Stats stats = this.currentParty[i].stats;
				this.str.Append(stats.GetName());
				this.str.Append(" gained health ");
				this.str.Append("[");
				this.str.Append(stats.HealthCurrent());
				this.str.Append("/");
				this.str.Append(stats.HealthMax());
				this.str.Append("] to [");
				stats.lifeBase += num2;
				stats.AddHealth(num2);
				this.str.Append(stats.HealthCurrent());
				this.str.Append("/");
				this.str.Append(stats.HealthMax());
				this.str.Append("] and increased ");
				this.str.Append(text);
				this.str.Append(" [");
				this.str.Append(stats.GetSkill(num));
				this.str.Append("] to [");
				stats.IncreaseSkill(num, num3);
				this.str.Append(stats.GetSkill(num));
				this.str.Append("]");
				if (i == 0)
				{
					a = this.str.ToString();
				}
				if (i == 1)
				{
					b = this.str.ToString();
				}
				if (i == 2)
				{
					c = this.str.ToString();
				}
				if (i == 3)
				{
					d = this.str.ToString();
				}
			}
			sprite = this.health;
			if (questName == "C6_Willowmaid")
			{
				return "Health increased!";
			}
			return "Blessed!";
		}
		else
		{
			if (questName == "C6_Chanter" || questName == "C6_Ghosts")
			{
				string text2 = "Aura";
				if (questName == "C6_Chanter")
				{
					text2 = "Aura";
					sprite = this.aura;
				}
				if (questName == "C6_Ghosts")
				{
					text2 = "Aura";
					sprite = this.aura;
				}
				for (int j = 0; j < this.currentParty.Count; j++)
				{
					this.str.Clear();
					Stats stats2 = this.currentParty[j].stats;
					this.str.Append(stats2.GetName());
					this.str.Append(" gained ");
					this.str.Append(text2);
					this.str.Append(" [");
					this.str.Append(stats2.GetStatOnly(text2));
					this.str.Append("] to [");
					stats2.AddStat(text2, 1f);
					this.str.Append(stats2.GetStatOnly(text2));
					this.str.Append("]");
					if (j == 0)
					{
						a = this.str.ToString();
					}
					if (j == 1)
					{
						b = this.str.ToString();
					}
					if (j == 2)
					{
						c = this.str.ToString();
					}
					if (j == 3)
					{
						d = this.str.ToString();
					}
				}
				return text2 + " increased!";
			}
			if (questName == "C6_DryadFlower")
			{
				for (int k = 0; k < this.currentParty.Count; k++)
				{
					this.str.Clear();
					Stats stats3 = this.currentParty[k].stats;
					this.str.Append(stats3.GetName());
					this.str.Append(" gained a stat token");
					stats3.LevelUpStats();
					if (k == 0)
					{
						a = this.str.ToString();
					}
					if (k == 1)
					{
						b = this.str.ToString();
					}
					if (k == 2)
					{
						c = this.str.ToString();
					}
					if (k == 3)
					{
						d = this.str.ToString();
					}
				}
				return "Stat tokens received!";
			}
			if (questName == "C5_Caravan" || questName == "C5_Blessed")
			{
				string text3 = "";
				int num4 = 0;
				int num5 = 5;
				string text4 = "";
				if (questName == "C5_Blessed")
				{
					num4 = 22;
					text3 = "Bartering";
					text4 = "Bartering increased!";
				}
				for (int l = 0; l < this.currentParty.Count; l++)
				{
					if (questName == "C5_Caravan")
					{
						float num6;
						string bestSkill = this.currentParty[l].stats.GetBestSkill("Weapon", out num6);
						num4 = this.currentParty[l].stats.MatchBestSkillToDialogueName(bestSkill);
						Debug.Log(num4.ToString() + " " + bestSkill);
						text3 = Links.x.manual.DisplayNameFromIndex(num4, this.currentParty[l]);
						text4 = "Weapon skills increased!";
					}
					this.str.Clear();
					Stats stats4 = this.currentParty[l].stats;
					this.str.Append(stats4.GetName());
					this.str.Append("'s ");
					this.str.Append(text3);
					this.str.Append(" increased ");
					this.str.Append("[");
					this.str.Append(stats4.GetSkill(num4));
					this.str.Append("] to [");
					stats4.IncreaseSkill(num4, num5);
					this.str.Append(stats4.GetSkill(num4));
					this.str.Append("]");
					if (l == 0)
					{
						a = this.str.ToString();
					}
					if (l == 1)
					{
						b = this.str.ToString();
					}
					if (l == 2)
					{
						c = this.str.ToString();
					}
					if (l == 3)
					{
						d = this.str.ToString();
					}
				}
				sprite = this.skill;
				return text4;
			}
			if (questName == "")
			{
				for (int m = 0; m < this.currentParty.Count; m++)
				{
					this.str.Clear();
					Stats stats5 = this.currentParty[m].stats;
					this.str.Append(stats5.GetName());
					this.str.Append("'s sight improved ");
					this.str.Append("[");
					this.str.Append(stats5.sightRadiusBase);
					this.str.Append("] to [");
					stats5.sightRadiusBase += 1f;
					this.str.Append(stats5.sightRadiusBase);
					this.str.Append("]");
					if (m == 0)
					{
						a = this.str.ToString();
					}
					if (m == 1)
					{
						b = this.str.ToString();
					}
					if (m == 2)
					{
						c = this.str.ToString();
					}
					if (m == 3)
					{
						d = this.str.ToString();
					}
				}
				sprite = this.sight;
				return "Vision extended!";
			}
			if (questName == "C6_WitchTask")
			{
				int num7 = 3;
				float num8 = 4f;
				for (int n = 0; n < this.currentParty.Count; n++)
				{
					this.str.Clear();
					Stats stats6 = this.currentParty[n].stats;
					this.str.Append(stats6.GetName());
					this.str.Append(" gained health ");
					this.str.Append("[");
					this.str.Append(stats6.HealthCurrent());
					this.str.Append("/");
					this.str.Append(stats6.HealthMax());
					this.str.Append("] to [");
					stats6.lifeBase += num7;
					stats6.AddHealth(num7);
					this.str.Append(stats6.HealthCurrent());
					this.str.Append("/");
					this.str.Append(stats6.HealthMax());
					this.str.Append("] and increased max stamina");
					this.str.Append(" [");
					this.str.Append(stats6.MaxStamina());
					this.str.Append("] to [");
					stats6.maxStaminaAdd += num8;
					this.str.Append(stats6.MaxStamina());
					this.str.Append("]");
					if (n == 0)
					{
						a = this.str.ToString();
					}
					if (n == 1)
					{
						b = this.str.ToString();
					}
					if (n == 2)
					{
						c = this.str.ToString();
					}
					if (n == 3)
					{
						d = this.str.ToString();
					}
				}
				sprite = this.health;
				return "Health and Stamina increased!";
			}
			if (questName == "D5_Dura")
			{
				string text5 = "Strength";
				string text6 = "Bartering";
				int num9 = 22;
				int num10 = 5;
				int num11 = 2;
				bool flag = true;
				bool flag2 = true;
				if (Links.x.dialogue.GetVariableBool("D5_UsedBell"))
				{
					flag = false;
				}
				if (!Links.x.dialogue.GetVariableBool("D5_GaveHead"))
				{
					flag2 = false;
				}
				for (int num12 = 0; num12 < this.currentParty.Count; num12++)
				{
					this.str.Clear();
					Stats stats7 = this.currentParty[num12].stats;
					this.str.Append(stats7.GetName());
					this.str.Append(" gained health ");
					this.str.Append("[");
					this.str.Append(stats7.HealthCurrent());
					this.str.Append("/");
					this.str.Append(stats7.HealthMax());
					this.str.Append("] to [");
					stats7.lifeBase += num11;
					stats7.AddHealth(num11);
					this.str.Append(stats7.HealthCurrent());
					this.str.Append("/");
					this.str.Append(stats7.HealthMax());
					this.str.Append("]");
					if (num12 == 0)
					{
						a = this.str.ToString();
					}
					if (num12 == 1)
					{
						b = this.str.ToString();
					}
					if (num12 == 2)
					{
						c = this.str.ToString();
					}
					if (num12 == 3)
					{
						d = this.str.ToString();
					}
					if (flag)
					{
						this.str.Append(",");
						this.str.Append(" gained ");
						this.str.Append(text5);
						this.str.Append(" [");
						this.str.Append(stats7.GetStatOnly(text5));
						this.str.Append("] to [");
						stats7.AddStat(text5, 1f);
						this.str.Append(stats7.GetStatOnly(text5));
						this.str.Append("]");
						if (num12 == 0)
						{
							a = this.str.ToString();
						}
						if (num12 == 1)
						{
							b = this.str.ToString();
						}
						if (num12 == 2)
						{
							c = this.str.ToString();
						}
						if (num12 == 3)
						{
							d = this.str.ToString();
						}
					}
					if (flag2)
					{
						this.str.Append(",");
						this.str.Append(" increased ");
						this.str.Append(text6);
						this.str.Append(" [");
						this.str.Append(stats7.GetSkill(num9));
						this.str.Append("] to [");
						stats7.IncreaseSkill(num9, num10);
						this.str.Append(stats7.GetSkill(num9));
						this.str.Append("]");
						if (num12 == 0)
						{
							a = this.str.ToString();
						}
						if (num12 == 1)
						{
							b = this.str.ToString();
						}
						if (num12 == 2)
						{
							c = this.str.ToString();
						}
						if (num12 == 3)
						{
							d = this.str.ToString();
						}
					}
				}
				sprite = this.health;
				if (!flag && !flag2)
				{
					return "Health increased!";
				}
				if (flag && !flag2)
				{
					return "Health and Strength increased!";
				}
				if (!flag && flag2)
				{
					return "Health and Bartering increased!";
				}
				if (flag && flag2)
				{
					return "Health, Strength and Bartering increased!";
				}
			}
			if (questName == "D6_Licech")
			{
				string text7 = "Sneaking";
				string text8 = "Lockpick";
				int num13 = 21;
				int num14 = 20;
				int num15 = 5;
				for (int num16 = 0; num16 < this.currentParty.Count; num16++)
				{
					this.str.Clear();
					Stats stats8 = this.currentParty[num16].stats;
					this.str.Append(stats8.GetName());
					this.str.Append("'s ");
					this.str.Append(text8);
					this.str.Append(" increased [");
					this.str.Append(stats8.GetSkill(num13));
					this.str.Append("] to [");
					stats8.IncreaseSkill(num13, num15);
					this.str.Append(stats8.GetSkill(num13));
					this.str.Append("]");
					if (num16 == 0)
					{
						a = this.str.ToString();
					}
					if (num16 == 1)
					{
						b = this.str.ToString();
					}
					if (num16 == 2)
					{
						c = this.str.ToString();
					}
					if (num16 == 3)
					{
						d = this.str.ToString();
					}
					this.str.Append(",");
					this.str.Append("'s ");
					this.str.Append(text7);
					this.str.Append(" increased [");
					this.str.Append(stats8.GetSkill(num14));
					this.str.Append("] to [");
					stats8.IncreaseSkill(num14, num15);
					this.str.Append(stats8.GetSkill(num14));
					this.str.Append("]");
					if (num16 == 0)
					{
						a = this.str.ToString();
					}
					if (num16 == 1)
					{
						b = this.str.ToString();
					}
					if (num16 == 2)
					{
						c = this.str.ToString();
					}
					if (num16 == 3)
					{
						d = this.str.ToString();
					}
				}
				sprite = this.skill;
				return "Lockpicking and Sneaking increased!";
			}
			if (questName.Contains("D6_Spy"))
			{
				string text9 = "Sensory";
				int num17 = 2;
				bool flag3 = false;
				if (questName.Contains("Informant"))
				{
					flag3 = true;
				}
				for (int num18 = 0; num18 < this.currentParty.Count; num18++)
				{
					this.str.Clear();
					Stats stats9 = this.currentParty[num18].stats;
					this.str.Append(stats9.GetName());
					this.str.Append(" gained health ");
					this.str.Append("[");
					this.str.Append(stats9.HealthCurrent());
					this.str.Append("/");
					this.str.Append(stats9.HealthMax());
					this.str.Append("] to [");
					stats9.lifeBase += num17;
					stats9.AddHealth(num17);
					this.str.Append(stats9.HealthCurrent());
					this.str.Append("/");
					this.str.Append(stats9.HealthMax());
					this.str.Append("]");
					if (num18 == 0)
					{
						a = this.str.ToString();
					}
					if (num18 == 1)
					{
						b = this.str.ToString();
					}
					if (num18 == 2)
					{
						c = this.str.ToString();
					}
					if (num18 == 3)
					{
						d = this.str.ToString();
					}
					if (flag3)
					{
						this.str.Append(",");
						this.str.Append(" gained ");
						this.str.Append(text9);
						this.str.Append(" [");
						this.str.Append(stats9.GetStatOnly(text9));
						this.str.Append("] to [");
						stats9.AddStat(text9, 1f);
						this.str.Append(stats9.GetStatOnly(text9));
						this.str.Append("]");
						if (num18 == 0)
						{
							a = this.str.ToString();
						}
						if (num18 == 1)
						{
							b = this.str.ToString();
						}
						if (num18 == 2)
						{
							c = this.str.ToString();
						}
						if (num18 == 3)
						{
							d = this.str.ToString();
						}
					}
				}
				sprite = this.health;
				if (!flag3)
				{
					return "Health increased!";
				}
				if (flag3)
				{
					return "Health and Sensory increased!";
				}
			}
			if (questName.Contains("D6_GoblinHole"))
			{
				int num19 = 5;
				string text10 = "";
				for (int num20 = 0; num20 < this.currentParty.Count; num20++)
				{
					float num21;
					string bestSkill2 = this.currentParty[num20].stats.GetBestSkill("Weapon", out num21);
					int num22 = this.currentParty[num20].stats.MatchBestSkillToDialogueName(bestSkill2);
					Debug.Log(num22.ToString() + " " + bestSkill2);
					string text11 = Links.x.manual.DisplayNameFromIndex(num22, this.currentParty[num20]);
					text10 = "Weapon skills increased!";
					this.str.Clear();
					Stats stats10 = this.currentParty[num20].stats;
					this.str.Append(stats10.GetName());
					this.str.Append("'s ");
					this.str.Append(text11);
					this.str.Append(" increased ");
					this.str.Append("[");
					this.str.Append(stats10.GetSkill(num22));
					this.str.Append("] to [");
					stats10.IncreaseSkill(num22, num19);
					this.str.Append(stats10.GetSkill(num22));
					this.str.Append("]");
					if (num20 == 0)
					{
						a = this.str.ToString();
					}
					if (num20 == 1)
					{
						b = this.str.ToString();
					}
					if (num20 == 2)
					{
						c = this.str.ToString();
					}
					if (num20 == 3)
					{
						d = this.str.ToString();
					}
				}
				sprite = this.skill;
				return text10;
			}
			return "Health increased!";
		}
	}

	// Token: 0x04000D91 RID: 3473
	public List<GameObject> vignetteObjects = new List<GameObject>();

	// Token: 0x04000D92 RID: 3474
	public Animator animator;

	// Token: 0x04000D93 RID: 3475
	public Animator textAnimator;

	// Token: 0x04000D94 RID: 3476
	public Animator feedAnimator;

	// Token: 0x04000D95 RID: 3477
	public TextMeshProUGUI skipText;

	// Token: 0x04000D96 RID: 3478
	public Transform spot1;

	// Token: 0x04000D97 RID: 3479
	public Transform spot2;

	// Token: 0x04000D98 RID: 3480
	public Transform spot3;

	// Token: 0x04000D99 RID: 3481
	public Transform spot4;

	// Token: 0x04000D9A RID: 3482
	private StringFast str = new StringFast(32);

	// Token: 0x04000D9B RID: 3483
	private int clickCount;

	// Token: 0x04000D9C RID: 3484
	private int w;

	// Token: 0x04000D9D RID: 3485
	private int h;

	// Token: 0x04000D9E RID: 3486
	private int qualitySettings;

	// Token: 0x04000D9F RID: 3487
	public RenderTexture renderTexture;

	// Token: 0x04000DA0 RID: 3488
	public Camera cam;

	// Token: 0x04000DA1 RID: 3489
	public CanvasGroup canvas;

	// Token: 0x04000DA2 RID: 3490
	public RawImage img;

	// Token: 0x04000DA3 RID: 3491
	private TextMeshPro[] texts = new TextMeshPro[0];

	// Token: 0x04000DA4 RID: 3492
	public TextMeshProUGUI[] feedTexts = new TextMeshProUGUI[0];

	// Token: 0x04000DA5 RID: 3493
	public Image[] imgs = new Image[0];

	// Token: 0x04000DA6 RID: 3494
	public RectTransform[] rects = new RectTransform[0];

	// Token: 0x04000DA7 RID: 3495
	private List<Body> bodies = new List<Body>();

	// Token: 0x04000DA8 RID: 3496
	private List<string> bodyNames = new List<string>();

	// Token: 0x04000DA9 RID: 3497
	public AnimatorOverrideController levelUpController;

	// Token: 0x04000DAA RID: 3498
	private List<Character> party;

	// Token: 0x04000DAB RID: 3499
	private List<Character> currentParty = new List<Character>();

	// Token: 0x04000DAC RID: 3500
	private List<string> anims;

	// Token: 0x04000DAD RID: 3501
	public Light l;

	// Token: 0x04000DAE RID: 3502
	public Sprite empty;

	// Token: 0x04000DAF RID: 3503
	public Sprite health;

	// Token: 0x04000DB0 RID: 3504
	public Sprite skill;

	// Token: 0x04000DB1 RID: 3505
	public Sprite strength;

	// Token: 0x04000DB2 RID: 3506
	public Sprite dexterity;

	// Token: 0x04000DB3 RID: 3507
	public Sprite agility;

	// Token: 0x04000DB4 RID: 3508
	public Sprite pagan;

	// Token: 0x04000DB5 RID: 3509
	public Sprite sensory;

	// Token: 0x04000DB6 RID: 3510
	public Sprite aura;

	// Token: 0x04000DB7 RID: 3511
	public Sprite sight;

	// Token: 0x04000DB8 RID: 3512
	public bool on;

	// Token: 0x04000DB9 RID: 3513
	public PuzzleActions puzzleActions;
}
