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

// Token: 0x02000086 RID: 134
public class Gaia : MonoBehaviour
{
	// Token: 0x06000D41 RID: 3393 RVA: 0x000FFBEC File Offset: 0x000FDDEC
	private void Start()
	{
		this.tr = base.transform;
		this.sceneLoaded = false;
		Links.x.SetCursor("Point", true);
		base.StartCoroutine(this.StartGame());
		MasterAudio.MasterVolumeLevel = 0f;
		SceneManager.sceneUnloaded += this.OnSceneUnloaded;
		SceneManager.sceneLoaded += this.OnSceneLoaded;
	}

	// Token: 0x06000D42 RID: 3394 RVA: 0x000FFC55 File Offset: 0x000FDE55
	private IEnumerator StartGame()
	{
		ES3File es3File = new ES3File("Version.es3");
		string text = "AutoSave/Quests.es3";
		ES3File es3FileSerpent = new ES3File("SerpentData.es3");
		if (!es3File.KeyExists("CheckpointSave"))
		{
			Debug.Log("Writing new version files");
			es3File.Save<string>("CheckpointSave", "Checkpoint Save");
			es3File.Save<string>("CheckpointSaveTime", "");
			es3File.Save<string>("QuickSave", "Quick Save");
			es3File.Save<string>("QuickSaveTime", "");
			es3File.Save<string>("Save1", "");
			es3File.Save<string>("Save1Time", "");
			es3File.Save<string>("Save2", "");
			es3File.Save<string>("Save2Time", "");
			es3File.Save<string>("Save3", "");
			es3File.Save<string>("Save3Time", "");
			es3File.Save<string>("Save4", "");
			es3File.Save<string>("Save4Time", "");
			es3File.Save<string>("Save5", "");
			es3File.Save<string>("Save5Time", "");
			es3File.Save<string>("Save6", "");
			es3File.Save<string>("Save6Time", "");
			es3File.Save<string>("Save7", "");
			es3File.Save<string>("Save7Time", "");
			es3File.Save<string>("Save8", "");
			es3File.Save<string>("Save8Time", "");
			es3File.Save<string>("Save9", "");
			es3File.Save<string>("Save9Time", "");
			es3File.Save<string>("Save10", "");
			es3File.Save<string>("Save10Time", "");
			es3File.Save<float>("CurrentVersion", Records.x.gameVersion);
			es3File.Save<float>("CurrentVersionDemo", Records.x.gameVersionDemo);
			es3File.Sync();
			this.newGame = true;
			ES3.Save<string>("SceneName", "", text);
			ES3.Save<int>("GameHours", 0, text);
			ES3.Save<int>("GameDays", 0, text);
			ES3.Save<float>("GameMinutes", 0f, text);
			this.partyNames.Clear();
			this.partyIDs.Clear();
			this.partyNames.Add("BloodlessHunter");
			this.partyIDs.Add(0);
			ES3.Save<List<string>>("PartyNames", this.partyNames, text);
		}
		else
		{
			this.partyNames.Clear();
			this.partyIDs.Clear();
			this.partyNames.Add("Empty");
			this.partyIDs.Add(0);
			es3File.Save<float>("CurrentVersion", Records.x.gameVersion);
			es3File.Save<float>("CurrentVersionDemo", Records.x.gameVersionDemo);
			es3File.Sync();
			this.newGame = false;
		}
		if (es3File.KeyExists("DefendTutorialTip"))
		{
			Records.x.needsDefendTooltip = false;
		}
		else
		{
			Records.x.needsDefendTooltip = true;
		}
		if (es3File.KeyExists("SynergyTutorialTip"))
		{
			Records.x.needsSynergyTooltip = false;
		}
		else
		{
			Records.x.needsSynergyTooltip = true;
		}
		if (es3File.KeyExists("CompanionTutorialTip"))
		{
			Records.x.needsCompanionTooltip = false;
		}
		else
		{
			Records.x.needsCompanionTooltip = true;
		}
		if (es3File.KeyExists("AttackTutorialTip"))
		{
			Records.x.needsAttackTooltip = false;
		}
		else
		{
			Records.x.needsAttackTooltip = true;
		}
		if (es3File.KeyExists("MoreTutorialTip"))
		{
			Records.x.needsMoreTooltip = false;
		}
		else
		{
			Records.x.needsMoreTooltip = true;
		}
		if (es3File.KeyExists("CircleTutorialTip"))
		{
			Records.x.needsCircleTooltip = false;
		}
		else
		{
			Records.x.needsCircleTooltip = true;
		}
		Links.x.archives.CreateArchives();
		yield return new WaitForSecondsRealtime(0.001f);
		Links.x.cellar.CreateCellar();
		Links.x.options.LoadOptions();
		yield return new WaitForSecondsRealtime(0.1f);
		this.StartGameContinued();
		yield return new WaitForSecondsRealtime(0.5f);
		this.pathfindingReady = true;
		if (es3FileSerpent.KeyExists("SitsAnimal"))
		{
			Records.x.sitsAnimal = es3FileSerpent.Load<string>("SitsAnimal");
			Records.x.sitsCompanion1 = es3FileSerpent.Load<string>("SitsCompanion1");
			Records.x.sitsCompanion2 = es3FileSerpent.Load<string>("SitsCompanion2");
			Records.x.sitsCompanion3 = es3FileSerpent.Load<string>("SitsCompanion3");
			Records.x.sitsCompanion4 = es3FileSerpent.Load<string>("SitsCompanion4");
			Records.x.sitsNecholai = es3FileSerpent.Load<string>("SitsNecholai");
		}
		Links.x.prewarm.SetActive(false);
		Links.x.prewarm.transform.SetParent(Links.x.gameplay.transform);
		Links.x.camera3D.enabled = false;
		if (!Records.x.editor)
		{
			this.debugPlaylist = false;
		}
		yield break;
	}

	// Token: 0x06000D43 RID: 3395 RVA: 0x000FFC64 File Offset: 0x000FDE64
	public void StartGameContinued()
	{
		this.sceneLoaded = false;
		this.sceneToLoad = "_~[Menu]~_";
		Records.x.LoadGameFiles(true);
		this.cameraFollow = Records.x.cameraFollowing;
	}

	// Token: 0x06000D44 RID: 3396 RVA: 0x000FFC94 File Offset: 0x000FDE94
	public void PlayFade(string state, string timeMode)
	{
		if (timeMode == "Scaled")
		{
			Links.x.fadeAnimator.updateMode = AnimatorUpdateMode.Normal;
		}
		else
		{
			Links.x.fadeAnimator.updateMode = AnimatorUpdateMode.UnscaledTime;
		}
		if (state == "Out")
		{
			if (Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeIn") || Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeInLoop"))
			{
				Links.x.fadeAnimator.Play("FadeOut");
				return;
			}
		}
		else if (Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeOut") || Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeOutLoop"))
		{
			Links.x.fadeAnimator.Play("FadeIn");
		}
	}

	// Token: 0x06000D45 RID: 3397 RVA: 0x000FFD82 File Offset: 0x000FDF82
	public void NewGameFromMainMenu()
	{
		base.StartCoroutine(this.NewGame());
	}

	// Token: 0x06000D46 RID: 3398 RVA: 0x000FFD91 File Offset: 0x000FDF91
	private IEnumerator NewGame()
	{
		string text = Application.persistentDataPath + "/AutoSave";
		if (Directory.Exists(text))
		{
			string[] files = Directory.GetFiles(text);
			for (int i = 0; i < files.Length; i++)
			{
				File.Delete(files[i]);
			}
		}
		Records.x.mainMenuOpen = false;
		yield return new WaitForSecondsRealtime(0.25f);
		this.PlayFade("Out", "Unscaled");
		this.DestroyPartyObjects();
		this.partyNames.Clear();
		this.partyNames.Add("BloodlessHunter");
		this.partyIDs.Add(0);
		Records.x.partyTotal++;
		Links.x.journal.NewGame();
		Links.x.cameraEffects.pointLightShadows.SwitchingScenes();
		Links.x.RemoveScene();
		Links.x.ClearSceneLists();
		yield return new WaitForSecondsRealtime(0.25f);
		Links.x.gameplay.CloseDock();
		Links.x.gameplay.TogglePause(false);
		SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(1));
		SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(2));
		yield return new WaitForSecondsRealtime(0.25f);
		this.sceneToLoad = "F4_BanquetIsle";
		this.newGameFromMenu = true;
		this.addressablesLoading = true;
		this.ChangeLevels("Assets/+ Joseph/Maps/" + this.sceneToLoad + ".unity", this.sceneToLoad, "New Game");
		while (this.addressablesLoading)
		{
			yield return null;
		}
		yield break;
	}

	// Token: 0x06000D47 RID: 3399 RVA: 0x000FFDA0 File Offset: 0x000FDFA0
	public void ReturnToMainMenu()
	{
		this.clearPreviousScene = false;
		SceneManager.LoadScene(0, LoadSceneMode.Single);
	}

	// Token: 0x06000D48 RID: 3400 RVA: 0x000FFDB0 File Offset: 0x000FDFB0
	public void LoadFromGameFiles()
	{
		this.newGame = false;
		if (Records.x.combat)
		{
			Links.x.combat.EndCombat(false);
		}
		if (this.loadCoroutine == null)
		{
			this.loadCoroutine = this.LoadFromGameFilesTimed();
			base.StartCoroutine(this.loadCoroutine);
		}
	}

	// Token: 0x06000D49 RID: 3401 RVA: 0x000FFE01 File Offset: 0x000FE001
	private IEnumerator LoadFromGameFilesTimed()
	{
		Records.x.RemoveControls(true);
		Debug.Log("Load from game files");
		this.PlayFade("Out", "Unscaled");
		yield return new WaitForSecondsRealtime(0.25f);
		Links.x.saveLoad.StartEndMenu(false);
		Links.x.gameplay.CloseDock();
		if (Links.x.pocketWheel.rallyWheelOpen)
		{
			Links.x.pocketWheel.CloseRallyWheel(false);
		}
		Links.x.gameplay.TogglePause(false);
		if (Records.x.pocketPause)
		{
			Links.x.gameplay.PocketPause(false);
		}
		if (Records.x.partySailing)
		{
			this.boat.ClearBoatForRespawn();
			Records.x.partySailing = false;
		}
		Links.x.RemoveScene();
		Links.x.hudControl.ClearBadges();
		Links.x.hudControl.ClearBribeBadges();
		Links.x.hudControl.ClearSheep();
		Links.x.renderPortraits.Reloading();
		Links.x.gameFeed.ClearFeed();
		Links.x.hudControl.ClearRally();
		if (Records.x.circle)
		{
			Links.x.fellowship.BreakCircle(false);
		}
		this.DestroyPartyObjects();
		Links.x.ClearSceneLists();
		Records.x.mainMenuOpen = false;
		this.sceneLoaded = false;
		Links.x.partyColliderAdventure.itemCollector.EmptyItems();
		if (!Links.x.worldCamera.orthographic)
		{
			Links.x.rtsCamera.ReturnOrthographicCamera();
		}
		Links.x.cameraEffects.pointLightShadows.SwitchingScenes();
		yield return new WaitForSecondsRealtime(0.01f);
		if (SceneManager.sceneCount > 2)
		{
			SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(1));
			yield return new WaitForSecondsRealtime(0.25f);
			SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(1));
			yield return new WaitForSecondsRealtime(0.25f);
		}
		Records.x.LoadGameFiles(false);
		this.cameraFollow = Records.x.cameraFollowing;
		this.loadCoroutine = null;
		yield break;
	}

	// Token: 0x06000D4A RID: 3402 RVA: 0x000FFE10 File Offset: 0x000FE010
	public void GameFilesLoaded(string s)
	{
		this.sceneToLoad = s;
		this.currentSceneName = this.sceneToLoad;
		if (!(s == "_~[Menu]~_"))
		{
			this.addressablesLoading = true;
			this.ChangeLevels("Assets/+ Joseph/Maps/" + this.sceneToLoad + ".unity", this.sceneToLoad, "Game Files");
			Records.x.RemoveControls(false);
			return;
		}
		SceneManager.LoadScene(this.sceneToLoad, LoadSceneMode.Additive);
		if (this.sceneToLoad == "_~[Menu]~_")
		{
			SceneManager.LoadScene("Statues", LoadSceneMode.Additive);
			return;
		}
		Records.x.RemoveControls(false);
	}

	// Token: 0x06000D4B RID: 3403 RVA: 0x000FFEAB File Offset: 0x000FE0AB
	public void SetSavedExit(string n1, string n2)
	{
		this.savedMapExitName = n1;
		this.saveMapExitSub = n2;
	}

	// Token: 0x06000D4C RID: 3404 RVA: 0x000FFEBC File Offset: 0x000FE0BC
	public void Teleport(Character character, string sceneTo, MapExit.interiorNames interiorName, MapExit.interiorNames exteriorName, bool toInterior, MapExit clickedDoor)
	{
		character.ClearMoveTargets();
		character.body.SetMagicaClothState(false);
		int num = 0;
		MapExit mapExit;
		string text;
		if (toInterior)
		{
			num = 1;
			mapExit = Links.x.diorama.MatchMapExitInteriorExterior(toInterior, interiorName, clickedDoor);
			text = interiorName.ToString();
		}
		else
		{
			mapExit = Links.x.diorama.MatchMapExitInteriorExterior(toInterior, exteriorName, clickedDoor);
			text = "";
		}
		int desiredGraph = character.desiredGraph;
		string doorID = character.doorID;
		character.desiredGraph = num;
		if (toInterior)
		{
			character.doorID = text;
		}
		else
		{
			character.doorID = "";
		}
		character.lastDoorID = text;
		GraphNode graphNode = character.NearNode(mapExit.doorPoint, true, 0, num, 0);
		if (graphNode != null)
		{
			character.SetPosition((Vector3)graphNode.position, null);
			Quaternion rotation = mapExit.GetComponent<MapExitActions>().spawnPoint.rotation;
			Vector3 eulerAngles = rotation.eulerAngles;
			rotation.x = 0f;
			rotation.z = 0f;
			Vector3 vector = Quaternion.Euler(eulerAngles) * Vector3.forward * -1f;
			character.ClearNodePath();
			character.SetRotation(Quaternion.Euler(vector), false, true);
			character.ClaimNode(graphNode, (Vector3)graphNode.position, true);
			character.sphere.transform.position = this.tr.position;
			if (character.circleTr)
			{
				character.circleTr.position = character.tr.position;
			}
			character.SetMoveFollowPosition((Vector3)graphNode.position);
			character.savedFollowNode = character.node;
			character.savedPathTarget = character.node;
			if (num == 1)
			{
				if (Links.x.diorama.GetIndoorView())
				{
					character.indoorID = Links.x.diorama.GetIndoorView().GetInteriorBoundsName((Vector3)graphNode.position);
				}
				else
				{
					character.indoorID = "?";
				}
			}
			else
			{
				character.indoorID = "";
			}
			character.ChangeTorchLight();
			character.FirstPosition(graphNode);
			if (clickedDoor)
			{
				bool playDoorSound = clickedDoor.playDoorSound;
				MasterAudio.PlaySound3DAtVector3AndForget("Feedback", character.tr.position, 0.3f, new float?(1f), 0f, "Used Exit", null);
				if (clickedDoor.locationText != "")
				{
					clickedDoor.gameObject.GetComponent<MapExitActions>().Use();
				}
				clickedDoor.gameObject.GetComponent<MapExitActions>().Leave();
			}
			Links.x.fellowship.TeleportParty(true);
		}
		else
		{
			character.desiredGraph = desiredGraph;
			character.doorID = doorID;
		}
		if (character == Links.x.main)
		{
			Links.x.rtsCamera.JumpTo(Links.x.main.tr, true);
		}
		else
		{
			Links.x.sensory.UpdateCharactersIntExt(true);
		}
		character.body.SetMagicaClothState(true);
		character.selectedBeforeDoor = false;
	}

	// Token: 0x06000D4D RID: 3405 RVA: 0x001001CC File Offset: 0x000FE3CC
	public void TeleportNPC(Character character, MapExit exit, string exitID, bool toInterior)
	{
		int desiredGraph = character.desiredGraph;
		string doorID = character.doorID;
		string indoorID = character.indoorID;
		int num = 0;
		MapExit mapExit;
		if (toInterior)
		{
			num = 1;
			mapExit = exit;
			character.doorID = exitID;
		}
		else
		{
			mapExit = exit;
			character.doorID = "";
			character.indoorID = "";
		}
		character.desiredGraph = num;
		GraphNode graphNode = character.NearNode(mapExit.doorPoint, true, 0, num, 0);
		if (graphNode != null)
		{
			character.SetPosition((Vector3)graphNode.position, null);
			character.SetRotation(mapExit.GetComponent<MapExitActions>().spawnPoint.rotation, false, true);
			character.FirstPosition(graphNode);
			character.lastDoorID = exitID;
			if (num == 1)
			{
				if (Links.x.diorama.GetIndoorView())
				{
					character.indoorID = Links.x.diorama.GetIndoorView().GetInteriorBoundsName((Vector3)graphNode.position);
				}
				else
				{
					character.indoorID = "?";
				}
			}
			else
			{
				character.indoorID = "";
			}
			character.ChangeTorchLight();
			return;
		}
		character.desiredGraph = desiredGraph;
		character.doorID = doorID;
		character.indoorID = indoorID;
	}

	// Token: 0x06000D4E RID: 3406 RVA: 0x001002F0 File Offset: 0x000FE4F0
	public void ChangeScene(string sceneTo, string sceneFrom, string subExit)
	{
		Debug.Log(string.Concat(new string[] { sceneTo, " ", sceneFrom, " ", subExit }));
		if (!this.sceneLoaded)
		{
			return;
		}
		this.newGame = false;
		this.newSceneFromOverworldMap = false;
		base.StartCoroutine(this.WaitForSceneChange(sceneTo, sceneFrom, subExit));
	}

	// Token: 0x06000D4F RID: 3407 RVA: 0x00100350 File Offset: 0x000FE550
	public void ChangeSceneFromOverworld(string sceneTo, string sceneFrom)
	{
		if (!this.sceneLoaded)
		{
			return;
		}
		if (sceneTo == "None" || sceneTo == "Interiors" || sceneTo == "Exteriors" || sceneTo == "Same" || sceneTo == "x")
		{
			return;
		}
		this.newGame = false;
		this.newSceneFromOverworldMap = true;
		base.StartCoroutine(this.WaitForSceneChange(sceneTo, sceneFrom, "A"));
	}

	// Token: 0x06000D50 RID: 3408 RVA: 0x001003CA File Offset: 0x000FE5CA
	private IEnumerator WaitForSceneChange(string sceneTo, string sceneFrom, string subExit)
	{
		this.changingMapsComplete = false;
		for (int i = 0; i < this.changingMaps.Count; i++)
		{
			if (this.changingMaps[i])
			{
				if (this.changingMaps[i].IsSentient() && !this.changingMaps[i].ghost && this.changingMaps[i].hostility == 2 && !this.changingMaps[i].stats.characterRow._NeverLeaveMap && this.changingMaps[i].stats.characterRow._Quest == "")
				{
					this.changingMaps[i].changingMaps = true;
					this.changingMaps[i].creatures.futureDelay = this.changingMapsDistance[i];
					this.changingMaps[i].creatures.MoveToNewMap(this.changingMaps[i], sceneTo, Vector3.zero, this.changingMapsDistance[i]);
				}
				else
				{
					this.changingMaps[i] = null;
				}
			}
		}
		this.pathfindingReady = false;
		Links.x.gameplay.ChangeScene();
		if (Records.x.circle)
		{
			Links.x.fellowship.BreakCircle(false);
		}
		this.PlayFade("Out", "Unscaled");
		yield return new WaitForSecondsRealtime(0.26f);
		Records.x.TriggerGlobalSave("AutoSave", false);
		while (Records.x.IsSaving())
		{
			yield return null;
		}
		if (Records.x.CanSave())
		{
			Records.x.CopyToCheckPoint();
		}
		Links.x.diorama.CheckDelayedCharacters(sceneTo);
		this.waitingToRemoveScene = true;
		Links.x.hudControl.ClearBadges();
		Links.x.hudControl.ClearBribeBadges();
		Links.x.hudControl.ClearOnReload();
		Links.x.RemoveScene();
		while (this.waitingToRemoveScene)
		{
			yield return null;
		}
		Links.x.ClearSceneLists();
		this.sceneToLoad = sceneTo;
		this.sceneLoaded = false;
		this.savedSceneFrom = sceneFrom;
		this.savedSubExit = subExit;
		this.changeScene = sceneFrom;
		Records.x.RemoveControls(true);
		if (!Links.x.worldCamera.orthographic)
		{
			Links.x.rtsCamera.ReturnOrthographicCamera();
		}
		Links.x.partyColliderAdventure.itemCollector.EmptyItems();
		Links.x.gameplay.hitExit = false;
		this.newSceneFromMapExit = true;
		Records.x.inOverworldMap = false;
		if (sceneTo == "Invimona")
		{
			for (int j = 0; j < this.party.Count; j++)
			{
				if (this.party[j])
				{
					this.party[j].fowRevealer.enabled = false;
				}
			}
			Records.x.inOverworldMap = true;
			Links.x.hudControl.ChangeHudVisibility(false, true);
		}
		else if (sceneFrom == "Invimona")
		{
			for (int k = 0; k < this.party.Count; k++)
			{
				if (this.party[k] && this.party[k].fowRevealer)
				{
					this.party[k].fowRevealer.enabled = true;
				}
			}
		}
		if (this.boat)
		{
			this.boat.nodeMovingID = 0;
			this.boat.nodeStationaryID = 0;
		}
		Links.x.gameplay.CloseDock();
		Links.x.gameplay.TogglePause(false);
		Links.x.gameplay.ChangeScene();
		Links.x.cameraEffects.pointLightShadows.SwitchingScenes();
		this.cameraFollow = Links.x.rtsCamera.IsFollowing;
		Links.x.sceneMap.LeavingScene(sceneFrom);
		yield return new WaitForSecondsRealtime(0.01f);
		this.addressablesLoading = true;
		this.ChangeLevels("Assets/+ Joseph/Maps/" + this.sceneToLoad + ".unity", this.sceneToLoad, "Switching Scenes");
		yield break;
	}

	// Token: 0x06000D51 RID: 3409 RVA: 0x001003EE File Offset: 0x000FE5EE
	public void OnSceneUnloaded(Scene current)
	{
		this.unloaded = false;
	}

	// Token: 0x06000D52 RID: 3410 RVA: 0x001003F7 File Offset: 0x000FE5F7
	public void OnSceneLoaded(Scene current, LoadSceneMode mode)
	{
		this.loaded = false;
	}

	// Token: 0x06000D53 RID: 3411 RVA: 0x00100400 File Offset: 0x000FE600
	public void ChangeLevels(string addressableKey, string sceneName, string switchType)
	{
		base.StartCoroutine(this.SceneAddressables(addressableKey, sceneName, switchType));
	}

	// Token: 0x06000D54 RID: 3412 RVA: 0x00100412 File Offset: 0x000FE612
	private IEnumerator SceneAddressables(string addressableKey, string sceneName, string switchType)
	{
		this.unloaded = false;
		this.loaded = false;
		if (this.clearPreviousScene && SceneManager.sceneCount > 1)
		{
			this.cleared = false;
			this.unloaded = true;
			SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(1));
			if (this.unloaded)
			{
				yield return null;
			}
			this.cleared = true;
		}
		else
		{
			this.cleared = true;
		}
		while (!this.cleared)
		{
			yield return null;
		}
		Links.x.archives.clearing = true;
		Links.x.archives.ClearBetweenLevels();
		while (Links.x.archives.clearing)
		{
			yield return null;
		}
		if (switchType == "Main Menu" || Time.timeScale < 0.5f)
		{
			yield return new WaitForSecondsRealtime(0.1f);
		}
		else
		{
			yield return new WaitForSeconds(0.1f);
		}
		bool loading = false;
		if (addressableKey != "")
		{
			loading = true;
			this.loaded = true;
			if (switchType == "Switching Scenes")
			{
				base.StartCoroutine(this.FinishSceneSwitch(sceneName));
			}
			SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);
			if (this.loaded)
			{
				yield return null;
			}
			loading = false;
			this.clearPreviousScene = true;
		}
		while (loading)
		{
			yield return null;
		}
		if (switchType == "Main Menu")
		{
			this.cleared = false;
			SceneManager.LoadScene(0, LoadSceneMode.Single);
		}
		else
		{
			this.cleared = false;
			this.ClearMemory();
			while (!this.cleared)
			{
				yield return null;
			}
		}
		yield break;
	}

	// Token: 0x06000D55 RID: 3413 RVA: 0x00100436 File Offset: 0x000FE636
	private void ClearMemory()
	{
		Resources.UnloadUnusedAssets().completed += delegate(AsyncOperation operation)
		{
			this.cleared = true;
		};
	}

	// Token: 0x06000D56 RID: 3414 RVA: 0x0010044E File Offset: 0x000FE64E
	private IEnumerator FinishSceneSwitch(string sceneName)
	{
		Debug.Log("Finish scene switch");
		Links.x.hudControl.ClearSheep();
		Links.x.renderPortraits.Reloading();
		Records.x.SetupStunned();
		Records.x.SetupBribeBadges(sceneName);
		this.currentSceneName = this.sceneToLoad;
		Links.x.diorama = null;
		Links.x.fellowship.NewScene();
		while (Links.x.diorama == null)
		{
			yield return null;
		}
		MapExit exit = null;
		if (this.newSceneFromOverworldMap)
		{
			if (this.party.Count > 0)
			{
				this.party[0].SetPosition(Links.x.diorama.playerStartDefault.position, null);
				this.party[0].SetRotation(Links.x.diorama.playerStartDefault.rotation, false, true);
				this.party[0].FirstPosition(null);
				Links.x.fellowship.SetPartyPositions(false);
			}
		}
		else
		{
			exit = Links.x.diorama.MatchMapExit(this.savedSceneFrom, this.savedSubExit);
			string[] array = new string[8];
			array[0] = "SCENE SWITCH ";
			int num = 1;
			MapExit mapExit = exit;
			array[num] = ((mapExit != null) ? mapExit.ToString() : null);
			array[2] = " ";
			array[3] = this.party.Count.ToString();
			array[4] = " ";
			array[5] = this.savedSceneFrom;
			array[6] = " ";
			array[7] = this.savedSubExit;
			Debug.Log(string.Concat(array));
			if (this.party.Count > 0 && exit)
			{
				Debug.Log(exit.waterExit.ToString() + " " + exit.keepWaterPosition.ToString());
				if (!exit.waterExit)
				{
					this.party[0].SetPosition(exit.gameObject.GetComponent<MapExitActions>().spawnPoint.position, null);
					this.party[0].SetRotation(exit.gameObject.GetComponent<MapExitActions>().spawnPoint.rotation, false, true);
					this.party[0].FirstPosition(null);
					for (int i = 1; i < this.party.Count; i++)
					{
						if (this.party[i])
						{
							this.party[i].SetPosition(exit.gameObject.GetComponent<MapExitActions>().spawnPoint.position, null);
						}
					}
				}
				Links.x.fellowship.SetPartyPositions(false);
			}
		}
		yield return new WaitForSecondsRealtime(0.1f);
		if (exit && exit.waterExit)
		{
			Debug.Log("water exit");
			if (exit.keepWaterPosition)
			{
				this.boat.ChangeScenes(this.exitPoint);
			}
			else
			{
				Debug.Log("new point " + exit.gameObject.GetComponent<MapExitActions>().spawnPoint.position.ToString());
				this.boat.ChangeScenes(exit.gameObject.GetComponent<MapExitActions>().spawnPoint.position);
			}
		}
		this.changeScene = "";
		Records.x.RemoveControls(false);
		this.pathfindingReady = true;
		Debug.Log("Scene ready");
		yield break;
	}

	// Token: 0x06000D57 RID: 3415 RVA: 0x00100464 File Offset: 0x000FE664
	public void SwitchToBloodlessScene()
	{
		this.sceneLoaded = false;
		Records.x.RemoveControls(false);
		this.newGame = true;
		base.StartCoroutine(this.SwitchToSceneTimed("F4_BanquetIsle", true, "BloodlessHunter", 2f, false));
	}

	// Token: 0x06000D58 RID: 3416 RVA: 0x0010049D File Offset: 0x000FE69D
	public void SwitchToCharacterCreationScene()
	{
		this.sceneLoaded = false;
		Records.x.RemoveControls(true);
		base.StartCoroutine(this.SwitchToSceneTimed("C6_FortenLazure", true, "Protagonist", 1f, false));
	}

	// Token: 0x06000D59 RID: 3417 RVA: 0x001004D0 File Offset: 0x000FE6D0
	public void FinishCharacterCreation(GameObject go, bool fromBeginning)
	{
		if (fromBeginning)
		{
			Links.x.gameplay.TogglePause(false);
			Object.Destroy(Links.x.creation.gameObject);
		}
		else
		{
			Object.Destroy(Links.x.creation.gameObject);
			Links.x.creation = null;
			Links.x.gameplay.TogglePause(false);
			Records.x.dialogue = false;
			Records.x.RemoveControls(false);
			this.PlayFade("In", "Unscaled");
		}
		Links.x.fellowship.UpdateHotkeys();
		Links.x.cameraEffects.ToggleObscurance();
	}

	// Token: 0x06000D5A RID: 3418 RVA: 0x00100579 File Offset: 0x000FE779
	public void EndCharacterCreation()
	{
		Links.x.gameFeed.ClearFeed();
		base.gameObject.AddComponent<Cinematics>().StartPavuraWalk();
	}

	// Token: 0x06000D5B RID: 3419 RVA: 0x0010059A File Offset: 0x000FE79A
	private IEnumerator SwitchToSceneTimed(string newScene, bool destroyParty, string newPartyMember, float waitTime, bool checkPoint)
	{
		bool currentControls = Records.x.removeControls;
		Records.x.RemoveControls(true);
		while (Records.x.IsSaving())
		{
			yield return null;
		}
		yield return new WaitForSecondsRealtime(waitTime);
		Records.x.mainMenuOpen = false;
		this.PlayFade("Out", "Unscaled");
		yield return new WaitForSecondsRealtime(0.25f);
		if (destroyParty)
		{
			this.partyNames.Clear();
			this.partyIDs.Clear();
			this.partyNames.Add("Protagonist");
			this.partyIDs.Add(0);
			this.DestroyPartyObjects();
		}
		Links.x.RemoveScene();
		Links.x.ClearSceneLists();
		yield return new WaitForSecondsRealtime(0.5f);
		Links.x.gameplay.CloseDock();
		Links.x.gameplay.TogglePause(false);
		this.cameraFollow = Links.x.rtsCamera.IsFollowing;
		Links.x.cameraEffects.pointLightShadows.SwitchingScenes();
		this.addressablesLoading = true;
		this.sceneToLoad = newScene;
		this.ChangeLevels("Assets/+ Joseph/Maps/" + this.sceneToLoad + ".unity", this.sceneToLoad, "Timed");
		while (this.addressablesLoading)
		{
			yield return null;
		}
		yield return new WaitForSecondsRealtime(0.1f);
		Records.x.removeControls = currentControls;
		this.changingScene = false;
		Links.x.hudControl.ChangeHudVisibility(true, true);
		while (!Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeInLoop"))
		{
			yield return null;
		}
		if (checkPoint)
		{
			Records.x.TriggerGlobalSave("CheckpointSave", false);
		}
		while (Records.x.IsSaving())
		{
			yield return null;
		}
		yield break;
	}

	// Token: 0x06000D5C RID: 3420 RVA: 0x001005C8 File Offset: 0x000FE7C8
	public void CreateCharacterSingle(Vector3 pos, Quaternion rot, int partyID)
	{
		int freePartyNode = Links.x.GetFreePartyNode();
		this.CreateCharacter(true, freePartyNode, "Empty", partyID);
		this.party[freePartyNode].SceneSetup();
		this.party[freePartyNode].tr.position = pos;
		this.party[freePartyNode].SetRotation(rot, false, true);
		this.party[freePartyNode].FirstPosition(null);
	}

	// Token: 0x06000D5D RID: 3421 RVA: 0x0010063C File Offset: 0x000FE83C
	public void CreateCharacter(bool party, int num, string partyName, int partyID)
	{
		this.go = new GameObject("Player " + num.ToString());
		Character character = this.go.AddComponent<Character>();
		if (num == 0 && !Links.x.gaia.sceneLoaded)
		{
			Links.x.main = character;
			Links.x.protagonist = character;
		}
		character.SetupBasic(party, num, partyName, num * 2 + 1, false, partyID);
		if (Records.x.useTestCharacters && num == 0)
		{
			character.stats.protagonist = true;
			character.stats.level = 1;
		}
		if (Records.x.useTestCharacters)
		{
			Records.x.partyTotal++;
		}
	}

	// Token: 0x06000D5E RID: 3422 RVA: 0x001006F1 File Offset: 0x000FE8F1
	public void NewSceneLoaded()
	{
		SceneManager.SetActiveScene(SceneManager.GetSceneAt(0));
		this.SceneStartCommands();
	}

	// Token: 0x06000D5F RID: 3423 RVA: 0x00100705 File Offset: 0x000FE905
	public void SceneStartCommands()
	{
		base.StartCoroutine(this.SceneCommands());
	}

	// Token: 0x06000D60 RID: 3424 RVA: 0x00100714 File Offset: 0x000FE914
	private IEnumerator SceneCommands()
	{
		this.sceneLoaded = false;
		this.changingMapsComplete = false;
		this.loadingCharacterCreation = false;
		if (Links.x.diorama.sceneName == "C6_FortenLazure" && QuestLog.GetQuestState("CharacterCreation") != QuestState.Success && QuestLog.GetQuestState("CharacterCreation") != QuestState.Active)
		{
			this.loadingCharacterCreation = true;
			Debug.Log("Loading character creation");
		}
		Links.x.partyColliderCombat.gameObject.transform.localScale = Vector3.zero;
		Links.x.partyColliderAdventure.gameObject.transform.localScale = Vector3.zero;
		Links.x.combat.ClearNearby();
		Links.x.combat.ChangeScene();
		Shader.SetGlobalFloat("_Pocket", 0f);
		if (Links.x.diorama.playerStartDefault)
		{
			Links.x.rtsCamera.JumpTo(Links.x.diorama.playerStartDefault.position, Links.x.main, true);
		}
		if (Links.x.diorama.sceneName == "F4_BanquetIsle")
		{
			Records.x.banquetIsle = true;
		}
		else
		{
			Records.x.banquetIsle = false;
		}
		while (AstarPath.active == null)
		{
			yield return null;
		}
		while (AstarPath.active.graphs == null)
		{
			yield return null;
		}
		while (AstarPath.active.graphs.Length < 2)
		{
			yield return null;
		}
		while (AstarPath.active.DirtyNodeCount() > 0)
		{
			Debug.Log(AstarPath.active.DirtyNodeCount());
			yield return null;
		}
		yield return new WaitForSecondsRealtime(0.1f);
		this.interiorGraph = (GridGraph)AstarPath.active.graphs[1];
		this.exteriorGraph = (GridGraph)AstarPath.active.graphs[0];
		AstarPath.active.heuristic = Heuristic.Euclidean;
		if (!this.newSceneFromMapExit)
		{
			Links.x.characterSheet.anim.enabled = true;
			Links.x.characterSheet.anim.Play("Open", 0, 1f);
		}
		Records.x.inOverworldMap = false;
		Records.x.miniGame = false;
		Links.x.inputControls.NewScene();
		Links.x.sceneMap.DoLoad();
		if (!this.newSceneFromOverworldMap && Links.x.diorama.sceneName == "Invimona")
		{
			Records.x.inOverworldMap = true;
		}
		this.party = Links.x.party;
		int num;
		if (this.party.Count == 0)
		{
			int partyCount = 4;
			yield return new WaitForSecondsRealtime(0.1f);
			if (this.loadingCharacterCreation)
			{
				this.partyNames.Clear();
				this.partyIDs.Clear();
				this.partyNames.Add("Empty");
				this.partyNames.Add("Empty");
				this.partyNames.Add("Empty");
				this.partyNames.Add("Empty");
				this.partyIDs.Add(3);
				this.partyIDs.Add(4);
				this.partyIDs.Add(5);
				this.partyIDs.Add(6);
				Records.x.partyTotal = 7;
			}
			else if (Records.x.useTestCharacters)
			{
				this.partyNames.Clear();
				this.partyIDs.Clear();
				this.partyNames.Add("Josef");
				this.partyIDs.Add(3);
				this.partyNames.Add("Branwen");
				this.partyIDs.Add(4);
				this.partyNames.Add("Hannah");
				this.partyIDs.Add(5);
				this.partyNames.Add("Pug");
				this.partyIDs.Add(6);
				Records.x.partyTotal = 7;
			}
			partyCount = this.partyNames.Count;
			for (int i = 0; i < partyCount; i = num + 1)
			{
				this.settingUpParty = true;
				this.CreateCharacter(true, i, this.partyNames[i], this.partyIDs[i]);
				while (this.settingUpParty)
				{
					yield return null;
				}
				yield return new WaitForSecondsRealtime(0.01f);
				if (Records.x.banquetIsle && this.newGameFromMenu)
				{
					Library.Pagan pagan = Links.x.library.GetPaganRow("Mistral");
					List<Vector3> sockets = Links.x.main.sockets;
					sockets[20] = new Vector3((float)pagan._Number, 5f, 0f);
					sockets[21] = new Vector3(0f, 5f, 10f);
					Links.x.main.stats.EnchantJewelryEffects(20, true);
					Links.x.main.inventoryBag.socketA[10] = sockets[20];
					Links.x.main.inventoryBag.socketB[10] = sockets[21];
					pagan = Links.x.library.GetPaganRow("StormSword");
					sockets[0] = new Vector3((float)pagan._Number, 1f, 0f);
					sockets[1] = new Vector3(0f, 5f, 12f);
					Links.x.main.inventoryBag.socketA[0] = sockets[0];
					Links.x.main.inventoryBag.socketB[0] = sockets[1];
				}
				num = i;
			}
			for (int j = 0; j < partyCount; j++)
			{
				if (Records.x.useTestCharacters && Records.x.editor)
				{
					if (j == 0)
					{
						this.party[j].stats.SetMajorsMinors("Pagan", "Dexterity", "Strength", "Vines", "Hand-to-Hand", "Robes", false);
						global::Item item;
						ItemEquipped itemEquipped;
						Links.x.inventory.AddFromGround(null, null, 0, false, 0f, Links.x.library.GetInvRowID("Spellbook"), 1, new Vector3(3f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector4(0f, 0f, 0f, 0f), this.party[j], false, false, out item, out itemEquipped);
						this.party[j].stats.UpdateAbilityTriggers();
						this.party[j].portrait.skillBag.SetSpellbookGrid();
					}
					if (j == 1)
					{
						this.party[j].stats.SetMajorsMinors("Strength", "Dexterity", "Sensory", "Hand-to-Hand", "Bindings", "Robes", false);
						global::Item item2;
						ItemEquipped itemEquipped2;
						Links.x.inventory.AddFromGround(null, null, 0, false, 0f, Links.x.library.GetInvRowID("Songbook"), 1, new Vector3(4f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector4(0f, 0f, 0f, 0f), this.party[j], false, false, out item2, out itemEquipped2);
						this.party[j].stats.UpdateAbilityTriggers();
						this.party[j].portrait.skillBag.SetSongGrid();
					}
					if (j == 2)
					{
						this.party[j].stats.SetMajorsMinors("Sensory", "Dexterity", "Strength", "Hand-to-Hand", "Sneaking", "Sling", false);
						global::Item item3;
						ItemEquipped itemEquipped3;
						Links.x.inventory.AddFromGround(null, null, 0, false, 0f, Links.x.library.GetInvRowID("Songbook"), 1, new Vector3(5f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector4(0f, 0f, 0f, 0f), this.party[j], false, false, out item3, out itemEquipped3);
						this.party[j].stats.UpdateAbilityTriggers();
						this.party[j].portrait.skillBag.SetSongGrid();
					}
					if (j == 3)
					{
						this.party[j].stats.SetMajorsMinors("Strength", "Dexterity", "Aura", "Hand-to-Hand", "Flute", "Robes", false);
						global::Item item4;
						ItemEquipped itemEquipped4;
						Links.x.inventory.AddFromGround(null, null, 0, false, 0f, Links.x.library.GetInvRowID("Songbook"), 1, new Vector3(6f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector4(0f, 0f, 0f, 0f), this.party[j], false, false, out item4, out itemEquipped4);
						this.party[j].stats.UpdateAbilityTriggers();
						this.party[j].portrait.skillBag.SetSongGrid();
					}
					this.party[j].portrait.skillBag.trinketWindow.GridLayout(true, false);
				}
			}
		}
		else
		{
			for (int partyCount = 0; partyCount < this.party.Count; partyCount = num + 1)
			{
				this.party[partyCount].SceneSetup();
				yield return new WaitForSecondsRealtime(0.001f);
				num = partyCount;
			}
		}
		SceneManager.SetActiveScene(SceneManager.GetSceneAt(1));
		Records.x.currentPathNode = 13;
		Links.x.gameplay.SceneSwitch();
		Links.x.diorama.GetGhostNode();
		Links.x.pocketWheel.NewScene();
		Links.x.cameraEffects.pointLightShadows.DoneSwitchingScenes();
		if (!this.newSceneFromMapExit)
		{
			Links.x.inventory.Setup();
			Links.x.inventory.groundBag.Setup();
			Links.x.characterSheet.StartMenu(true);
		}
		yield return new WaitForSecondsRealtime(0.001f);
		Links.x.diorama.SetupInteractives1();
		yield return new WaitForSecondsRealtime(0.001f);
		Links.x.diorama.SetupInteractives2();
		Links.x.diorama.StartQuadCulling();
		yield return new WaitForSecondsRealtime(0.001f);
		Links.x.cameraEffects.SceneSwitch();
		Links.x.rtsCamera.CameraStart();
		Links.x.diorama.GetBreakableTiles();
		Links.x.fogOfWar.Load();
		if (Links.x.fogOfWarInterior)
		{
			Links.x.fogOfWarInterior.Load();
		}
		yield return new WaitForSecondsRealtime(0.001f);
		this.changingMapsComplete = true;
		if (Records.x.partySailing && this.boat && this.boat.setup && this.boat.node == null)
		{
			this.boat.ChangeScenes(this.exitPoint);
		}
		if (this.party.Count > 0 && this.changeScene == "")
		{
			bool flag = false;
			if (Links.x.diorama.sceneName.Contains("C6_FortenLazure") && QuestLog.GetQuestState("CharacterCreation") == QuestState.Unassigned)
			{
				flag = true;
			}
			if (this.newGameFromMenu || (Records.x.editor && Records.x.defaultStartPoint) || Links.x.diorama.sceneName == "Intro" || this.loadingCharacterCreation || flag)
			{
				Transform transform = Links.x.diorama.ReturnJumpPoint();
				if (flag || this.loadingCharacterCreation || this.newGameFromMenu || !Records.x.editor)
				{
					transform = Links.x.diorama.playerStartDefault;
				}
				this.party[0].SetPosition(transform.position, null);
				this.party[0].SetRotation(transform.rotation, false, true);
				this.party[0].FirstPosition(null);
				Links.x.fellowship.SetPartyPositions(false);
				Records.x.defaultStartPoint = false;
			}
		}
		this.playerStartingPosition = Links.x.main.tr.position;
		this.playerStartingNode = Links.x.main.node;
		Records.x.CheckForTemporaryCreatures(0);
		Links.x.diorama.FindCreatures();
		Records.x.CheckForTemporaryCreatures(1);
		Links.x.diorama.SetupCreatures();
		for (int k = 0; k < this.party.Count; k++)
		{
			if (Links.x.diorama.singleCharacter)
			{
				if (!this.party[k].mainSelected)
				{
					this.party[k].offMap = true;
					this.party[k].TurnScriptsOff();
				}
			}
			else if (this.party[k].inactive || this.party[k].offMap)
			{
				this.party[k].offMap = false;
				this.party[k].TurnScriptsOn();
			}
		}
		yield return new WaitForSecondsRealtime(0.001f);
		Links.x.diorama.SetupItems();
		if (!Records.x.mainMenuOpen && this.sceneToLoad != "F4_BanquetIsle" && !this.loadingCharacterCreation)
		{
			Links.x.hudControl.ChangeHudVisibility(true, true);
		}
		if (Records.x.inOverworldMap || this.loadingCharacterCreation)
		{
			Links.x.hudControl.ChangeHudVisibility(false, true);
		}
		Links.x.rtsCamera.SwitchScene();
		Links.x.hudControl.SwitchScene();
		Links.x.hudControl.canvas.enabled = true;
		Links.x.partyColliderAdventure.itemCollector.LoadScene();
		for (int partyCount = 0; partyCount < this.party.Count; partyCount = num + 1)
		{
			this.party[partyCount].FirstPosition(null);
			yield return new WaitForSecondsRealtime(0.001f);
			if (Records.x.inOverworldMap)
			{
				this.party[partyCount].SetMeshState(false);
			}
			else
			{
				this.party[partyCount].SetMeshState(true);
			}
			this.party[partyCount].stats.FormationTactics();
			num = partyCount;
		}
		if (!this.newSceneFromMapExit)
		{
			this.LoadSummons();
		}
		else
		{
			for (int l = 0; l < this.party.Count; l++)
			{
				if (this.party[l].summoned && this.party[l] != this.boro && this.party[l].dockFriend)
				{
					this.party[l].dockFriend.AddPortrait();
				}
			}
		}
		Links.x.gameplay.SetControlsText(false);
		if (!Links.x.diorama.underground && !Records.x.banquetIsle && !Records.x.mainMenuOpen)
		{
			Links.x.sceneMap.NewScene(Links.x.diorama.sceneName);
		}
		bool flag2 = false;
		if (this.loadingCharacterCreation || this.sceneToLoad == "F4_BanquetIsle")
		{
			this.partyBoat.SetActive(false);
			this.party[0].fowRevealer.main = true;
			Links.x.beachCollider.SetActive(false);
		}
		else
		{
			if (Links.x.diorama.playerStartBoatDefault && Records.x.BoroInParty())
			{
				flag2 = true;
				Records.x.boroLastBeachPoint = Links.x.diorama.playerStartBoatDefault.position;
			}
			if (flag2)
			{
				Vector3 boroPosition = Records.x.boroPosition;
				Quaternion boroRotation = Records.x.boroRotation;
				bool partySailing = Records.x.partySailing;
				string boroScene = Records.x.boroScene;
				Quaternion boatRotation = Records.x.boatRotation;
				Vector3 boatPosition = Records.x.boatPosition;
				bool partyBoatDown = Records.x.partyBoatDown;
				if (Records.x.boroName == "")
				{
					Records.x.boroName = "Boro";
				}
				if (flag2)
				{
					if (Records.x.boroID == "")
					{
						Debug.Log("Missing boro info");
						Records.x.AddFirstBoro();
					}
					string boroID = Records.x.boroID;
					if (partySailing)
					{
						if (this.boro)
						{
							string boroModel = Records.x.GetBoroModel(boroID, false, true);
							if (!(this.boro.stats.model == boroModel))
							{
								Links.x.gaia.boro.stats.model = boroModel;
								Links.x.gaia.boro.SetupBody();
							}
						}
						if (!this.boro)
						{
							Records.x.CreateBoro(false);
						}
						Links.x.gaia.boro.SetMeshState(false);
						this.partyBoat.SetActive(true);
						if (!this.boat.setup)
						{
							this.boat.PartySetupFromLoad();
							this.partyBoat.transform.position = boatPosition;
							this.partyBoat.transform.rotation = boatRotation;
						}
						this.restingBoat.SetActive(false);
					}
					else
					{
						if (!this.boro)
						{
							Records.x.CreateBoro(true);
						}
						this.partyBoat.SetActive(false);
						if (partyBoatDown)
						{
							this.restingBoat.SetActive(true);
							this.restingBoat.transform.position = boatPosition;
							this.restingBoat.transform.rotation = boatRotation;
						}
						else
						{
							this.restingBoat.SetActive(false);
						}
					}
				}
				else
				{
					this.partyBoat.SetActive(false);
				}
			}
			else
			{
				Links.x.beachCollider.SetActive(false);
			}
		}
		Records.x.boroNearby = flag2;
		if (!this.newSceneFromMapExit)
		{
			Links.x.characterSheet.StartEndMenu(false, false);
		}
		Links.x.OrderPortraitList();
		Links.x.characterSheet.OrderPortraits();
		Links.x.hudControl.SetPortraitPositions();
		Links.x.hudControl.SetPortraitBacks();
		Links.x.partyColliderAdventure.itemCollector.UpdateSize();
		Links.x.fellowship.UpdateHotkeys();
		Links.x.fellowship.SetFriends();
		yield return new WaitForSecondsRealtime(0.05f);
		if (Records.x.mainMenuOpen)
		{
			Links.x.hudControl.ChangeHudVisibility(false, true);
		}
		else if (!Records.x.dialogue && !Records.x.removeControls && this.loadingCharacterCreation)
		{
			Links.x.hudControl.ChangeHudVisibility(true, true);
		}
		for (int partyCount = 0; partyCount < this.party.Count; partyCount = num + 1)
		{
			this.party[partyCount].FirstPosition(null);
			yield return new WaitForSecondsRealtime(0.001f);
			if (Records.x.inOverworldMap)
			{
				this.party[partyCount].SetMeshState(false);
			}
			else if ((this.party[partyCount].isBoro && !this.party[partyCount].sailing) || !this.party[partyCount].isBoro)
			{
				this.party[partyCount].SetMeshState(true);
			}
			if (!this.party[partyCount].summoned && !this.party[partyCount].isBoro)
			{
				Links.x.fellowship.AddPortraitChange(this.party[partyCount]);
			}
			if (partyCount == 0 && this.loadingCharacterCreation)
			{
				this.party[partyCount].AddToSelected(true, false);
			}
			num = partyCount;
		}
		if (Links.x.main.node == null)
		{
			Links.x.main.FindCurrentNodeAnytime(true);
		}
		this.playerStartingPosition = Links.x.main.tr.position;
		this.playerStartingNode = Links.x.main.node;
		Links.x.diorama.UpdateTemporaryCreatureStartNodes();
		if (this.sceneToLoad == "F4_BanquetIsle" && this.newGameFromMenu)
		{
			this.party[0].SetPosition(Links.x.diorama.playerStartDefault.position, null);
			this.party[0].SetRotation(Links.x.diorama.playerStartDefault.rotation, false, true);
			this.party[0].FirstPosition(null);
			this.playerStartingPosition = Links.x.main.tr.position;
			this.playerStartingNode = Links.x.main.node;
			base.StartCoroutine(this.Intro());
		}
		if (this.sceneToLoad == "C6_FortenLazure" && QuestLog.GetQuestState("CharacterCreation") == QuestState.Unassigned)
		{
			Links.x.diorama.gameObject.AddComponent<Cinematics>().StartDemo();
		}
		if (this.newGameFromMenu)
		{
			Links.x.diorama.gameObject.AddComponent<Cinematics>().StartBanquetIsle();
		}
		this.SceneCamera();
		if (this.boro)
		{
			Links.x.hudControl.ShowSheep(false);
			if (Records.x.boroInvisible || Links.x.cameraEffects.indoors)
			{
				this.boroControls.Leave();
			}
		}
		Links.x.cameraEffects.SetShadowInfo();
		Links.x.sceneMap.CheckQuests();
		if (Links.x.sceneMap.undergroundMap)
		{
			Links.x.sceneMap.undergroundMap.UsedPreviousDoor(this.savedMapExitName, this.saveMapExitSub);
		}
		this.savedMapExitName = "";
		this.saveMapExitSub = "";
		Links.x.gameFeed.SetState(Links.x.options.gameFeedState);
		yield return new WaitForSecondsRealtime(0.2f);
		this.sceneLoaded = true;
		this.SetEnvironmentPlaylist(false, Links.x.main.inTown, true);
		if (Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeOut") || Links.x.fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("FadeOutLoop"))
		{
			if (this.loadingCharacterCreation)
			{
				yield return new WaitForSecondsRealtime(0.2f);
			}
			if (!this.newGameFromMenu && !this.loadingCharacterCreation)
			{
				this.PlayFade("In", "Unscaled");
			}
		}
		if (Records.x.useTestCharacters)
		{
			Links.x.protagonist = this.party[0];
			this.party[0].stats.protagonist = true;
			this.party[0].protagonist = true;
		}
		this.newGameFromMenu = false;
		for (int m = 0; m < this.party.Count; m++)
		{
			if (this.party[m] && this.party[m].fowRevealer)
			{
				this.party[m].fowRevealer.enabled = true;
			}
			if (this.party[m] && this.party[m].fowRevealerInterior)
			{
				this.party[m].fowRevealerInterior.enabled = true;
			}
			if (this.party[m] && !this.party[m].isBoro && !this.party[m].summoned)
			{
				this.party[m].RemovePlayerLight();
				this.party[m].portrait.skillBag.NewPortrait();
			}
		}
		List<Boat> boats = Links.x.boats;
		for (int n = 0; n < boats.Count; n++)
		{
			if (boats[n] && !boats[n].navigator)
			{
				boats[n].SetBoatNavigator(null, false);
			}
		}
		Records.x.CheckForTemporaryCreatures(2);
		Links.x.diorama.UpdateTemporaryCreatureStartNodes();
		Links.x.hudControl.LoadButtonImages();
		Links.x.sensory.StartGrounder();
		this.newSceneFromMapExit = false;
		this.newSceneFromOverworldMap = false;
		if (this.doCircle)
		{
			Records.x.CircleFromLoad();
		}
		this.doCircle = false;
		yield return new WaitForSecondsRealtime(0.5f);
		Links.x.cameraEffects.ToggleObscurance();
		Links.x.partyColliderCombat.gameObject.transform.localScale = Vector3.one;
		Links.x.partyColliderAdventure.gameObject.transform.localScale = Vector3.one;
		Links.x.main.DoFootsteps();
		Links.x.rtsCamera.Follow(Links.x.main.transform, Links.x.main, false);
		if (Links.x.diorama.underground && Links.x.sceneMap.undergroundMap)
		{
			Links.x.sceneMap.undergroundMap.ChangedArea(Links.x.rtsCamera.currentBoundsName);
		}
		Records.x.useTestCharacters = false;
		yield break;
	}

	// Token: 0x06000D61 RID: 3425 RVA: 0x00100724 File Offset: 0x000FE924
	public void SceneCamera()
	{
		if (!Records.x.dialogue)
		{
			Links.x.rtsCamera.JumpTo(Links.x.main.tr, true);
			Links.x.rtsCamera.Follow(Links.x.main.transform, Links.x.main, false);
			Links.x.cameraEffects.ToggleInteriorExterior(Links.x.main);
			Links.x.rtsCamera.singleJumpFrame = 3;
			if (!Records.x.cameraFollowing && Records.x.cameraPosition != Vector3.zero)
			{
				Links.x.rtsCamera.gameObject.transform.position = Records.x.cameraPosition;
				Links.x.rtsCamera.cameraTarget.transform.position = Records.x.cameraTargetPosition;
				Links.x.rtsCamera.LookAt = Records.x.cameraTargetPosition;
				Links.x.rtsCamera.singleJumpFrame = 3;
				Links.x.cameraEffects.ToggleInteriorExterior(Links.x.main);
				return;
			}
		}
		else
		{
			Links.x.cameraEffects.ToggleInteriorExterior(Links.x.main);
		}
	}

	// Token: 0x06000D62 RID: 3426 RVA: 0x0010087B File Offset: 0x000FEA7B
	private IEnumerator Intro()
	{
		Records.x.mainMenuOpen = false;
		Records.x.RemoveControls(true);
		yield return new WaitForSecondsRealtime(0.25f);
		Records.x.RemoveControls(false);
		Links.x.hudControl.ChangeHudVisibility(true, true);
		yield return new WaitForSecondsRealtime(2f);
		yield break;
	}

	// Token: 0x06000D63 RID: 3427 RVA: 0x00100883 File Offset: 0x000FEA83
	public void OpenCharacterCreation(bool fromBeginning, Character cc, Character respec)
	{
		if (fromBeginning)
		{
			this.ccCharacter = cc;
		}
		base.StartCoroutine(this.OpenCharacterCreationTimed(fromBeginning, respec));
	}

	// Token: 0x06000D64 RID: 3428 RVA: 0x0010089E File Offset: 0x000FEA9E
	private IEnumerator OpenCharacterCreationTimed(bool fromBeginning, Character respec)
	{
		if (Links.x.creation)
		{
			if (fromBeginning)
			{
				Links.x.gaia.PlayFade("Out", "Unscaled");
				yield return new WaitForSecondsRealtime(0.25f);
			}
			Links.x.gameplay.TogglePause(false);
			Links.x.creation.fromBeginning = fromBeginning;
			Links.x.creation.gameObject.SetActive(true);
			if (fromBeginning)
			{
				Links.x.gaia.PlayFade("In", "Unscaled");
			}
		}
		else
		{
			bool justRespec = false;
			int previousXP = 0;
			int previousLevel = 0;
			if (fromBeginning)
			{
				Links.x.gaia.PlayFade("Out", "Unscaled");
				yield return new WaitForSecondsRealtime(0.25f);
				Links.x.gaia.PlayFade("In", "Unscaled");
			}
			else if (!fromBeginning && respec)
			{
				SceneManager.SetActiveScene(SceneManager.GetSceneAt(0));
				justRespec = true;
				previousXP = respec.stats.XP;
				previousLevel = respec.stats.level;
				respec.stats.level = 1;
				respec.stats.XP = 0;
			}
			else
			{
				SceneManager.SetActiveScene(SceneManager.GetSceneAt(0));
				yield return new WaitForSecondsRealtime(0.1f);
				if (Records.x.partyTotal < 7)
				{
					Records.x.partyTotal = 7;
				}
				Links.x.gaia.CreateCharacterSingle(Links.x.main.tr.position, Links.x.main.tr.rotation, Records.x.partyTotal + 1);
				yield return new WaitForSecondsRealtime(0.4f);
			}
			SceneManager.SetActiveScene(SceneManager.GetSceneAt(1));
			GameObject gameObject = Object.Instantiate<GameObject>(this.characterCreation, Vector3.zero, Quaternion.Euler(Vector3.zero), null);
			gameObject.GetComponent<Creation>().fromBeginning = fromBeginning;
			gameObject.GetComponent<Creation>().justRespec = justRespec;
			gameObject.GetComponent<Creation>().respecCharacter = respec;
			gameObject.GetComponent<Creation>().previousXP = previousXP;
			gameObject.GetComponent<Creation>().previousLevel = previousLevel;
			Links.x.gameplay.TogglePause(false);
		}
		yield break;
	}

	// Token: 0x06000D65 RID: 3429 RVA: 0x001008BC File Offset: 0x000FEABC
	public void SetEnvironmentPlaylist(bool onBeach, bool inTown, bool alwaysCheckSoundtrack)
	{
		bool flag = false;
		string text = "";
		if (Links.x.hasMain && !Links.x.diorama.underground && Links.x.main.desiredGraph == 1)
		{
			flag = true;
		}
		if (onBeach)
		{
			text = "Beach";
		}
		else if (inTown && !flag)
		{
			if (Links.x.gameplay.IsNight())
			{
				text = "Night Town";
			}
			else
			{
				text = "Town";
			}
		}
		else if (flag)
		{
			text = "None";
		}
		else if (!inTown)
		{
			if (Links.x.diorama.exteriorForest)
			{
				text = "Forest";
			}
			else if (Links.x.diorama.exteriorDeepForest)
			{
				text = "DeepForest";
			}
			else if (Links.x.diorama.exteriorWaterBeach)
			{
				text = "Water";
			}
			else if (Links.x.diorama.exteriorBog)
			{
				text = "Forest";
			}
			else if (Links.x.diorama.exteriorMountains)
			{
				text = "Forest";
			}
			else if (Links.x.diorama.interiorCave)
			{
				text = "Cave";
			}
			else if (Links.x.diorama.interiorTomb)
			{
				text = "InteriorEmpty";
			}
			else if (Links.x.diorama.horror)
			{
				text = "Horror";
			}
		}
		if (Records.x.mainMenuOpen || (flag && Links.x.creation))
		{
			text = "Tavern";
		}
		if (text == "None")
		{
			this.FadeOutPlaylist(false, 1f);
		}
		else
		{
			this.SetPlaylist(text, false, 0f);
		}
		if (this.debugPlaylist)
		{
			Debug.Log(text + " " + this.currentPlaylist);
		}
		if (text != this.currentPlaylist || alwaysCheckSoundtrack || this.currentPlaylist == "")
		{
			this.CheckForNewSoundtrack(text, flag, inTown);
		}
	}

	// Token: 0x06000D66 RID: 3430 RVA: 0x00100AB4 File Offset: 0x000FECB4
	public void CheckForNewSoundtrack(string n, bool indoors, bool inTown)
	{
		if (this.debugPlaylist)
		{
			Debug.Log(string.Concat(new string[]
			{
				"Checking for new soundtrack ",
				n,
				" ",
				indoors.ToString(),
				" ",
				inTown.ToString(),
				" ",
				this.playingSoundtrackFromInWorld.ToString(),
				" ",
				Links.x.gaia.sceneLoaded.ToString()
			}));
		}
		if (this.playingSoundtrackFromInWorld)
		{
			return;
		}
		if (!Links.x.gaia.sceneLoaded)
		{
			return;
		}
		if (Records.x.removeControls)
		{
			return;
		}
		if (Records.x.InCombat(false))
		{
			return;
		}
		float num = Random.Range(1f, 10f);
		if (Records.x.banquetIsle)
		{
			if (!Records.x.removeControls)
			{
				this.SetPlaylist("Banquet Isle", true, Random.Range(1f, 3f));
				return;
			}
		}
		else if (n == "Town" || (indoors && inTown))
		{
			int num2 = Random.Range(0, 6);
			if (num2 == 0)
			{
				this.SetPlaylist("Garrison", true, num);
				return;
			}
			if (num2 == 1)
			{
				this.SetPlaylist("Ambience", true, num);
				return;
			}
			if (num2 == 2)
			{
				this.SetPlaylist("Mood", true, num);
				return;
			}
			if (num2 == 3)
			{
				this.SetPlaylist("Wandering", true, num);
				return;
			}
			if (num2 == 4)
			{
				this.SetPlaylist("Lazure", true, num);
				return;
			}
			if (num2 == 5)
			{
				this.SetPlaylist("Wandering", true, num);
				return;
			}
		}
		else
		{
			if (n == "Forest")
			{
				int num3 = Random.Range(0, 4);
				if (num3 == 0)
				{
					this.SetPlaylist("Trees", true, num);
				}
				else if (num3 == 1)
				{
					this.SetPlaylist("Creepy Trees", true, num);
				}
				else if (num3 == 2)
				{
					this.SetPlaylist("Mood", true, num);
				}
				else if (num3 == 3)
				{
					this.SetPlaylist("Wandering", true, num);
				}
				else if (num3 == 4)
				{
					this.SetPlaylist("Ambience", true, num);
				}
			}
			if (n == "Cave")
			{
				this.SetPlaylist("Caves", true, num);
			}
			if (n == "InteriorEmpty" && !Links.x.diorama.interiorTomb)
			{
				int num4 = Random.Range(0, 4);
				if (num4 == 0)
				{
					this.SetPlaylist("Dangerous Area A", true, num);
				}
				else if (num4 == 1)
				{
					this.SetPlaylist("Dangerous Area B", true, num);
				}
				else if (num4 == 2)
				{
					this.SetPlaylist("Dangerous Area C", true, num);
				}
				else if (num4 == 3)
				{
					this.SetPlaylist("Lachovinians", true, num);
				}
			}
			if (n == "Tomb" || Links.x.diorama.interiorTomb)
			{
				this.SetPlaylist("Tomb", true, num);
			}
		}
	}

	// Token: 0x06000D67 RID: 3431 RVA: 0x00100D6C File Offset: 0x000FEF6C
	public void SetPlaylist(string playlistName, bool useSoundtrackPlaylist, float delay)
	{
		if (useSoundtrackPlaylist)
		{
			Links.x.soundtrack.onlyStartCombatTracks = this.playingSoundtrackFromInWorld;
			if (this.debugPlaylist)
			{
				Debug.Log("From gaia set playlist " + playlistName + " " + this.currentSoundtrack);
			}
			if (playlistName != this.currentSoundtrack && (!this.playingSoundtrackFromInWorld || (Records.x.InCombat(false) && this.playingSoundtrackFromInWorld)))
			{
				this.currentSoundtrack = playlistName;
				if (!Records.x.editor)
				{
					Links.x.soundtrack.debug = false;
				}
				Links.x.soundtrack.filming = Records.x.filming;
				Links.x.soundtrack.currentSoundtrack = this.currentSoundtrack;
				Links.x.soundtrack.StartSong(1f, this.currentSoundtrack, delay);
				return;
			}
		}
		else if (playlistName != this.currentPlaylist)
		{
			this.currentPlaylist = playlistName;
			if (playlistName != "")
			{
				MasterAudio.FadePlaylistToVolume("PlaylistController", Links.x.options.soundVolume, 2f);
				MasterAudio.StartPlaylist("PlaylistController", playlistName, null);
			}
		}
	}

	// Token: 0x06000D68 RID: 3432 RVA: 0x00100EA4 File Offset: 0x000FF0A4
	public void FadeOutPlaylist(bool useSoundtrackPlaylist, float fadeTime)
	{
		Links.x.soundtrack.onlyStartCombatTracks = this.playingSoundtrackFromInWorld;
		if (this.debugPlaylist)
		{
			Debug.Log("From gaia fade out playlist " + useSoundtrackPlaylist.ToString());
		}
		if (useSoundtrackPlaylist)
		{
			this.currentSoundtrack = "";
			Links.x.soundtrack.currentSoundtrack = "";
			Links.x.soundtrack.EndSong(fadeTime, false);
			return;
		}
		this.currentPlaylist = "";
		MasterAudio.FadePlaylistToVolume("PlaylistController", 0f, fadeTime);
	}

	// Token: 0x06000D69 RID: 3433 RVA: 0x00100F34 File Offset: 0x000FF134
	public void SaveSummons()
	{
		string text = Records.x.openBook + "/Summons.es3";
		this.saveFile = new ES3File(text);
		this.summons.Clear();
		this.summonPosition.Clear();
		this.summonHealth.Clear();
		this.summonsTime.Clear();
		this.summonsDetails.Clear();
		this.summonsPotency.Clear();
		for (int i = 0; i < this.party.Count; i++)
		{
			if (this.party[i].summoned && this.party[i] != this.boro)
			{
				float leaveTime = this.party[i].stats.leaveTime;
				if (this.party[i].stats.HealthCurrent() > 0 && (!this.party[i].summoned || (this.party[i].summoned && !this.party[i].stats.xmlName.Contains("Summon"))))
				{
					this.summonPosition.Add(this.party[i].tr.position);
					this.summons.Add(this.party[i].stats.xmlName);
					this.summonHealth.Add(this.party[i].stats.HealthCurrent());
					this.summonsTime.Add(leaveTime);
					this.summonsDetails.Add(this.party[i].GetBoundCharacter());
					bool flag = this.party[i].stats.HasEffect("PipePotency");
					bool flag2 = this.party[i].stats.HasEffect("CharmPotency");
					if (flag)
					{
						Effects existingEffect = this.party[i].stats.GetExistingEffect("PipePotency");
						if (existingEffect)
						{
							this.summonsPotency.Add(existingEffect.sourceLevel);
						}
						else
						{
							this.summonsPotency.Add(0f);
						}
						this.party[i].pipeSummons = true;
					}
					if (flag2)
					{
						Effects existingEffect2 = this.party[i].stats.GetExistingEffect("CharmPotency");
						if (existingEffect2)
						{
							this.summonsPotency.Add(existingEffect2.sourceLevel);
						}
						else
						{
							this.summonsPotency.Add(0f);
						}
					}
					if (!flag2 && !flag)
					{
						this.summonsPotency.Add(0f);
					}
				}
			}
		}
		this.saveFile.Save<List<string>>("Summons", this.summons);
		this.saveFile.Save<List<int>>("SummonsHealth", this.summonHealth);
		this.saveFile.Save<List<Vector3>>("SummonsPosition", this.summonPosition);
		this.saveFile.Save<List<float>>("SummonsTime", this.summonsTime);
		this.saveFile.Save<List<string>>("SummonsScene", this.summonsDetails);
		this.saveFile.Save<List<float>>("SummonsPotency", this.summonsPotency);
		this.saveFile.Sync();
	}

	// Token: 0x06000D6A RID: 3434 RVA: 0x00101288 File Offset: 0x000FF488
	public void LoadSummons()
	{
		string text = Records.x.openBook + "/Summons.es3";
		this.saveFile = new ES3File(text);
		this.summons.Clear();
		this.summonPosition.Clear();
		this.summonHealth.Clear();
		this.summonsTime.Clear();
		this.summonsDetails.Clear();
		this.summonsPotency.Clear();
		if (this.saveFile.KeyExists("Summons"))
		{
			this.summonHealth = this.saveFile.Load<List<int>>("SummonsHealth");
			this.summons = this.saveFile.Load<List<string>>("Summons");
			this.summonPosition = this.saveFile.Load<List<Vector3>>("SummonsPosition");
			this.summonsTime = this.saveFile.Load<List<float>>("SummonsTime");
			this.summonsDetails = this.saveFile.Load<List<string>>("SummonsScene");
			this.summonsPotency = this.saveFile.Load<List<float>>("SummonsPotency");
			for (int i = 0; i < this.summons.Count; i++)
			{
				Character firstCharacter = this.CreateCreature(this.summonPosition[i], Quaternion.LookRotation(Links.x.main.tr.position, this.summonPosition[i]), this.summons[i], true, this.summonsTime[i], 1).GetFirstCharacter();
				if (Links.x.diorama.singleCharacter)
				{
					firstCharacter.offMap = true;
					firstCharacter.TurnScriptsOff();
				}
				if (this.summonsPotency[i] > 0f && firstCharacter)
				{
					if (this.summons[i].Contains("Summon"))
					{
						Effects effects = firstCharacter.gameObject.AddComponent<Effects>();
						Links.x.cellar.AddEffects(effects);
						effects.source = null;
						effects.target = firstCharacter;
						effects.effectName = "PipePotency";
						effects.sourceLevel = this.summonsPotency[i];
						effects.Inflicted(true);
					}
					if (firstCharacter.stats.race == "Forest" || firstCharacter.stats.race == "Fish" || firstCharacter.stats.race == "Shroom")
					{
						Effects effects2 = firstCharacter.gameObject.AddComponent<Effects>();
						Links.x.cellar.AddEffects(effects2);
						effects2.source = null;
						effects2.target = firstCharacter;
						effects2.effectName = "CharmPotency";
						effects2.sourceLevel = this.summonsPotency[i];
						effects2.Inflicted(true);
					}
				}
				if (firstCharacter)
				{
					if (firstCharacter.stats.race == "Vol")
					{
						Character character = Links.x.GetPartyFromName(this.summonsDetails[i]);
						if (!character)
						{
							character = Links.x.GetPagan();
						}
						firstCharacter.GetFriendDock(character);
					}
					if (firstCharacter.stats.race == "Forest" || firstCharacter.stats.race == "Fish" || firstCharacter.stats.race == "Shroom")
					{
						Character character2 = Links.x.GetPartyFromName(this.summonsDetails[i]);
						if (!character2)
						{
							character2 = Links.x.GetBinder(firstCharacter.stats.race);
						}
						firstCharacter.Charmed(character2);
					}
				}
			}
		}
	}

	// Token: 0x06000D6B RID: 3435 RVA: 0x00101624 File Offset: 0x000FF824
	public CreatureActions CreateCreature(Vector3 position, Quaternion rotation, string xmlName, bool alliedToParty, float summonTime, int number)
	{
		GameObject gameObject = new GameObject("Summoned " + xmlName + " " + number.ToString());
		gameObject.transform.parent = base.gameObject.transform;
		gameObject.transform.parent = null;
		gameObject.transform.position = position;
		gameObject.transform.rotation = rotation;
		GameObject gameObject2 = new GameObject("DayNight");
		gameObject2.transform.SetParent(gameObject.transform);
		gameObject2.transform.localPosition = Vector3.zero;
		GameObject gameObject3 = new GameObject("Walk");
		gameObject3.transform.SetParent(gameObject2.transform);
		gameObject3.transform.localPosition = Vector3.zero;
		Creatures creatures = gameObject.AddComponent<Creatures>();
		if (number == 0)
		{
			number = 1;
		}
		creatures.number = number;
		int characterCreatureIndex = Records.x.GetCharacterCreatureIndex(xmlName);
		if (characterCreatureIndex > -1)
		{
			creatures.characterName = (Creatures.xmlNames)characterCreatureIndex;
			if (alliedToParty)
			{
				creatures.temperament = Creatures.temperamentState.Ally;
			}
			else if (xmlName.Contains("Boro"))
			{
				creatures.temperament = Creatures.temperamentState.FightsIfAttacked;
			}
			else
			{
				creatures.temperament = Creatures.temperamentState.AttacksOnSight;
			}
			CreatureActions creatureActions = gameObject.gameObject.AddComponent<CreatureActions>();
			creatureActions.creatures = creatures;
			creatureActions.summons = true;
			creatureActions.alliedToParty = alliedToParty;
			if (xmlName == "Ghost")
			{
				creatureActions.SetAsResurrected();
			}
			creatureActions.SetupCreatures();
			Character firstCharacter = creatureActions.GetFirstCharacter();
			if (firstCharacter)
			{
				firstCharacter.SetMeshState(true);
				if (alliedToParty && !xmlName.Contains("Friend") && !xmlName.Contains("Acorn"))
				{
					xmlName.Contains("Sheep");
				}
				if (summonTime > 0f)
				{
					firstCharacter.stats.leaveTime = summonTime;
				}
				if (Records.x.InCombat(false))
				{
					Links.x.combat.AddParty(creatureActions.GetFirstCharacter(), false, null, true);
				}
				firstCharacter.jumpingPosition = false;
			}
			else
			{
				string text = "No first character summoned ";
				CreatureActions creatureActions2 = creatureActions;
				Debug.Log(text + ((creatureActions2 != null) ? creatureActions2.ToString() : null));
			}
			return creatureActions;
		}
		Debug.Log("no creature found for " + xmlName);
		return null;
	}

	// Token: 0x06000D6C RID: 3436 RVA: 0x00101835 File Offset: 0x000FFA35
	public void SaveOverworldMapInfo()
	{
	}

	// Token: 0x06000D6D RID: 3437 RVA: 0x00101837 File Offset: 0x000FFA37
	public void UpdateOverworldFow(List<float> buff)
	{
	}

	// Token: 0x06000D6E RID: 3438 RVA: 0x00101839 File Offset: 0x000FFA39
	public void LoadMapVariables()
	{
	}

	// Token: 0x06000D6F RID: 3439 RVA: 0x0010183B File Offset: 0x000FFA3B
	public void RandomVariables()
	{
	}

	// Token: 0x06000D70 RID: 3440 RVA: 0x00101840 File Offset: 0x000FFA40
	public void DestroyPartyObjects()
	{
		if (this.boroControls)
		{
			this.boroControls.Stop();
		}
		Links.x.inventory.ClearAllBags();
		this.party = Links.x.party;
		if (this.party != null)
		{
			for (int i = 0; i < this.party.Count; i++)
			{
				this.party[i].DestroyCharacter();
			}
			this.party.Clear();
		}
		List<Character> deads = Links.x.deads;
		for (int j = 0; j < deads.Count; j++)
		{
			deads[j].DestroyCharacter();
		}
		if (this.boat.sailing)
		{
			this.boat.ClearPartyBoat();
		}
		Links.x.portraitOrder.Clear();
		Links.x.hudControl.ClearOnReload();
		Links.x.journal.ClearNotes();
	}

	// Token: 0x06000D71 RID: 3441 RVA: 0x0010192B File Offset: 0x000FFB2B
	public string GetTestLocation(string txt)
	{
		return "";
	}

	// Token: 0x0400151D RID: 5405
	[Header("CREATING MAP")]
	private List<Character> party;

	// Token: 0x0400151E RID: 5406
	private GameObject go;

	// Token: 0x0400151F RID: 5407
	private Transform tr;

	// Token: 0x04001520 RID: 5408
	public bool sceneLoaded;

	// Token: 0x04001521 RID: 5409
	public bool pathfindingReady;

	// Token: 0x04001522 RID: 5410
	public bool newGame;

	// Token: 0x04001523 RID: 5411
	public bool newGameFromMenu;

	// Token: 0x04001524 RID: 5412
	public bool changingMapsComplete;

	// Token: 0x04001525 RID: 5413
	public bool noAstar;

	// Token: 0x04001526 RID: 5414
	public string sceneToLoad = "HamletAConsil";

	// Token: 0x04001527 RID: 5415
	public string currentSceneName;

	// Token: 0x04001528 RID: 5416
	public string mapDirection;

	// Token: 0x04001529 RID: 5417
	public string changeScene;

	// Token: 0x0400152A RID: 5418
	public string currentPlaylist;

	// Token: 0x0400152B RID: 5419
	public string currentSoundtrack;

	// Token: 0x0400152C RID: 5420
	public GameObject characterCreation;

	// Token: 0x0400152D RID: 5421
	public List<string> partyNames = new List<string>();

	// Token: 0x0400152E RID: 5422
	public List<int> partyIDs = new List<int>();

	// Token: 0x0400152F RID: 5423
	public Vector3 playerStartingPosition;

	// Token: 0x04001530 RID: 5424
	public GraphNode playerStartingNode;

	// Token: 0x04001531 RID: 5425
	public GridGraph interiorGraph;

	// Token: 0x04001532 RID: 5426
	public GridGraph exteriorGraph;

	// Token: 0x04001533 RID: 5427
	public Vector3 exitPoint;

	// Token: 0x04001534 RID: 5428
	private Character ccCharacter;

	// Token: 0x04001535 RID: 5429
	public bool changingScene;

	// Token: 0x04001536 RID: 5430
	public bool loadingCharacterCreation;

	// Token: 0x04001537 RID: 5431
	public bool settingUpParty;

	// Token: 0x04001538 RID: 5432
	public bool doCircle;

	// Token: 0x04001539 RID: 5433
	private IEnumerator loadCoroutine;

	// Token: 0x0400153A RID: 5434
	public bool newSceneFromMapExit;

	// Token: 0x0400153B RID: 5435
	public bool newSceneFromOverworldMap;

	// Token: 0x0400153C RID: 5436
	private ES3File saveFile;

	// Token: 0x0400153D RID: 5437
	public bool playingSoundtrackFromInWorld;

	// Token: 0x0400153E RID: 5438
	public GameSecondCounter gameSecondCounter;

	// Token: 0x0400153F RID: 5439
	[Header("SUMMONS")]
	private List<string> summons = new List<string>();

	// Token: 0x04001540 RID: 5440
	private List<int> summonHealth = new List<int>();

	// Token: 0x04001541 RID: 5441
	private List<Vector3> summonPosition = new List<Vector3>();

	// Token: 0x04001542 RID: 5442
	private List<float> summonsTime = new List<float>();

	// Token: 0x04001543 RID: 5443
	private List<string> summonsDetails = new List<string>();

	// Token: 0x04001544 RID: 5444
	private List<float> summonsPotency = new List<float>();

	// Token: 0x04001545 RID: 5445
	[Header("SCENE TRANSFER")]
	public List<Character> changingMaps = new List<Character>();

	// Token: 0x04001546 RID: 5446
	public List<float> changingMapsDistance = new List<float>();

	// Token: 0x04001547 RID: 5447
	private bool cameraFollow;

	// Token: 0x04001548 RID: 5448
	private string savedSceneFrom;

	// Token: 0x04001549 RID: 5449
	private string savedSubExit;

	// Token: 0x0400154A RID: 5450
	public bool waitingToRemoveScene;

	// Token: 0x0400154B RID: 5451
	private int sceneLoadedCount;

	// Token: 0x0400154C RID: 5452
	private string savedMapExitName;

	// Token: 0x0400154D RID: 5453
	private string saveMapExitSub;

	// Token: 0x0400154E RID: 5454
	[Header("BOAT")]
	public GameObject partyBoat;

	// Token: 0x0400154F RID: 5455
	public Boat boat;

	// Token: 0x04001550 RID: 5456
	public GameObject restingBoat;

	// Token: 0x04001551 RID: 5457
	public List<Transform> restingBoatPoints = new List<Transform>();

	// Token: 0x04001552 RID: 5458
	public Character boro;

	// Token: 0x04001553 RID: 5459
	public Boro boroControls;

	// Token: 0x04001554 RID: 5460
	private bool clearPreviousScene;

	// Token: 0x04001555 RID: 5461
	private bool cleared;

	// Token: 0x04001556 RID: 5462
	private bool addressablesLoading;

	// Token: 0x04001557 RID: 5463
	private bool loaded;

	// Token: 0x04001558 RID: 5464
	private bool unloaded;

	// Token: 0x04001559 RID: 5465
	public bool debugPlaylist;
}
