using System;
using System.Collections;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
using Pathfinding;
using PixelCrushers.DialogueSystem;
using UnityEngine;
using UnityEngine.EventSystems;

// Token: 0x02000083 RID: 131
public class Cinematics : MonoBehaviour
{
	// Token: 0x06000CAC RID: 3244 RVA: 0x000F84D8 File Offset: 0x000F66D8
	public void StartBanquetIsle()
	{
		base.StartCoroutine(this.StartOfBanquetIsle());
	}

	// Token: 0x06000CAD RID: 3245 RVA: 0x000F84E7 File Offset: 0x000F66E7
	private IEnumerator StartOfBanquetIsle()
	{
		Records.x.RemoveControls(true);
		Links.x.hudControl.ChangeHudVisibility(false, false);
		Records.x.SetTypingState(true);
		this.videoFinished = false;
		yield return new WaitForSeconds(0.3f);
		Links.x.cinematicVideos.Setup("Throat", this);
		yield return new WaitForSeconds(0.5f);
		Links.x.gaia.PlayFade("In", "Scaled");
		while (!this.videoFinished)
		{
			if (Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeOut") || Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeOutLoop"))
			{
				Links.x.gaia.PlayFade("In", "Scaled");
			}
			yield return null;
		}
		if (!Records.x.demo && new ES3File("Version.es3").KeyExists("FinishedIntro"))
		{
			Links.x.hudControl.skipIntro.SetActive(true);
			if (Links.x.joy)
			{
				yield return new WaitForSecondsRealtime(0.5f);
				GameObject go = Links.x.hudControl.skipIntro.transform.GetChild(0).GetChild(2).gameObject;
				while (!go.activeSelf || !go.activeInHierarchy)
				{
					yield return null;
				}
				EventSystem.current.SetSelectedGameObject(go);
				go.GetComponent<UITriggerButton>().SetSelected(true);
				go = null;
			}
			while (Links.x.hudControl.skipIntro.activeSelf)
			{
				yield return null;
			}
			if (Links.x.joy)
			{
				EventSystem.current.SetSelectedGameObject(null);
			}
		}
		Links.x.hudControl.JoyBox(false);
		if (!Links.x.hudControl.skippingIntro)
		{
			Records.x.RemoveControls(false);
			Links.x.hudControl.ChangeHudVisibility(true, true);
			Links.x.cameraEffects.ToggleObscurance();
			Shader.SetGlobalFloat("_CloseUp", 0f);
			Shader.SetGlobalFloat("_Perspective", 0f);
			Records.x.SetTypingState(false);
			Records.x.TriggerGlobalSave("CheckpointSave", true);
			Records.x.RemoveControls(false);
			Links.x.gaia.CheckForNewSoundtrack("Banquet Isle", false, false);
		}
		Links.x.hudControl.skippingIntro = false;
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CAE RID: 3246 RVA: 0x000F84F6 File Offset: 0x000F66F6
	public void Ishaat(PromptActions prompt)
	{
		base.StartCoroutine(this.EndOfBanquet(prompt));
	}

	// Token: 0x06000CAF RID: 3247 RVA: 0x000F8506 File Offset: 0x000F6706
	private IEnumerator EndOfBanquet(PromptActions prompt)
	{
		Character hunter = null;
		int num = 10000000;
		List<Character> party = Links.x.party;
		for (int j = 0; j < party.Count; j++)
		{
			if (party[j])
			{
				int partyID = party[j].stats.partyID;
				if (partyID < num)
				{
					num = partyID;
					hunter = party[j];
				}
			}
		}
		while (Links.x.combat.inPocketAttack || Links.x.combat.inRally)
		{
			if (!Records.x.combat)
			{
				break;
			}
			yield return null;
		}
		while (Records.x.inMenus)
		{
			yield return null;
		}
		if (Links.x.main.cc)
		{
			Links.x.main.cc.enabled = false;
		}
		Records.x.RemoveControls(true);
		Links.x.hudControl.ChangeHudVisibility(false, false);
		Records.x.SetTypingState(true);
		if (Records.x.combat)
		{
			if (Records.x.pocketPause)
			{
				Links.x.gameplay.PocketPause(false);
			}
			List<Character> combatCharacters = Links.x.combat.characters;
			GraphNode i = Links.x.main.NearNode(Links.x.diorama.playerStartDefault.position, false, 0, -1, 0);
			for (int k = 0; k < combatCharacters.Count; k++)
			{
				if (combatCharacters[k] && combatCharacters[k] != hunter)
				{
					if (i != null)
					{
						combatCharacters[k].StartFleeAroundPoint(i);
						combatCharacters[k].ignoreRemoveControls = true;
						combatCharacters[k].ClearLKP();
						if (combatCharacters[k].actions)
						{
							combatCharacters[k].actions.EndActions();
						}
					}
					else
					{
						combatCharacters[k].stats.SetHealth(0, false);
						combatCharacters[k].Stunned(false);
					}
				}
			}
			yield return new WaitForSeconds(0.01f);
			for (int l = 0; l < combatCharacters.Count; l++)
			{
				if (combatCharacters[l] && combatCharacters[l] != hunter)
				{
					if (i != null)
					{
						combatCharacters[l].StartFleeAroundPoint(i);
						combatCharacters[l].ignoreRemoveControls = true;
						combatCharacters[l].ClearLKP();
						if (combatCharacters[l].actions)
						{
							combatCharacters[l].actions.EndActions();
						}
					}
					else
					{
						combatCharacters[l].stats.SetHealth(0, false);
						combatCharacters[l].Stunned(false);
					}
				}
			}
			hunter.ClearLKP();
			if (hunter.actions)
			{
				hunter.actions.EndActions();
			}
			Links.x.combat.EndCombat(false);
			hunter.StopMoving();
			hunter.sphere.transform.position = hunter.tr.position;
			hunter.savedPathTarget = hunter.node;
			hunter.savedFollowNode = hunter.node;
			hunter.TargetReached();
			if (hunter.cc)
			{
				hunter.cc.enabled = false;
			}
			combatCharacters = null;
			i = null;
		}
		Records.x.combat = false;
		prompt.state = 2;
		Links.x.gaia.PlayFade("Out", "Unscaled");
		this.videoFinished = false;
		yield return new WaitForSeconds(0.3f);
		Links.x.cinematicVideos.Setup("Standoff", this);
		while (!this.videoFinished)
		{
			yield return null;
		}
		Records.x.SetTypingState(false);
		Links.x.gameplay.gameHours = 5f;
		Links.x.gameplay.gameMinutes = 300f;
		Links.x.gameplay.gameSeconds = 18000f;
		Links.x.gameplay.gameDays = 0;
		Links.x.inventory.emeralds = 0;
		Links.x.fellowship.rally = 0f;
		Links.x.fellowship.rallyBoost = 0f;
		Links.x.fellowship.rallyAttacks = 0f;
		Links.x.gameplay.LoadGameTime();
		Links.x.gaia.SwitchToCharacterCreationScene();
		ES3File es3File = new ES3File("Version.es3");
		es3File.Save<bool>("FinishedIntro", true);
		es3File.Sync();
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CB0 RID: 3248 RVA: 0x000F851C File Offset: 0x000F671C
	public void EndDemoMessage()
	{
		base.StartCoroutine(this.EndDemoMessageWait());
	}

	// Token: 0x06000CB1 RID: 3249 RVA: 0x000F852B File Offset: 0x000F672B
	private IEnumerator EndDemoMessageWait()
	{
		Links.x.hudControl.demoMessage.SetActive(true);
		Links.x.hudControl.demoMessage.GetComponent<DeathScreen>().Setup();
		while (!this.Clicked())
		{
			yield return null;
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CB2 RID: 3250 RVA: 0x000F853A File Offset: 0x000F673A
	public void StartDemo()
	{
		base.StartCoroutine(this.DemoStart());
	}

	// Token: 0x06000CB3 RID: 3251 RVA: 0x000F854C File Offset: 0x000F674C
	private bool Clicked()
	{
		if (Links.x.joy)
		{
			if (Links.x.gameplay.cancelStart || Links.x.gameplay.actionStart || Links.x.gameplay.interactStart)
			{
				return true;
			}
		}
		else if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return))
		{
			return true;
		}
		return false;
	}

	// Token: 0x06000CB4 RID: 3252 RVA: 0x000F85BF File Offset: 0x000F67BF
	private IEnumerator DemoStart()
	{
		Records.x.RemoveControls(true);
		Links.x.hudControl.ChangeHudVisibility(false, false);
		Records.x.SetTypingState(true);
		this.videoFinished = false;
		while (!Links.x.gaia.sceneLoaded)
		{
			yield return null;
		}
		bool flag = false;
		if (!Records.x.editor)
		{
			flag = false;
		}
		GameObject gameObject = GameObject.Find("Mihal the Scribe CC");
		Character npc = gameObject.GetComponent<CreatureActions>().GetFirstCharacter();
		List<Character> allCharacters = Links.x.diorama.characters;
		GameObject gameObject2 = GameObject.Find("Fake Guard A");
		GameObject gameObject3 = GameObject.Find("Fake Guard B");
		GameObject gameObject4 = GameObject.Find("Fake Guard C");
		GameObject gameObject5 = GameObject.Find("Fake Guard D");
		CreatureActions creatureA = gameObject2.GetComponent<CreatureActions>();
		CreatureActions creatureB = gameObject3.GetComponent<CreatureActions>();
		CreatureActions creatureC = gameObject4.GetComponent<CreatureActions>();
		CreatureActions creatureD = gameObject5.GetComponent<CreatureActions>();
		if (!flag)
		{
			Links.x.cinematicVideos.Setup("Flyover", this);
			Links.x.gaia.PlayFade("Out", "Unscaled");
			npc.ambushing = true;
			npc.SetMeshState(false);
			npc.body.SetMeshState(false, false);
			while (!this.videoFinished)
			{
				if (Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeIn") || Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeInLoop"))
				{
					Links.x.gaia.PlayFade("Out", "Unscaled");
				}
				yield return null;
			}
			Links.x.gameplay.TogglePause(false);
			yield return new WaitForSeconds(0.2f);
			Character barkeep = Links.x.diorama.FindCharacterAnyState("LazureBarkeep");
			Character character = Links.x.diorama.FindCharacterAnyState("LazureBarmaid");
			Character duraPatron = Links.x.diorama.FindCharacterAnyState("LazurePatronDuraMessenger");
			Character mercPatron = Links.x.diorama.FindCharacterAnyState("LazurePatronMerc");
			Character patronC = Links.x.diorama.FindCharacterAnyState("LazureBarPatronC");
			Character patronD = Links.x.diorama.FindCharacterAnyState("LazureBarPatronD");
			Character patronE = Links.x.diorama.FindCharacterAnyState("LazureBarPatronE");
			Character fakeGuardA = creatureA.GetFirstCharacter();
			Character fakeGuardB = creatureB.GetFirstCharacter();
			creatureC.GetFirstCharacter();
			creatureD.GetFirstCharacter();
			character.tr.position = (Vector3)character.creatures.GetWalkIndex(0).position;
			character.FirstPosition(character.creatures.GetWalkIndex(0));
			character.ignoreRemoveControls = true;
			List<Character> portraitOrder = Links.x.portraitOrder;
			int count2 = portraitOrder.Count;
			for (int j = 0; j < count2; j++)
			{
				Character character2 = portraitOrder[j];
				character2.SetRotation(Quaternion.LookRotation(npc.tr.position - character2.tr.position), false, true);
			}
			Links.x.gameplay.gameHours = 5f;
			Links.x.gameplay.gameMinutes = 300f;
			Links.x.gameplay.gameSeconds = 18000f;
			Links.x.gameplay.gameDays = 0;
			Links.x.gaia.SetPlaylist("Garrison", true, 0f);
			for (int k = 0; k < allCharacters.Count; k++)
			{
				Character character3 = allCharacters[k];
				if (character3 && character3.npc && (character3.tr.position - npc.tr.position).sqrMagnitude < 2500f && character3 != npc && character3 != barkeep)
				{
					character3.ignoreRemoveControls = true;
				}
			}
			character.MakePath(character.creatures.GetWalkIndex(1), 4, false, false, true);
			yield return new WaitForSeconds(0.5f);
			patronD.PlayAnimation("Talk_1", 0f);
			mercPatron.PatrolRotate();
			patronE.PlayAnimation("Talk_2", 0f);
			fakeGuardA.PlayAnimation("Talk_3", 0f);
			mercPatron.PlayAnimation("Talk_3", 0f);
			patronE.PatrolRotate();
			duraPatron.PlayAnimation("Talk_2", 0f);
			yield return new WaitForSeconds(0.5f);
			Links.x.gaia.PlayFade("In", "Scaled");
			yield return new WaitForSeconds(0.5f);
			fakeGuardB.PatrolRotate();
			yield return new WaitForSeconds(1.5f);
			MasterAudio.PlaySound3DAtVector3AndForget("Interactives", npc.tr.position, 1f, new float?(1f), 0f, "Opening Door", null);
			patronC.PlayAnimation("Talk_1", 0f);
			npc.ambushing = false;
			npc.SetMeshState(true);
			npc.body.SetMeshState(true, true);
			npc.PlayAnimation("Idle", 0f);
			yield return new WaitForSeconds(1f);
			npc.ignoreRemoveControls = true;
			npc.StartQuip("Hold your tongues and still your mead!");
			npc.body.headAnim.FreshBlink();
			yield return new WaitForSeconds(1f);
			patronD.PlayAnimation("Talk_1", 0f);
			yield return new WaitForSeconds(0.5f);
			mercPatron.PatrolRotate();
			float timeToLerp = 1f;
			float percentage = 0f;
			float startTime = Time.time;
			float count = 0f;
			int num2;
			for (int i = 0; i < allCharacters.Count; i = num2 + 1)
			{
				Character character4 = allCharacters[i];
				if (character4 && character4.npc && character4.visible == 1 && character4 != npc && character4 != barkeep)
				{
					character4.alwaysTurn = true;
					character4.SetRotation(Quaternion.LookRotation(npc.tr.position - character4.tr.position), true, false);
					float num = Random.Range(0.1f, 0.25f);
					count += num;
					if (!this.Clicked())
					{
						yield return new WaitForSeconds(num);
					}
				}
				num2 = i;
			}
			timeToLerp = 4f - count;
			percentage = 0f;
			startTime = Time.time;
			if (timeToLerp < 0f)
			{
				timeToLerp = 0.1f;
			}
			while (percentage < 1f && !this.Clicked())
			{
				percentage = (Time.time - startTime) / timeToLerp;
				yield return null;
			}
			barkeep.ignoreRemoveControls = false;
			count = 0f;
			npc.ignoreRemoveControls = true;
			npc.PlayAnimation("Talk_1", 0f);
			npc.StartQuip("The Pavura needs four guards, who will answer his call?");
			timeToLerp = 4f;
			percentage = 0f;
			startTime = Time.time;
			while (percentage < 1f && !this.Clicked())
			{
				percentage = (Time.time - startTime) / timeToLerp;
				yield return null;
			}
			npc.EndQuip();
			barkeep = null;
			duraPatron = null;
			mercPatron = null;
			patronC = null;
			patronD = null;
			patronE = null;
			fakeGuardA = null;
			fakeGuardB = null;
		}
		Links.x.gaia.OpenCharacterCreation(true, npc, null);
		yield return new WaitForSeconds(0.5f);
		npc.SetRotation(Quaternion.LookRotation(Links.x.main.tr.position - npc.tr.position), false, true);
		while (Links.x.creation)
		{
			yield return null;
		}
		Links.x.cameraEffects.ToggleObscurance();
		for (int l = 0; l < allCharacters.Count; l++)
		{
			Character character5 = allCharacters[l];
			if (character5 != npc && character5 && character5.party)
			{
				character5.SetRotation(Quaternion.LookRotation(npc.tr.position - character5.tr.position), false, true);
			}
		}
		Links.x.gaia.PlayFade("In", "Scaled");
		Records.x.RemoveControls(true);
		Links.x.gameplay.TogglePause(false);
		Links.x.cameraEffects.ToggleObscurance();
		float timeToLerp2 = 2f;
		float percentage2 = 0f;
		float startTime2 = Time.time;
		while (percentage2 < 1f)
		{
			if (this.Clicked())
			{
				break;
			}
			percentage2 = (Time.time - startTime2) / timeToLerp2;
			yield return null;
		}
		while (this.Clicked())
		{
			yield return null;
		}
		npc.ignoreRemoveControls = true;
		npc.StartQuip("Make haste, and follow me! The Pavura awaits you.");
		timeToLerp2 = 5f;
		percentage2 = 0f;
		startTime2 = Time.time;
		while (percentage2 < 1f && !this.Clicked())
		{
			percentage2 = (Time.time - startTime2) / timeToLerp2;
			yield return null;
		}
		for (int m = 0; m < allCharacters.Count; m++)
		{
			Character character6 = allCharacters[m];
			if (character6 && character6.npc)
			{
				character6.ignoreRemoveControls = false;
			}
		}
		Records.x.StartUIFade(false, false);
		yield return new WaitForSeconds(0.5f);
		if (creatureA)
		{
			creatureA.GetFirstCharacter().Missing();
		}
		if (creatureB)
		{
			creatureB.GetFirstCharacter().Missing();
		}
		if (creatureC)
		{
			creatureC.GetFirstCharacter().Missing();
		}
		if (creatureD)
		{
			creatureD.GetFirstCharacter().Missing();
		}
		Links.x.gaia.EndCharacterCreation();
		Records.x.SetTypingState(false);
		Links.x.cameraEffects.ToggleObscurance();
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CB5 RID: 3253 RVA: 0x000F85CE File Offset: 0x000F67CE
	public void EndDemoInOffice()
	{
		base.StartCoroutine(this.EndDemoInOfficeTimer());
	}

	// Token: 0x06000CB6 RID: 3254 RVA: 0x000F85DD File Offset: 0x000F67DD
	private IEnumerator EndDemoInOfficeTimer()
	{
		while (Links.x.combat.inPocketAttack || Links.x.combat.inRally)
		{
			if (!Records.x.combat)
			{
				break;
			}
			yield return null;
		}
		while (Records.x.combat)
		{
			yield return null;
		}
		while (Records.x.inMenus)
		{
			yield return null;
		}
		Records.x.RemoveControls(true);
		Records.x.SetTypingState(true);
		Links.x.hudControl.StartDemoIntro();
		float timeToLerp = 1f;
		float percentage = 0f;
		float startTime = Time.realtimeSinceStartup;
		while (percentage < 1f)
		{
			percentage = (Time.realtimeSinceStartup - startTime) / timeToLerp;
			yield return null;
		}
		timeToLerp = 10f;
		percentage = 0f;
		startTime = Time.realtimeSinceStartup;
		while (percentage < 1f && !this.Clicked())
		{
			percentage = (Time.realtimeSinceStartup - startTime) / timeToLerp;
			yield return null;
		}
		Object.Destroy(this);
		Links.x.hudControl.EndDemoIntro();
		Records.x.RemoveControls(false);
		Records.x.SetTypingState(false);
		yield break;
	}

	// Token: 0x06000CB7 RID: 3255 RVA: 0x000F85EC File Offset: 0x000F67EC
	public void EndDemo()
	{
		base.StartCoroutine(this.DemoEnd());
	}

	// Token: 0x06000CB8 RID: 3256 RVA: 0x000F85FB File Offset: 0x000F67FB
	private IEnumerator DemoEnd()
	{
		while (Links.x.combat.inPocketAttack || Links.x.combat.inRally)
		{
			if (!Records.x.combat)
			{
				break;
			}
			yield return null;
		}
		while (Records.x.inMenus)
		{
			yield return null;
		}
		if (Links.x.main.cc)
		{
			Links.x.main.cc.enabled = false;
		}
		yield return new WaitForSeconds(0.5f);
		Records.x.TriggerGlobalSave("CheckpointSave", true);
		yield return new WaitForSeconds(0.5f);
		Records.x.RemoveControls(true);
		Links.x.hudControl.ChangeHudVisibility(false, false);
		Links.x.hudControl.demoMessage.SetActive(true);
		Links.x.hudControl.demoMessage.GetComponent<DeathScreen>().Setup();
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CB9 RID: 3257 RVA: 0x000F860A File Offset: 0x000F680A
	public void StartPavuraWalk()
	{
		if (this.pavuraWalk == null)
		{
			this.pavuraWalk = this.PavuraWalk();
			base.StartCoroutine(this.pavuraWalk);
		}
	}

	// Token: 0x06000CBA RID: 3258 RVA: 0x000F862D File Offset: 0x000F682D
	private IEnumerator PavuraWalk()
	{
		if (Records.x.paused)
		{
			Links.x.gameplay.TogglePause(false);
		}
		Shader.SetGlobalFloat("_CloseUp", 1f);
		Shader.SetGlobalFloat("_Perspective", 1f);
		Links.x.gaia.PlayFade("Out", "Scaled");
		yield return new WaitForSeconds(0.2f);
		Links.x.diorama.FindCharacterAnyState("LazureScribeCC").Leave(false);
		Links.x.gaia.SetEnvironmentPlaylist(false, false, false);
		Links.x.gaia.SetPlaylist("Lazure", true, 0f);
		List<Character> party = Links.x.portraitOrder;
		int partyCount = party.Count;
		int num;
		for (int i = 0; i < partyCount; i = num + 1)
		{
			Character character = party[i];
			GameObject pavuraOfficePoint = GameObject.Find("Jump_Pavura Office Point " + i.ToString());
			GraphNode graphNode = character.NearNode(pavuraOfficePoint.transform.position, true, 0, -1, 0);
			if (graphNode != null)
			{
				Links.x.sensory.SetMagicaClothState(false);
				this.MovePosition(character, graphNode, true);
				yield return new WaitForSeconds(0.001f);
				Links.x.sensory.SetMagicaClothState(true);
			}
			character.SetRotation(pavuraOfficePoint.transform.rotation, false, true);
			character = null;
			pavuraOfficePoint = null;
			num = i;
		}
		Links.x.cameraEffects.ToggleInteriorExterior(Links.x.main);
		bool isFollowing = Links.x.rtsCamera.IsFollowing;
		Links.x.rtsCamera.Follow(Links.x.main.tr, Links.x.main, true);
		Links.x.rtsCamera.JumpTo(Links.x.main.tr, true);
		Links.x.main.SetAsLeader();
		yield return new WaitForSeconds(0.5f);
		Character pavura = Links.x.diorama.FindCharacterAnyState("Pavura");
		pavura.SetRotation(Quaternion.LookRotation(pavura.tr.position - Links.x.main.tr.position), false, true);
		Links.x.diorama.ToggleSceneCameras(true, "C");
		Links.x.rtsCamera.CopyPerspectiveCamera(Links.x.diorama.activeView.sceneCamera, null, pavura);
		yield return new WaitForSeconds(0.1f);
		pavura.SetRotation(Quaternion.LookRotation(pavura.tr.position - Links.x.main.tr.position), false, true);
		yield return new WaitForSeconds(0.1f);
		pavura.SetRotation(Quaternion.LookRotation(pavura.tr.position - Links.x.main.tr.position), false, true);
		yield return new WaitForSeconds(0.1f);
		pavura.SetRotation(Quaternion.LookRotation(pavura.tr.position - Links.x.main.tr.position), false, true);
		yield return new WaitForSeconds(0.1f);
		pavura.SetRotation(Quaternion.LookRotation(pavura.tr.position - Links.x.main.tr.position), false, true);
		if (Links.x.cameraEffects.gameFade.enabled)
		{
			Links.x.cameraEffects.FinishFade();
		}
		Links.x.gaia.PlayFade("In", "Scaled");
		Links.x.follow.position = Links.x.main.tr.position + new Vector3(0f, 3f, 0f);
		yield return new WaitForSeconds(3f);
		Links.x.gameplay.StartDialogue(pavura, Links.x.main, null, null, pavura.stats.dialogueFile);
		yield return new WaitForSeconds(3f);
		pavura.SetRotation(Quaternion.LookRotation(Links.x.main.tr.position - pavura.tr.position), false, true);
		this.pavuraWalk = null;
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CBB RID: 3259 RVA: 0x000F863C File Offset: 0x000F683C
	public void EndPavura()
	{
		if (this.endPavura == null)
		{
			this.endPavura = this.EndPavuraDialogue();
			base.StartCoroutine(this.endPavura);
		}
	}

	// Token: 0x06000CBC RID: 3260 RVA: 0x000F865F File Offset: 0x000F685F
	private IEnumerator EndPavuraDialogue()
	{
		Links.x.gaia.PlayFade("In", "Scaled");
		Links.x.follow.position = Links.x.main.tr.position + new Vector3(0f, 3f, 0f);
		QuestLog.SetQuestState("CharacterCreation", QuestState.Active);
		Links.x.cameraEffects.ToggleObscurance();
		Character pavura = Links.x.diorama.FindCharacterAnyState("Pavura");
		Shader.SetGlobalFloat("_CloseUp", 1f);
		Shader.SetGlobalFloat("_Perspective", 1f);
		pavura.patrolHoldTime = float.PositiveInfinity;
		pavura.ignoreRemoveControls = true;
		GraphNode i = pavura.NearNode(Links.x.diorama.playerStartDefault.position, true, 0, -1, 0);
		pavura.MakePath(i, 30, false, false, true);
		GameObject gameObject = GameObject.Find("The Pavura GuardA");
		GameObject gameObject2 = GameObject.Find("The Pavura GuardB");
		CreatureActions creatureA = gameObject.GetComponent<CreatureActions>();
		CreatureActions creatureB = gameObject2.GetComponent<CreatureActions>();
		if (creatureA)
		{
			yield return new WaitForSeconds(1f);
			Character firstCharacter = creatureA.GetFirstCharacter();
			firstCharacter.patrolHoldTime = float.PositiveInfinity;
			firstCharacter.ignoreRemoveControls = true;
			firstCharacter.MakePath(i, 30, false, false, true);
			yield return new WaitForSeconds(0.5f);
			Character firstCharacter2 = creatureB.GetFirstCharacter();
			firstCharacter2.patrolHoldTime = float.PositiveInfinity;
			firstCharacter2.ignoreRemoveControls = true;
			firstCharacter2.MakePath(i, 30, false, false, true);
		}
		GameObject gameObject3 = GameObject.Find("Mihal the Scribe");
		CreatureActions scribeA = gameObject3.GetComponent<CreatureActions>();
		yield return new WaitForSeconds(5f);
		Links.x.gaia.PlayFade("Out", "Scaled");
		yield return new WaitForSeconds(0.5f);
		if (creatureA)
		{
			pavura.Missing();
			creatureA.GetFirstCharacter().Missing();
			creatureB.GetFirstCharacter().Missing();
		}
		Links.x.diorama.GetIndoorView();
		Links.x.rtsCamera.ReturnOrthographicCamera();
		Links.x.cameraEffects.ToggleInteriorExterior(Links.x.main);
		Links.x.rtsCamera.Follow(Links.x.main.tr, Links.x.main, true);
		Links.x.rtsCamera.JumpTo(Links.x.main.tr, true);
		Links.x.gaia.loadingCharacterCreation = false;
		Links.x.cameraEffects.ToggleObscurance();
		scribeA.GetFirstCharacter();
		scribeA.GetFirstCharacter().stats.initiateDialogue = 12;
		scribeA.GetFirstCharacter().stats.canTalk = true;
		yield return new WaitForSeconds(0.5f);
		Links.x.dialogue.SetSkipKey(true);
		Links.x.gaia.PlayFade("In", "Scaled");
		yield return new WaitForSeconds(0.5f);
		Records.x.TriggerGlobalSave("CheckpointSave", true);
		while (Records.x.saving)
		{
			yield return null;
		}
		yield return new WaitForSeconds(1f);
		Records.x.RemoveControls(false);
		Links.x.hudControl.ChangeHudVisibility(true, true);
		Links.x.cameraEffects.ToggleObscurance();
		Shader.SetGlobalFloat("_CloseUp", 0f);
		Shader.SetGlobalFloat("_Perspective", 0f);
		Records.x.AddQuestToTimer("C6_GobletGuildThievesA", 72f, "unassigned", "active", false);
		Records.x.AddQuestToTimer("C6_GobletGuildThievesB", 72f, "unassigned", "active", false);
		Records.x.AddQuestToTimer("C6_GobletGuildThievesC", 72f, "unassigned", "active", false);
		this.endPavura = null;
		if (Records.x.demo)
		{
			this.EndDemoInOffice();
		}
		else
		{
			Object.Destroy(this);
		}
		yield break;
	}

	// Token: 0x06000CBD RID: 3261 RVA: 0x000F8670 File Offset: 0x000F6870
	public void MovePosition(Character character, GraphNode g, bool isInterior)
	{
		character.SetPosition((Vector3)g.position, null);
		character.ClaimNode(g, (Vector3)g.position, true);
		character.sphere.transform.position = (Vector3)g.position;
		if (character.circleTr)
		{
			character.circleTr.position = character.tr.position;
		}
		character.SetMoveFollowPosition((Vector3)g.position);
		character.doorID = "";
		character.indoorID = "";
		if (isInterior)
		{
			if (Links.x.diorama.GetIndoorView())
			{
				character.indoorID = Links.x.diorama.GetIndoorView().GetInteriorBoundsName((Vector3)g.position);
			}
			else
			{
				character.indoorID = "?";
			}
		}
		character.ChangeTorchLight();
		character.FirstPosition(g);
	}

	// Token: 0x06000CBE RID: 3262 RVA: 0x000F875F File Offset: 0x000F695F
	public void TalkToWitch(Character messenger, Vector3 startPoint)
	{
		base.StartCoroutine(this.TalkToWitchWait(messenger, startPoint));
	}

	// Token: 0x06000CBF RID: 3263 RVA: 0x000F8770 File Offset: 0x000F6970
	private IEnumerator TalkToWitchWait(Character messenger, Vector3 startPoint)
	{
		if (messenger && !messenger.stunned && !messenger.dead)
		{
			while (!this.CanTalk(messenger, startPoint, false, false, true, 10f))
			{
				yield return null;
			}
			if (Links.x.cameraEffects.transitioning)
			{
				yield return null;
			}
			messenger.EndPath();
			DialogueLua.SetVariable("C6_WitchPrompt", true);
			Links.x.gameplay.StartDialogue(messenger, Links.x.main, null, null, messenger.stats.dialogueFile);
			yield return new WaitForSecondsRealtime(1f);
			while (Records.x.dialogue)
			{
				yield return null;
			}
			messenger.creatures.stopPatrolTemporarily = false;
			messenger.MakePath(messenger.creatures.GetWalkNodeIndex(0), 200, false, false, false);
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CC0 RID: 3264 RVA: 0x000F878D File Offset: 0x000F698D
	public void BanquetIsleFriend(Character messenger, Vector3 startPoint)
	{
		base.StartCoroutine(this.BanquetIsleFriendWait(messenger, startPoint));
	}

	// Token: 0x06000CC1 RID: 3265 RVA: 0x000F879E File Offset: 0x000F699E
	private IEnumerator BanquetIsleFriendWait(Character messenger, Vector3 startPoint)
	{
		if (messenger && !messenger.stunned && !messenger.dead)
		{
			messenger.StartQuip("Hold!");
			Debug.Log("Starting friend cinematic");
			while (!this.CanTalk(messenger, startPoint, true, true, false, 10f))
			{
				yield return null;
			}
			messenger.EndPath();
			Character nearestPartyInRoom = Links.x.GetNearestPartyInRoom(messenger.tr.position, null, 400f, messenger.indoorID, true);
			Character character = Links.x.diorama.FindCharacter("BanquetIsleFriend2");
			if (character && (character.dead || character.stunned))
			{
				character = null;
			}
			Links.x.gameplay.StartDialogue(messenger, nearestPartyInRoom, character, null, messenger.stats.dialogueFile);
			yield return new WaitForSecondsRealtime(1f);
			while (Records.x.dialogue)
			{
				yield return null;
			}
			yield return new WaitForSeconds(0.25f);
			if (Records.x.needsCompanionTooltip || Records.x.editor)
			{
				Links.x.hudControl.ShowTutorialTooltip("Companion");
			}
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CC2 RID: 3266 RVA: 0x000F87BB File Offset: 0x000F69BB
	public void BanquetIsleFriendLeave(Character messenger, Vector3 startPoint)
	{
		base.StartCoroutine(this.BanquetIsleFriendLeaveWait(messenger, startPoint));
	}

	// Token: 0x06000CC3 RID: 3267 RVA: 0x000F87CC File Offset: 0x000F69CC
	private bool IsPlayingAsMain()
	{
		return Links.x.main && Links.x.main.stats.partyID == 0;
	}

	// Token: 0x06000CC4 RID: 3268 RVA: 0x000F87F8 File Offset: 0x000F69F8
	private IEnumerator BanquetIsleFriendLeaveWait(Character messenger, Vector3 startPoint)
	{
		if (messenger)
		{
			while (Records.x.inMenus)
			{
				yield return null;
			}
			while (Records.x.paused)
			{
				if (!Records.x.secrets && !Records.x.editor)
				{
					break;
				}
				yield return null;
			}
			while (messenger.dead)
			{
				yield return null;
			}
			while (!this.CanTalk(messenger, startPoint, true, true, false, 40f) && this.IsPlayingAsMain())
			{
				yield return null;
			}
			Links.x.gameplay.TogglePause(false);
			Records.x.RemoveControls(true);
			Links.x.rtsCamera.puzzleLerp = false;
			messenger.EndPath();
			messenger.SetRotation(Quaternion.LookRotation(Links.x.main.tr.position - messenger.tr.position), false, false);
			if (this.IsPlayingAsMain())
			{
				Links.x.rtsCamera.puzzleTarget = messenger.transform.gameObject;
			}
			else
			{
				Links.x.rtsCamera.puzzleTarget = Links.x.main.transform.gameObject;
			}
			Links.x.rtsCamera.Zoom(true, "Dialogue");
			if (this.IsPlayingAsMain())
			{
				Shader.SetGlobalVector("_CinematicRevealPosition", messenger.gameObject.transform.position);
			}
			else
			{
				Shader.SetGlobalVector("_CinematicRevealPosition", Links.x.main.gameObject.transform.position);
			}
			Links.x.gaia.FadeOutPlaylist(true, 0.5f);
			MasterAudio.PlaySound3DAtVector3AndForget("Choking", Links.x.main.transform.position, 0.6f, new float?(1f), 0.1f, "", null);
			yield return new WaitForSeconds(0.5f);
			messenger.PlayAnimation("Hit", 0f);
			Character npc2 = Links.x.GetCreationID(2);
			messenger.animator.SetBool("Combat", true);
			if (npc2)
			{
				npc2.animator.SetBool("Combat", true);
				npc2.PlayAnimation("Hit", 0f);
			}
			MasterAudio.PlaySound3DAtVector3AndForget("Vine", Links.x.main.transform.position, 0.7f, new float?(1f), 0.1f, "", null);
			Links.x.cinematicFX.gameObject.SetActive(true);
			Links.x.cinematicFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
			Vector3 position = messenger.body.faceRenderer.transform.position;
			Vector3 vector = Links.x.worldCamera.WorldToScreenPoint(position);
			vector.z = 0f;
			vector.x = vector.x * (1920f / (float)Screen.width) - 960f;
			vector.y = vector.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
			Links.x.cinematicFX.localPosition = vector;
			GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(78);
			pooledGameObject.transform.position = messenger.tr.position + new Vector3(0f, 1f, 0f);
			pooledGameObject.SetActive(true);
			Character creationID = Links.x.GetCreationID(0);
			if (creationID.dead)
			{
				creationID.PartyResurrect(-1);
			}
			messenger.RemoveFromParty(true);
			messenger.SetMeshState(true);
			if (npc2)
			{
				npc2.RemoveFromParty(true);
				GameObject pooledGameObject2 = Links.x.cellar.GetPooledGameObject(78);
				pooledGameObject2.transform.position = npc2.tr.position + new Vector3(0f, 1f, 0f);
				pooledGameObject2.SetActive(true);
				npc2.SetMeshState(true);
			}
			yield return new WaitForSeconds(1f);
			messenger.creatures.SetTemperament(2);
			if (npc2)
			{
				npc2.creatures.SetTemperament(2);
			}
			messenger.body.faceRenderer.material.SetTexture("_MainTex", Links.x.cinematicLachoTextureSwap1);
			QuestLog.SetQuestState("F5_BanquetFriend", QuestState.Success);
			Links.x.gameplay.StartDialogue(messenger, Links.x.main, null, null, messenger.stats.dialogueFile);
			yield return new WaitForSeconds(0.5f);
			Shader.SetGlobalVector("_CinematicRevealPosition", new Vector3(-100000f, -100000f, -100000f));
			Links.x.rtsCamera.puzzleTarget = Links.x.main.gameObject;
			Links.x.rtsCamera.puzzleLerp = false;
			Links.x.rtsCamera.puzzleTarget = null;
			Links.x.rtsCamera.puzzleLerp = false;
			Records.x.RemoveControls(false);
			Links.x.rtsCamera.Zoom(false, "Dialogue");
			QuestLog.SetQuestState("F5_BanquetFriend", QuestState.Complete);
			while (Records.x.dialogue)
			{
				yield return null;
			}
			messenger.body.faceRenderer.material.SetTexture("_MainTex", Links.x.cinematicLachoTextureSwap2);
			npc2.body.faceRenderer.material.SetTexture("_MainTex", Links.x.cinematicLachoTextureSwap2);
			if (messenger == Links.x.main || npc2 == Links.x.main)
			{
				Character creationID2 = Links.x.GetCreationID(0);
				creationID2.SetAsLeader();
				Links.x.fellowship.SingleSelected(creationID2);
				creationID2.AddToSelected(false, true);
				creationID2.SetAsLeader();
				Links.x.rtsCamera.JumpTo(creationID2.tr.position, creationID2, true);
				Links.x.rtsCamera.Follow(creationID2.tr, creationID2, true);
			}
			while (!Records.x.combat)
			{
				yield return null;
			}
			if (messenger && !messenger.dead)
			{
				messenger.hostility = 2;
				messenger.FullAttackTime();
				messenger.stats.AddActionTimeMod(-2f);
				messenger.UpdateLKP(Links.x.main, Links.x.main.node, "Seen", true);
				Links.x.combat.GetNextAction(messenger);
			}
			if (npc2 && !npc2.dead)
			{
				npc2.creatures.SetTemperament(2);
				npc2.hostility = 2;
				npc2.FullAttackTime();
				npc2.stats.AddActionTimeMod(-1f);
				npc2.UpdateLKP(Links.x.main, Links.x.main.node, "Seen", true);
				Links.x.combat.GetNextAction(npc2);
			}
			if (messenger == Links.x.main || npc2 == Links.x.main)
			{
				Character creationID3 = Links.x.GetCreationID(0);
				creationID3.SetAsLeader();
				Links.x.fellowship.SingleSelected(creationID3);
				creationID3.AddToSelected(false, true);
				creationID3.SetAsLeader();
				Links.x.rtsCamera.JumpTo(creationID3.tr.position, creationID3, true);
				Links.x.rtsCamera.Follow(creationID3.tr, creationID3, true);
			}
			Links.x.protagonist = Links.x.main;
			npc2 = null;
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CC5 RID: 3269 RVA: 0x000F8815 File Offset: 0x000F6A15
	public void BanquetIslePriest(Character messenger, Vector3 startPoint)
	{
		base.StartCoroutine(this.BanquetIslePriestWait(messenger, startPoint));
	}

	// Token: 0x06000CC6 RID: 3270 RVA: 0x000F8826 File Offset: 0x000F6A26
	private IEnumerator BanquetIslePriestWait(Character messenger, Vector3 startPoint)
	{
		if (messenger && !messenger.stunned && !messenger.dead)
		{
			Debug.Log("Starting banquet isle priest");
			if (Links.x.soundtrack.currentSoundtrack != "Banquet Isle")
			{
				Links.x.gaia.SetPlaylist("Banquet Isle", true, 0f);
			}
			while (!this.CanTalk(messenger, startPoint, true, false, false, 20f))
			{
				yield return null;
			}
			while (Records.x.inMenus)
			{
				yield return null;
			}
			while (Records.x.paused && (Records.x.secrets || Records.x.editor))
			{
				yield return null;
			}
			Links.x.gameplay.TogglePause(false);
			Records.x.RemoveControls(true);
			Links.x.rtsCamera.puzzleLerp = false;
			messenger.EndPath();
			messenger.SetRotation(Quaternion.LookRotation(Links.x.main.tr.position - messenger.tr.position), false, false);
			Links.x.rtsCamera.puzzleTarget = messenger.transform.gameObject;
			Links.x.rtsCamera.Zoom(true, "Dialogue");
			Shader.SetGlobalVector("_CinematicRevealPosition", messenger.gameObject.transform.position);
			yield return new WaitForEndOfFrame();
			while (messenger.turning)
			{
				yield return null;
			}
			while (Records.x.IsSaving())
			{
				yield return null;
			}
			messenger.StartQuip("Help! I cannot resist him!");
			MasterAudio.PlaySound3DAtVector3AndForget("BloodlessTurn", messenger.transform.position, 1f, new float?(1f), 0f, "", null);
			MasterAudio.PlaySound3DAtVector3AndForget("Choking", messenger.transform.position, 0.6f, new float?(1f), 0.1f, "", null);
			yield return new WaitForSeconds(0.5f);
			messenger.SetRotation(Quaternion.LookRotation(Links.x.main.tr.position - messenger.tr.position), true, false);
			messenger.PlayAnimation("Distress", 0f);
			messenger.inAction = true;
			messenger.inActionTime = Links.x.gameplay.seconds;
			messenger.animator.SetBool("Combat", true);
			MasterAudio.PlaySound3DAtVector3AndForget("Vine", messenger.transform.position, 0.7f, new float?(1f), 0.1f, "", null);
			Links.x.cinematicFX.gameObject.SetActive(true);
			Links.x.cinematicFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
			Vector3 position = messenger.body.faceRenderer.transform.position;
			Vector3 vector = Links.x.worldCamera.WorldToScreenPoint(position);
			vector.z = 0f;
			vector.x = vector.x * (1920f / (float)Screen.width) - 960f;
			vector.y = vector.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
			Links.x.cinematicFX.localPosition = vector;
			GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(78);
			pooledGameObject.transform.position = messenger.tr.position + new Vector3(0f, 1f, 0f);
			pooledGameObject.SetActive(true);
			messenger.creatures.SetTemperament(2);
			messenger.body.faceRenderer.material.SetTexture("_MainTex", Links.x.cinematicLachoTextureSwap1);
			messenger.SetRotation(Quaternion.LookRotation(Links.x.main.tr.position - messenger.tr.position), true, false);
			yield return new WaitForSeconds(2.5f);
			messenger.inAction = false;
			messenger.SetRotation(Quaternion.LookRotation(Links.x.main.tr.position - messenger.tr.position), true, false);
			Shader.SetGlobalVector("_CinematicRevealPosition", new Vector3(-100000f, -100000f, -100000f));
			Links.x.rtsCamera.puzzleTarget = Links.x.main.gameObject;
			Links.x.rtsCamera.puzzleLerp = false;
			yield return new WaitForSeconds(0.5f);
			Links.x.rtsCamera.puzzleTarget = null;
			Links.x.rtsCamera.puzzleLerp = false;
			Records.x.RemoveControls(false);
			Links.x.rtsCamera.Zoom(false, "Dialogue");
			messenger.hostility = 2;
			if (Vector3.Distance(messenger.tr.position, Links.x.main.tr.position) < 30f)
			{
				messenger.UpdateLKP(Links.x.main, Links.x.main.node, "Seen", true);
				Links.x.sensory.AddPlayerToCombat(messenger, Links.x.main, true, false, false);
				if (!Records.x.combat && !messenger.dead && !messenger.stunned)
				{
					Links.x.combat.StartCombat(Links.x.main, messenger, false, true);
				}
				messenger.FullAttackTime();
			}
			QuestLog.SetQuestState("F5_BanquetPriest", QuestState.Success);
			yield return new WaitForSeconds(1f);
			while (messenger.inAction || messenger.inRecovery)
			{
				yield return null;
			}
			if (Records.x.needsAttackTooltip || Records.x.editor)
			{
				Links.x.hudControl.ShowTutorialTooltip("Attack");
			}
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CC7 RID: 3271 RVA: 0x000F8843 File Offset: 0x000F6A43
	public void TalkToPartyPaduriiChildQuest(Character messenger, Vector3 startPoint)
	{
		base.StartCoroutine(this.TalkToPartyPaduriiChildQuestWait(messenger, startPoint));
	}

	// Token: 0x06000CC8 RID: 3272 RVA: 0x000F8854 File Offset: 0x000F6A54
	private IEnumerator TalkToPartyPaduriiChildQuestWait(Character messenger, Vector3 startPoint)
	{
		if (messenger && !messenger.stunned && !messenger.dead)
		{
			messenger.ignoreRemoveControls = true;
			while (!this.CanTalk(messenger, startPoint, false, false, true, 8f))
			{
				yield return null;
			}
			while (messenger.moving)
			{
				yield return null;
			}
			Links.x.gameplay.StartDialogue(messenger, Links.x.main, null, null, messenger.stats.dialogueFile);
			yield return new WaitForSecondsRealtime(1f);
			while (Records.x.dialogue)
			{
				yield return null;
			}
			messenger.ignoreNodeIDs = false;
			messenger.creatures.stopPatrolTemporarily = false;
			messenger.ignoreRemoveControls = false;
			messenger.MakePath(messenger.creatures.GetWalkNodeIndex(0), 200, false, false, false);
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CC9 RID: 3273 RVA: 0x000F8874 File Offset: 0x000F6A74
	private bool CanTalk(Character messenger, Vector3 startPoint, bool canInterruptCombat, bool run, bool checkStartPoint, float dist)
	{
		if (Records.x.InCombat(false) && !canInterruptCombat)
		{
			return false;
		}
		if (Records.x.removeControls && !messenger.ignoreRemoveControls)
		{
			return false;
		}
		if (Records.x.paused)
		{
			return false;
		}
		if (Records.x.inMenus)
		{
			return false;
		}
		if (Records.x.dialogue)
		{
			return false;
		}
		if (!Links.x.hasMain)
		{
			return false;
		}
		if (Links.x.combat.inPocketAttack || Links.x.combat.inRally)
		{
			return false;
		}
		if (Links.x.cameraEffects.transitioning)
		{
			return false;
		}
		if (messenger.sleeping)
		{
			return false;
		}
		if (messenger.dead || messenger.stunned)
		{
			return false;
		}
		if (Links.x.main.followingType != "")
		{
			return false;
		}
		float num = 6400f;
		float sqrMagnitude = (messenger.tr.position - startPoint).sqrMagnitude;
		if (sqrMagnitude > num && checkStartPoint)
		{
			messenger.creatures.stopPatrolTemporarily = false;
			return false;
		}
		if (!checkStartPoint || (checkStartPoint && sqrMagnitude <= num))
		{
			if ((Links.x.main.tr.position - new Vector3(messenger.tr.position.x, Links.x.main.tr.position.y, messenger.tr.position.z)).sqrMagnitude < dist * dist)
			{
				return true;
			}
			if (messenger.creatures)
			{
				messenger.creatures.stopPatrolTemporarily = true;
			}
			if (messenger.moving)
			{
				return false;
			}
			if (messenger.waitingForPath > 0 || messenger.NodesCount() > 0)
			{
				return false;
			}
			GraphNode graphNode = messenger.NearNode(Links.x.main.tr.position + Quaternion.LookRotation(messenger.tr.position - Links.x.main.tr.position) * Vector3.forward * 5f, true, 0, -1, 0);
			if (graphNode != null)
			{
				messenger.running = run;
				messenger.MakePath(graphNode, 100, false, false, true);
			}
		}
		return false;
	}

	// Token: 0x06000CCA RID: 3274 RVA: 0x000F8AB2 File Offset: 0x000F6CB2
	public void ClearGhostFog(GameObject go)
	{
		base.StartCoroutine(this.ClearFog(go));
	}

	// Token: 0x06000CCB RID: 3275 RVA: 0x000F8AC2 File Offset: 0x000F6CC2
	private IEnumerator ClearFog(GameObject go)
	{
		while (Records.x.inMenus)
		{
			yield return null;
		}
		while (Records.x.paused)
		{
			if (!Records.x.secrets && !Records.x.editor)
			{
				break;
			}
			yield return null;
		}
		while (Links.x.combat.inPocketAttack || Links.x.combat.inRally)
		{
			yield return null;
		}
		Links.x.combat.EndCombat(false);
		while (Records.x.InCombat(false))
		{
			yield return null;
		}
		Links.x.gameplay.TogglePause(false);
		Records.x.RemoveControls(true);
		Shader.SetGlobalFloat("_CinematicGhostFow", 0f);
		Shader.SetGlobalFloat("_CinematicGhostFade", 0f);
		Debug.Log("Ghost fog cinematics");
		List<Transform> trs = new List<Transform>();
		foreach (object obj in go.transform)
		{
			Transform transform = (Transform)obj;
			if (transform != go.transform)
			{
				trs.Add(transform);
			}
		}
		int childCount = trs.Count;
		SceneCamera sceneCamera = null;
		Links.x.gaia.SetPlaylist("Banquet Isle", true, 0f);
		yield return new WaitForSeconds(0.5f);
		int num2;
		for (int i = 0; i < childCount; i = num2 + 1)
		{
			Links.x.fogOfWar.saveFow = false;
			Links.x.fogOfWarInterior.saveFow = false;
			Links.x.rtsCamera.puzzleLerp = false;
			Links.x.rtsCamera.puzzleSnapCamera = true;
			Links.x.fadeAnimator.enabled = true;
			Links.x.fadeAnimator.Play("CinematicQuickFade");
			yield return new WaitForSecondsRealtime(0.14f);
			Links.x.diorama.GhostMaterials();
			Shader.SetGlobalFloat("_CinematicGhostFow", 1f);
			Shader.SetGlobalFloat("_CinematicGhostFade", 0f);
			Links.x.hoverObject = trs[i].gameObject;
			Shader.SetGlobalVector("_DoorLightPosition", trs[i].position + new Vector3(0f, 3f, 0f));
			Records.x.hoverLightColor = Color.white * 0.3f;
			Shader.SetGlobalFloat("_DoorLightRange", 30f);
			Links.x.rtsCamera.puzzleTarget = trs[i].gameObject;
			Shader.SetGlobalVector("_CinematicRevealPosition", trs[i].gameObject.transform.position);
			if (i == 0 && Records.x.inspectCamera && Records.x.inspecting)
			{
				this.FlipToOrthographic(out sceneCamera);
			}
			yield return new WaitForSeconds(0.25f);
			float startValue = 0f;
			float endValue = 1f;
			float timeToLerp = 1.5f;
			float percentage = 0f;
			float startTime = Time.time;
			while (percentage < 1f)
			{
				percentage = (Time.time - startTime) / timeToLerp;
				float num = Mathf.Lerp(startValue, endValue, percentage);
				Shader.SetGlobalFloat("_CinematicGhostFade", num);
				yield return null;
			}
			foreach (object obj2 in trs[i])
			{
				((Transform)obj2).gameObject.SetActive(true);
			}
			MasterAudio.PlaySound("Ghost Fog Gone", Random.Range(0.6f, 0.8f), new float?(Random.Range(0.8f, 1.2f)), 0f, "", null, false, false);
			yield return new WaitForSeconds(2.5f);
			num2 = i;
		}
		Links.x.fadeAnimator.enabled = true;
		Links.x.fadeAnimator.Play("CinematicQuickFade");
		yield return new WaitForSeconds(0.12f);
		Links.x.diorama.GhostFogOff();
		Shader.SetGlobalFloat("_CinematicGhostFow", 0f);
		Shader.SetGlobalFloat("_CinematicGhostFade", 0f);
		Shader.SetGlobalVector("_CinematicRevealPosition", new Vector3(-100000f, -100000f, -100000f));
		Links.x.rtsCamera.puzzleTarget = Links.x.main.gameObject;
		Links.x.rtsCamera.puzzleLerp = false;
		yield return new WaitForSeconds(0.01f);
		Links.x.rtsCamera.puzzleTarget = null;
		Links.x.rtsCamera.puzzleLerp = false;
		Links.x.rtsCamera.puzzleSnapCamera = false;
		yield return new WaitForSeconds(0.5f);
		MasterAudio.PlaySoundAndForget("Feedback", 0.4f, new float?(1f), 0f, "DialogueStatPass", null);
		Links.x.gameFeed.AddFeed("The air around you is lighter");
		yield return new WaitForSeconds(0.5f);
		Records.x.RemoveControls(false);
		Links.x.fogOfWar.saveFow = true;
		Links.x.fogOfWarInterior.saveFow = true;
		Links.x.questEnd.QuestEnded("C6_Ghosts");
		yield break;
	}

	// Token: 0x06000CCC RID: 3276 RVA: 0x000F8AD8 File Offset: 0x000F6CD8
	private SceneCamera FlipToOrthographic(out SceneCamera prevView)
	{
		prevView = null;
		if (Records.x.inspectCamera)
		{
			prevView = Records.x.previousView;
			SceneCamera inspectCamera = Records.x.inspectCamera;
			Records.x.inspecting = false;
			Links.x.rtsCamera.ReturnOrthographicCamera();
			Links.x.rtsCamera.Follow(Links.x.main.tr, Links.x.main, true);
			Links.x.rtsCamera.JumpTo(Links.x.main.tr, true);
			Links.x.diorama.ToggleSceneCameras(false, "");
			Records.x.inspectCamera = null;
			return inspectCamera;
		}
		return null;
	}

	// Token: 0x06000CCD RID: 3277 RVA: 0x000F8B98 File Offset: 0x000F6D98
	private bool CanStartCinematic()
	{
		return Links.x.gaia.sceneLoaded && !Records.x.InCombat(false) && !Records.x.inMenus && !Records.x.paused && !Records.x.pocketPause && !Records.x.removeControls && !Records.x.saving && !Links.x.rtsCamera.puzzleTarget && !Links.x.combat.inPocketAttack && !Links.x.combat.inRally;
	}

	// Token: 0x06000CCE RID: 3278 RVA: 0x000F8C40 File Offset: 0x000F6E40
	private bool Nearby(Character c, string startIndoorID, Vector3 center, float dist)
	{
		return c && !(c.indoorID != startIndoorID) && (c.tr.position - center).sqrMagnitude <= dist * dist;
	}

	// Token: 0x06000CCF RID: 3279 RVA: 0x000F8C8C File Offset: 0x000F6E8C
	public void PromptLook(Character hitCharacter, PromptActions promptActions, GameObject lookTarget, bool isRogue, bool isCharmer, int roll, string rollString, string diffString)
	{
		base.StartCoroutine(this.OrchestratePromptLook(hitCharacter, promptActions, lookTarget, isRogue, isCharmer, roll, rollString, diffString));
	}

	// Token: 0x06000CD0 RID: 3280 RVA: 0x000F8CB4 File Offset: 0x000F6EB4
	private IEnumerator OrchestratePromptLook(Character hitCharacter, PromptActions promptActions, GameObject lookTarget, bool isRogue, bool isCharmer, int roll, string rollString, string diffString)
	{
		string startIndoorID = hitCharacter.indoorID;
		while (!this.CanStartCinematic())
		{
			yield return null;
		}
		if (hitCharacter && promptActions.gameObject.activeSelf)
		{
			Vector3 center = lookTarget.transform.position;
			Debug.Log(string.Concat(new string[]
			{
				"Starting prompt sequence ",
				(hitCharacter != null) ? hitCharacter.ToString() : null,
				" ",
				(lookTarget != null) ? lookTarget.ToString() : null,
				" ",
				isRogue.ToString(),
				" ",
				isCharmer.ToString(),
				" ",
				roll.ToString(),
				" ",
				(promptActions != null) ? promptActions.ToString() : null
			}));
			while (!this.Nearby(hitCharacter, startIndoorID, lookTarget.transform.position, 50f) || !this.CanStartCinematic())
			{
				yield return null;
			}
			if (promptActions.gameObject.activeSelf)
			{
				Records.x.RemoveControls(true);
				Links.x.fellowship.StopWalking(true);
				Links.x.rtsCamera.puzzleLerp = true;
				Links.x.rtsCamera.puzzleTarget = lookTarget.transform.gameObject;
				Links.x.rtsCamera.Zoom(true, "Dialogue");
				Shader.SetGlobalVector("_CinematicRevealPosition", center);
				if (Links.x.cameraEffects.indoors)
				{
					Links.x.hoverObject = lookTarget;
					Shader.SetGlobalVector("_DoorLightPosition", center + new Vector3(0f, 3f, 0f));
					Records.x.hoverLightColor = Color.white * 0.1f;
					Shader.SetGlobalFloat("_DoorLightRange", 15f);
				}
				if (lookTarget == hitCharacter.gameObject)
				{
					if (isRogue)
					{
						hitCharacter.StartQuip(promptActions.SkillQuip(promptActions.prompt.rangerQuip, hitCharacter.stats.race));
					}
					else if (isCharmer)
					{
						hitCharacter.StartQuip(promptActions.SkillQuip(promptActions.prompt.charmerQuip, hitCharacter.stats.race));
					}
					else if (promptActions.prompt.type == Prompts.types.quip)
					{
						string text = promptActions.prompt.conversation;
						if (text == "")
						{
							text = promptActions.prompt.textID;
						}
						hitCharacter.StartQuip(promptActions.Quip(text, promptActions.characterName, hitCharacter.stats.race));
					}
				}
				if (isRogue)
				{
					promptActions.FinishRogueCheck(hitCharacter, roll);
					MasterAudio.PlaySoundAndForget("Feedback", 1f, new float?(1f), 0f, "DialogueStatPass", null);
				}
				else if (isCharmer)
				{
					promptActions.FinishCharmerCheck(hitCharacter, roll);
					MasterAudio.PlaySoundAndForget("Feedback", 1f, new float?(1f), 0f, "DialogueStatPass", null);
				}
				else if (promptActions.prompt.type == Prompts.types.quip)
				{
					promptActions.FinishQuip();
				}
				float num = 1.75f;
				if (isCharmer || isRogue || lookTarget != hitCharacter.gameObject)
				{
					num = 2f;
				}
				bool flag = false;
				if (promptActions.gameObject.transform.childCount == 3)
				{
					flag = true;
				}
				if (!flag)
				{
					if (Links.x.worldCamera.orthographic)
					{
						yield return new WaitForSeconds(num);
					}
				}
				else
				{
					Vector3 vector = promptActions.gameObject.transform.GetChild(0).position;
					vector.y -= 0.5f;
					Links.x.footstep.SetActive(true);
					Links.x.footstep.transform.position = vector;
					yield return new WaitForSeconds(0.95f);
					Links.x.footstep.SetActive(false);
					yield return new WaitForSeconds(0.05f);
					Links.x.footstep.SetActive(true);
					vector = promptActions.gameObject.transform.GetChild(1).position;
					vector.y -= 0.5f;
					Links.x.footstep.transform.position = vector;
					yield return new WaitForSeconds(0.95f);
					Links.x.footstep.SetActive(false);
					yield return new WaitForSeconds(0.05f);
					Links.x.footstep.SetActive(true);
					vector = promptActions.gameObject.transform.GetChild(2).position;
					vector.y -= 0.5f;
					Links.x.footstep.transform.position = vector;
					yield return new WaitForSeconds(1f);
					Links.x.footstep.SetActive(false);
				}
				if (lookTarget != hitCharacter.gameObject)
				{
					if (isRogue)
					{
						hitCharacter.StartQuip(promptActions.SkillQuip(promptActions.prompt.rangerQuip, hitCharacter.stats.race));
					}
					else if (isCharmer)
					{
						hitCharacter.StartQuip(promptActions.SkillQuip(promptActions.prompt.charmerQuip, hitCharacter.stats.race));
					}
					else if (promptActions.prompt.type == Prompts.types.quip)
					{
						string text2 = promptActions.prompt.conversation;
						if (text2 == "")
						{
							text2 = promptActions.prompt.textID;
						}
						hitCharacter.StartQuip(promptActions.Quip(text2, promptActions.characterName, hitCharacter.stats.race));
					}
					Links.x.rtsCamera.puzzleTarget = hitCharacter.gameObject;
					yield return new WaitForSeconds(1f);
					Records.x.RemoveControls(false);
					yield return new WaitForSeconds(1f);
				}
				else
				{
					Records.x.RemoveControls(false);
				}
				Shader.SetGlobalVector("_CinematicRevealPosition", new Vector3(-100000f, -100000f, -100000f));
				Links.x.rtsCamera.puzzleTarget = Links.x.main.gameObject;
				Links.x.rtsCamera.puzzleLerp = false;
				Links.x.rtsCamera.Zoom(false, "Dialogue");
				Links.x.hoverObject = null;
				GameObject fx = null;
				if (isRogue || isCharmer)
				{
					MasterAudio.PlaySoundAndForget("Feedback", 0.6f, new float?(1f), 0f, "Song Learned", null);
					string text3 = "Rogue Check";
					if (isCharmer)
					{
						text3 = "Charmer Check";
					}
					Animator animatedText = Links.x.cellar.GetAnimatedText("SkillCheckPass", text3, false);
					animatedText.gameObject.transform.position = hitCharacter.body.headBone.position + new Vector3(Random.Range(0f, 1f), Random.Range(0f, 1f), 0f) + new Vector3(0f, 3f, 0f);
					animatedText.gameObject.transform.SetParent(hitCharacter.tr, true);
					animatedText.gameObject.name = hitCharacter.stats.GetName();
					this.str.Clear();
					this.str.Append(Links.x.gameFeed.GetPartyColorText(hitCharacter));
					this.str.Append(hitCharacter.stats.GetName());
					this.str.Append("</color>");
					if (isRogue)
					{
						this.str.Append(" passed Rogue search check ");
					}
					else
					{
						this.str.Append(" passed Binding search check ");
					}
					if (Records.x.showRulesetInfo)
					{
						this.str.Append(" <color #857C6C>... ");
						this.str.Append(rollString);
						this.str.Append(" vs. ");
						this.str.Append(diffString);
						this.str.Append("</color>");
					}
					Links.x.gameFeed.AddFeed(this.str.ToString());
				}
				yield return new WaitForSeconds(0.5f);
				Links.x.rtsCamera.puzzleTarget = null;
				Links.x.rtsCamera.puzzleLerp = false;
				if (isRogue || isCharmer)
				{
					yield return new WaitForSeconds(1f);
					int xp = (promptActions.prompt.charmerSkillCheck + roll) * 2;
					if (isRogue)
					{
						xp = promptActions.prompt.rangerSkillCheck;
					}
					yield return new WaitForSeconds(0.5f);
					hitCharacter.stats.AddXP(xp, null, true);
				}
				promptActions.state = 1;
				yield return new WaitForSeconds(2f);
				if ((isRogue || isCharmer) && fx)
				{
					Links.x.cellar.ReturnPooledGameObject(10, fx);
				}
				fx = null;
			}
			center = default(Vector3);
		}
		else if (promptActions.gameObject.activeSelf)
		{
			promptActions.state = 0;
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CD1 RID: 3281 RVA: 0x000F8D0B File Offset: 0x000F6F0B
	public void Ambush(GameObject creatureFolder, Character hitCharacter, PromptActions promptActions)
	{
		if (Records.x.turnOffAnimals)
		{
			return;
		}
		base.StartCoroutine(this.OrchestrateAmbush(creatureFolder, hitCharacter, promptActions));
	}

	// Token: 0x06000CD2 RID: 3282 RVA: 0x000F8D2A File Offset: 0x000F6F2A
	private IEnumerator OrchestrateAmbush(GameObject creatureFolder, Character hitCharacter, PromptActions promptActions)
	{
		while (Records.x.removeControls)
		{
			yield return null;
		}
		if (Links.x.gaia.sceneLoaded)
		{
			List<Transform> pts = new List<Transform>();
			Vector3 center = Vector3.zero;
			foreach (object obj in base.transform)
			{
				Transform transform = (Transform)obj;
				if (transform != base.transform)
				{
					pts.Add(transform);
					center += transform.position;
				}
			}
			if (pts.Count > 0)
			{
				center /= (float)pts.Count;
			}
			bool doCinematicCameraPause = false;
			if (promptActions.prompt.conversation == "ShromersGate")
			{
				doCinematicCameraPause = true;
			}
			while (!Links.x.gaia.sceneLoaded)
			{
				yield return null;
			}
			CreatureActions[] creatures = creatureFolder.GetComponentsInChildren<CreatureActions>();
			foreach (CreatureActions creatureActions in creatures)
			{
				if (pts.Count > 0)
				{
					creatureActions.ambush = true;
				}
				creatureActions.SetupCreatures();
			}
			int count = 0;
			Character firstAmbushCharacter = null;
			List<Character> characters;
			foreach (CreatureActions creatureActions2 in creatures)
			{
				characters = creatureActions2.characters;
				int count2 = characters.Count;
				for (int l = 0; l < count2; l++)
				{
					Character character = characters[l];
					if (pts.Count > 0 && count < pts.Count && character)
					{
						character.ambushing = true;
						character.body.SeeThroughColliders(false);
						character.jumpingAreas = false;
						character.alwaysOn = true;
						character.SetPosition(pts[count].position, null);
						Vector3.Lerp(pts[count].position, hitCharacter.tr.position, 0.5f);
						character.SetMeshState(false);
						GraphNode walkIndex = creatureActions2.GetWalkIndex(l);
						character.ClaimNode(walkIndex, character.tr.position, false);
						this.npcs.Add(character);
						Vector3 zero = Vector3.zero;
						zero.x = Random.Range(8f, 10f);
						if (Random.Range(0, 2) == 0)
						{
							zero.x *= -1f;
						}
						zero.y = Random.Range(8f, 10f);
						if (Random.Range(0, 2) == 0)
						{
							zero.y *= -1f;
						}
						zero.z = Random.Range(8f, 10f);
						if (Random.Range(0, 2) == 0)
						{
							zero.z *= -1f;
						}
						this.rots.Add(zero);
						int j = count;
						count = j + 1;
					}
					else if (character)
					{
						character.FirstPosition(null);
					}
					if (!firstAmbushCharacter && character)
					{
						firstAmbushCharacter = character;
					}
				}
				if (pts.Count == 0)
				{
					creatureActions2.Ambush(hitCharacter);
					characters = creatureActions2.characters;
					int y = characters.Count;
					yield return new WaitForSecondsRealtime(0.1f);
					for (int m = 0; m < y; m++)
					{
						Character character2 = characters[m];
						if (character2)
						{
							character2.body.SeeThroughColliders(false);
							this.AmbushParticle(character2.tr.position + new Vector3(0f, 2f, 0f));
							MasterAudio.PlaySound3DAtVector3AndForget("Interactives", character2.tr.position, Random.Range(0.5f, 0.8f), new float?(Random.Range(0.5f, 0.8f)), 0f, "Chest Break", null);
							character2.ambushing = true;
							character2.jumpingPosition = false;
							character2.PlaySoundFX(0, 7);
							character2.ambushing = false;
						}
					}
				}
			}
			CreatureActions[] array2 = null;
			if (doCinematicCameraPause)
			{
				while (Records.x.inMenus)
				{
					yield return null;
				}
				while ((Records.x.paused && (Records.x.secrets || Records.x.editor)) || Records.x.removeControls || Records.x.saving || Links.x.combat.inPocketAttack || Links.x.combat.inRally)
				{
					yield return null;
				}
				Links.x.gameplay.TogglePause(false);
				Records.x.RemoveControls(true);
				foreach (CreatureActions creatureActions3 in creatures)
				{
					characters = creatureActions3.characters;
					int count3 = characters.Count;
					for (int n = 0; n < count3; n++)
					{
						Character character3 = characters[n];
						if (character3)
						{
							character3.ignoreRemoveControls = true;
							character3.ignoreNodeIDs = false;
							character3.meshAlwaysOn = true;
							character3.SetMeshState(true);
							character3.stats.AddBlind(-20f);
							character3.body.SetMeshState(true, true);
						}
					}
				}
				Links.x.rtsCamera.puzzleLerp = false;
				if (promptActions.prompt.conversation == "ShromersGate")
				{
					string text = "LazureGuardDayGateA";
					string text2 = "LazureGuardDayGateB";
					if (!Links.x.gameplay.IsDay())
					{
						text = "LazureGuardNightGateA";
						text2 = "LazureGuardNightGateB";
					}
					Character character4 = Links.x.main;
					Character character5 = Links.x.diorama.FindCharacterAnyState(text);
					if (character5 && (Links.x.main.tr.position - character5.tr.position).sqrMagnitude < 400f)
					{
						character4 = character5;
					}
					Character character6 = Links.x.diorama.FindCharacterAnyState(text2);
					if (character4 == Links.x.main && character6 && (Links.x.main.tr.position - character6.tr.position).sqrMagnitude < 400f)
					{
						character4 = character6;
					}
					if (character5)
					{
						if (character5.turning)
						{
							character5.EndTurning(false);
						}
						if (character5.moving)
						{
							character5.TargetReached();
						}
						character5.SetRotation(Quaternion.LookRotation(firstAmbushCharacter.tr.position - character5.tr.position), false, true);
						character5.PlayAnimation("Heard", 0f);
					}
					if (character6)
					{
						if (character6.turning)
						{
							character6.EndTurning(false);
						}
						if (character6.moving)
						{
							character6.TargetReached();
						}
						character6.SetRotation(Quaternion.LookRotation(firstAmbushCharacter.tr.position - character6.tr.position), false, true);
						character6.PlayAnimation("Heard", 0f);
					}
					character4.StartQuip(promptActions.Quip(promptActions.prompt.conversation, "Leader", Links.x.main.stats.race));
					Links.x.rtsCamera.puzzleTarget = character4.transform.gameObject;
					Links.x.rtsCamera.Zoom(true, "Dialogue");
					Shader.SetGlobalVector("_CinematicRevealPosition", Vector3.Lerp(Links.x.main.tr.position, firstAmbushCharacter.gameObject.transform.position, 0.5f));
					yield return new WaitForSeconds(2f);
					Links.x.rtsCamera.Zoom(false, "Dialogue");
					Links.x.rtsCamera.puzzleTarget = firstAmbushCharacter.gameObject;
					yield return new WaitForSeconds(1f);
				}
				else
				{
					Links.x.main.StartQuip(promptActions.Quip(promptActions.prompt.conversation, "Leader", Links.x.main.stats.race));
				}
				Shader.SetGlobalVector("_CinematicRevealPosition", new Vector3(-100000f, -100000f, -100000f));
				Links.x.rtsCamera.puzzleTarget = Links.x.main.gameObject;
				Links.x.rtsCamera.puzzleLerp = false;
				yield return new WaitForSeconds(0.5f);
				Links.x.rtsCamera.puzzleTarget = null;
				Links.x.rtsCamera.puzzleLerp = false;
				Records.x.RemoveControls(false);
				Links.x.rtsCamera.Zoom(false, "Dialogue");
			}
			else
			{
				Character character7 = Links.x.HasCompanion(promptActions.characterName, Links.x.main.tr.position);
				if (character7)
				{
					character7.StartQuip(promptActions.Quip(promptActions.prompt.conversation, promptActions.characterName, character7.stats.race));
				}
			}
			float max = 400f;
			int lastCount = 0;
			if (pts.Count > 0)
			{
				while ((Links.x.GetMainPosition() - new Vector3(center.x, Links.x.GetMainPosition().y, center.z)).sqrMagnitude > max || doCinematicCameraPause)
				{
					count = 0;
					foreach (CreatureActions creatureActions4 in creatures)
					{
						characters = creatureActions4.characters;
						int count4 = characters.Count;
						for (int num = 0; num < count4; num++)
						{
							Character character8 = characters[num];
							if (character8)
							{
								character8.SetMeshState(false);
								character8.body.SetMeshState(false, false);
								character8.ambushing = true;
								character8.jumpingAreas = false;
								if (count < pts.Count)
								{
									lastCount = count;
									character8.SetPosition(pts[count].position, null);
								}
								else
								{
									character8.SetPosition(pts[lastCount].position, null);
								}
							}
							int num2 = count;
							count = num2 + 1;
						}
					}
					yield return null;
				}
				count = 0;
				lastCount = 0;
				foreach (CreatureActions c in creatures)
				{
					characters = c.characters;
					int y = characters.Count;
					int j;
					for (int i = 0; i < y; i = j + 1)
					{
						Character character9 = characters[i];
						if (character9)
						{
							Vector3 vector = pts[lastCount].position;
							if (count < pts.Count)
							{
								lastCount = count;
								vector = pts[count].position;
							}
							this.AmbushParticle(vector + new Vector3(0f, 2f, 0f));
							MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, Random.Range(0.5f, 0.8f), new float?(Random.Range(0.5f, 0.8f)), 0f, "Chest Break", null);
							character9.ambushing = true;
							character9.body.SeeThroughColliders(true);
							character9.SetPosition(vector, null);
							GraphNode walkIndex2 = c.GetWalkIndex(i);
							if (character9.inactive)
							{
								character9.TurnScriptsOn();
								character9.inactive = false;
							}
							character9.ClaimNode(walkIndex2, character9.tr.position, false);
							character9.GetIndoorID();
							character9.Jump(walkIndex2, (Vector3)walkIndex2.position, false, false);
							character9.SetRotation(Quaternion.LookRotation((Vector3)walkIndex2.position, character9.tr.position), false, false);
							character9.SetMeshState(true);
							character9.body.SetMeshState(true, true);
							character9.PlaySoundFX(0, 7);
						}
						j = count;
						count = j + 1;
						float timeToLerp = Random.Range(0.1f, 0.3f);
						float percentage = 0f;
						float startTime = Time.time;
						while (percentage < 1f)
						{
							percentage = (Time.time - startTime) / timeToLerp;
							this.Jumping(hitCharacter, i);
							yield return null;
						}
						j = i;
					}
					c = null;
				}
				array2 = null;
				while (this.Jumping(hitCharacter, this.npcs.Count))
				{
					yield return null;
				}
			}
			foreach (CreatureActions creatureActions5 in creatures)
			{
				characters = creatureActions5.characters;
				int count5 = characters.Count;
				for (int num3 = 0; num3 < count5; num3++)
				{
					Character character10 = characters[num3];
					if (character10)
					{
						character10.meshAlwaysOn = false;
						character10.ignoreRemoveControls = false;
						character10.ignoreNodeIDs = false;
						character10.body.SeeThroughColliders(true);
					}
				}
			}
			if (promptActions.prompt.ambushQuipPrompt && !promptActions.prompt.ambushQuipPrompt.GetComponent<Cinematics>())
			{
				promptActions.prompt.ambushQuipPrompt.gameObject.SetActive(false);
				promptActions.prompt.ambushQuipPrompt.GetComponent<PromptActions>().state = 1;
			}
			promptActions.state = 1;
			characters = null;
			pts = null;
			center = default(Vector3);
			creatures = null;
			firstAmbushCharacter = null;
		}
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000CD3 RID: 3283 RVA: 0x000F8D50 File Offset: 0x000F6F50
	private bool Jumping(Character hitCharacter, int x)
	{
		int num = 0;
		for (int i = 0; i < this.npcs.Count; i++)
		{
			if (this.npcs[i].ambushing && i <= x)
			{
				if (!this.npcs[i].jumping)
				{
					this.npcs[i].ambushing = false;
					this.npcs[i].SettlePosition();
					this.npcs[i].SetRotation(Quaternion.LookRotation(Links.x.main.currentPosition, this.npcs[i].tr.position), false, true);
					this.StartAmbush(this.npcs[i], hitCharacter);
					string text = "Cannonball";
					if (Random.Range(0, 2) == 0)
					{
						text += "1";
					}
					else
					{
						text += "2";
					}
					MasterAudio.PlaySound3DAtVector3AndForget("SpecialAttacks", this.npcs[i].tr.position, Random.Range(0.8f, 0.9f), new float?(1f), 0f, text, null);
				}
				else if (this.npcs[i].jumping && !Records.x.pocketPause)
				{
					this.npcs[i].body.SetMeshState(true, true);
					if (this.npcs[i].stats.animal)
					{
						this.npcs[i].tr.Rotate(this.rots[i]);
					}
					else if (this.npcs[i].movePoint != Vector3.zero)
					{
						this.npcs[i].tr.rotation = Quaternion.LookRotation(new Vector3(this.npcs[i].movePoint.x, this.npcs[i].tr.position.y, this.npcs[i].movePoint.z) - this.npcs[i].tr.position);
					}
				}
			}
			else
			{
				num++;
			}
		}
		return num != this.npcs.Count;
	}

	// Token: 0x06000CD4 RID: 3284 RVA: 0x000F8FCD File Offset: 0x000F71CD
	private void AmbushParticle(Vector3 pt)
	{
		GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(60);
		pooledGameObject.transform.position = pt + new Vector3(0f, 1f, 0f);
		pooledGameObject.SetActive(true);
	}

	// Token: 0x06000CD5 RID: 3285 RVA: 0x000F900C File Offset: 0x000F720C
	private void StartAmbush(Character character, Character hitCharacter)
	{
		character.ClearMoveTargets();
		character.ClearPathUpdates();
		character.SetRotation(Quaternion.LookRotation(hitCharacter.tr.position - character.tr.position), true, true);
		if (!character.GetLKPlayerBool(hitCharacter))
		{
			character.StartGetPathToTarget(hitCharacter.node, hitCharacter, null, null, null, null, null, null, character, null, false, false, true, "Searching", false);
			character.UpdateLKP(hitCharacter, hitCharacter.node, "Heard", false);
		}
		if (hitCharacter != Links.x.main)
		{
			character.UpdateLKP(Links.x.main, Links.x.main.node, "Heard", false);
		}
		character.movingToPatrolNode = true;
	}

	// Token: 0x04001478 RID: 5240
	private IEnumerator pavuraWalk;

	// Token: 0x04001479 RID: 5241
	private IEnumerator endPavura;

	// Token: 0x0400147A RID: 5242
	private List<Character> npcs = new List<Character>();

	// Token: 0x0400147B RID: 5243
	private List<Vector3> rots = new List<Vector3>();

	// Token: 0x0400147C RID: 5244
	private StringFast str = new StringFast(64);

	// Token: 0x0400147D RID: 5245
	public bool videoFinished;
}
