using System;
using System.Collections;
using System.Collections.Generic;
using Pathfinding;
using PixelCrushers.DialogueSystem;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;

// Token: 0x020000B2 RID: 178
public class InputControls : MonoBehaviour
{
	// Token: 0x0600107F RID: 4223 RVA: 0x0013B7AA File Offset: 0x001399AA
	private void Awake()
	{
		this.child.SetActive(false);
	}

	// Token: 0x06001080 RID: 4224 RVA: 0x0013B7B8 File Offset: 0x001399B8
	private void Start()
	{
		if (!Records.x.secrets && !Records.x.editor)
		{
			base.enabled = false;
			this.child.SetActive(false);
		}
		if (base.enabled)
		{
			this.Lists();
		}
		Links.x.gameplay.SetInteractableSelected(EventSystem.current, this.exitButton);
	}

	// Token: 0x06001081 RID: 4225 RVA: 0x0013B818 File Offset: 0x00139A18
	public void Lists()
	{
		string[] names = Enum.GetNames(typeof(MapExit.exitToNames));
		this.sceneDropdown.options.Clear();
		foreach (string text in names)
		{
			this.sceneDropdown.options.Add(new TMP_Dropdown.OptionData(text));
		}
		string[] names2 = Enum.GetNames(typeof(SceneItem.xmlNames));
		this.itemDropdown.options.Clear();
		foreach (string text2 in names2)
		{
			this.itemDropdown.options.Add(new TMP_Dropdown.OptionData(text2));
		}
		this.questDropdown.options.Clear();
		foreach (string text3 in QuestLog.GetAllQuests(QuestState.Unassigned, true, null))
		{
			this.questDropdown.options.Add(new TMP_Dropdown.OptionData(text3));
		}
		string[] names3 = Enum.GetNames(typeof(Creatures.AdventureStates));
		this.questStateDropdown.options.Clear();
		foreach (string text4 in names3)
		{
			this.questStateDropdown.options.Add(new TMP_Dropdown.OptionData(text4));
		}
	}

	// Token: 0x06001082 RID: 4226 RVA: 0x0013B944 File Offset: 0x00139B44
	public void NewScene()
	{
		if (base.enabled)
		{
			this.jumpPoints.Clear();
			this.pointsDropdown.options.Clear();
			if (Links.x.diorama.playerStartDefault)
			{
				this.jumpPoints.Add(Links.x.diorama.playerStartDefault);
				this.pointsDropdown.options.Add(new TMP_Dropdown.OptionData("Start"));
			}
			if (Links.x.diorama.playerStartBoatDefault)
			{
				this.jumpPoints.Add(Links.x.diorama.playerStartBoatDefault);
				this.pointsDropdown.options.Add(new TMP_Dropdown.OptionData("Start Boat"));
			}
			foreach (object obj in Links.x.diorama.gameObject.transform)
			{
				Transform transform = (Transform)obj;
				if (transform.gameObject.name.Contains("Jump"))
				{
					this.pointsDropdown.options.Add(new TMP_Dropdown.OptionData(transform.gameObject.name));
					this.jumpPoints.Add(transform);
				}
			}
		}
	}

	// Token: 0x06001083 RID: 4227 RVA: 0x0013BAA4 File Offset: 0x00139CA4
	public void ChangeToStun()
	{
		if (Records.x.kill)
		{
			Links.x.hudControl.ToggleLethality(false);
		}
	}

	// Token: 0x06001084 RID: 4228 RVA: 0x0013BAC2 File Offset: 0x00139CC2
	public void ChangeToKill()
	{
		if (!Records.x.kill)
		{
			Links.x.hudControl.ToggleLethality(false);
		}
	}

	// Token: 0x06001085 RID: 4229 RVA: 0x0013BAE0 File Offset: 0x00139CE0
	public void EndCombat()
	{
		this.ChangeToKill();
		Links.x.combat.EndCombatFromTestScreen();
	}

	// Token: 0x06001086 RID: 4230 RVA: 0x0013BAF7 File Offset: 0x00139CF7
	public void EndCombatStun()
	{
		this.ChangeToStun();
		Links.x.combat.EndCombatFromTestScreen();
	}

	// Token: 0x06001087 RID: 4231 RVA: 0x0013BB0E File Offset: 0x00139D0E
	public void AddOneHour()
	{
		if (!Records.x.paused)
		{
			Links.x.gameplay.TogglePause(true);
		}
		Links.x.gameplay.AddHours();
	}

	// Token: 0x06001088 RID: 4232 RVA: 0x0013BB3B File Offset: 0x00139D3B
	public void Close()
	{
		this.closeNext = true;
	}

	// Token: 0x06001089 RID: 4233 RVA: 0x0013BB44 File Offset: 0x00139D44
	private void Update()
	{
		if (Links.x.gaia.sceneLoaded && (!Records.x.typing || (Records.x.typing && this.child.activeSelf)))
		{
			if (Input.GetKeyDown(KeyCode.Alpha6) || this.closeNext)
			{
				if (this.child.activeSelf)
				{
					this.closeNext = false;
					this.child.SetActive(false);
					Records.x.SetTypingState(false);
					if (!this.startedPaused)
					{
						Links.x.gameplay.TogglePause(false);
					}
				}
				else
				{
					this.closeNext = false;
					this.startedPaused = Records.x.paused;
					this.child.SetActive(true);
					Records.x.SetTypingState(true);
					Links.x.gameplay.TogglePause(true);
				}
			}
			if (this.child.activeSelf)
			{
				Records.x.SetTypingState(true);
			}
		}
	}

	// Token: 0x0600108A RID: 4234 RVA: 0x0013BC3F File Offset: 0x00139E3F
	public void CheckJumpPoint()
	{
		base.StartCoroutine(this.Jump());
	}

	// Token: 0x0600108B RID: 4235 RVA: 0x0013BC4E File Offset: 0x00139E4E
	private IEnumerator Jump()
	{
		int value = this.pointsDropdown.value;
		Transform t = this.jumpPoints[value];
		if (t)
		{
			int desiredGraph = 0;
			if (t.gameObject.name.Contains("Inside"))
			{
				desiredGraph = 1;
			}
			if (t.gameObject.name.Contains("inside"))
			{
				desiredGraph = 1;
			}
			if (Links.x.diorama.underground)
			{
				desiredGraph = 1;
			}
			List<Character> party = Links.x.party;
			int num;
			for (int i = 0; i < party.Count; i = num + 1)
			{
				Character character = party[i];
				if (character && !character.isBoro)
				{
					GraphNode graphNode = character.NearNode(t.position, true, 0, desiredGraph, 0);
					if (graphNode != null)
					{
						Links.x.sensory.SetMagicaClothState(false);
						character.SetPosition((Vector3)graphNode.position, null);
						character.ClaimNode(graphNode, (Vector3)graphNode.position, true);
						character.sphere.transform.position = t.position;
						if (character.circleTr)
						{
							character.circleTr.position = character.tr.position;
						}
						character.SetMoveFollowPosition((Vector3)graphNode.position);
						character.indoorID = "";
						character.doorID = "";
						if (desiredGraph == 1)
						{
							if (Links.x.diorama.GetIndoorView())
							{
								character.indoorID = Links.x.diorama.GetIndoorView().GetInteriorBoundsName((Vector3)graphNode.position);
							}
							else
							{
								character.indoorID = "?";
							}
							character.doorID = "";
						}
						if (Records.x.circle)
						{
							Links.x.fellowship.BreakCircle(false);
						}
						character.ChangeTorchLight();
						character.TargetReached();
						if (character.mainSelected)
						{
							character.StopMoving();
							if (character.cc)
							{
								character.cc.enabled = false;
							}
						}
						character.FirstPosition(graphNode);
						if (character == Links.x.main)
						{
							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);
						}
						yield return new WaitForSecondsRealtime(0.01f);
						if (character.mainSelected && character.cc)
						{
							character.cc.enabled = true;
						}
						Links.x.sensory.SetMagicaClothState(true);
					}
					else
					{
						Links.x.gameFeed.AddFeed("Points not found");
					}
				}
				character = null;
				num = i;
			}
			party = null;
		}
		yield return new WaitForSecondsRealtime(1f);
		if (Records.x.combat)
		{
			Links.x.combat.EndCombat(false);
		}
		yield break;
	}

	// Token: 0x0600108C RID: 4236 RVA: 0x0013BC60 File Offset: 0x00139E60
	public void Rally()
	{
		Links.x.fellowship.rally = 15f;
		Links.x.fellowship.rallyBoost = 30f;
		Links.x.fellowship.rallyAttacks = 4f;
		Links.x.hudControl.SetRallyBars();
	}

	// Token: 0x0600108D RID: 4237 RVA: 0x0013BCB8 File Offset: 0x00139EB8
	public void LevelUp()
	{
		List<Character> portraitOrder = Links.x.portraitOrder;
		for (int i = 0; i < portraitOrder.Count; i++)
		{
			if (portraitOrder[i] && !portraitOrder[i].dead && !portraitOrder[i].summoned && !portraitOrder[i].isBoro)
			{
				int num = portraitOrder[i].stats.XPToNextLevel();
				portraitOrder[i].stats.AddXP(num, null, true);
			}
		}
	}

	// Token: 0x0600108E RID: 4238 RVA: 0x0013BD40 File Offset: 0x00139F40
	public void LevelUpStats()
	{
		List<Character> portraitOrder = Links.x.portraitOrder;
		for (int i = 0; i < portraitOrder.Count; i++)
		{
			if (portraitOrder[i] && !portraitOrder[i].dead && !portraitOrder[i].summoned && !portraitOrder[i].isBoro)
			{
				portraitOrder[i].stats.XPToNextLevel();
				portraitOrder[i].stats.LevelUpStats();
			}
		}
	}

	// Token: 0x0600108F RID: 4239 RVA: 0x0013BDC4 File Offset: 0x00139FC4
	public void CheckMapExit()
	{
		string text = this.sceneDropdown.options[this.sceneDropdown.value].text;
		Links.x.gaia.ChangeSceneFromOverworld(text, Links.x.diorama.sceneName);
	}

	// Token: 0x06001090 RID: 4240 RVA: 0x0013BE14 File Offset: 0x0013A014
	public void CheckEndItem(GameObject obj)
	{
		string text = obj.transform.parent.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text;
		if (text == "")
		{
			Links.x.gameFeed.AddFeed("Not found");
			return;
		}
		Library.Inventory invRowFromName = Links.x.library.GetInvRowFromName(text);
		if (invRowFromName != null)
		{
			Character main = Links.x.main;
			float num = 0f;
			if (invRowFromName._DurabilityMax > 0)
			{
				num = (float)invRowFromName._DurabilityMax;
			}
			if (invRowFromName._Stackable)
			{
				if (text == "Emeralds")
				{
					global::Item item;
					ItemEquipped itemEquipped;
					Links.x.inventory.AddFromGround(null, null, 0, false, 0f, invRowFromName._ID, 1000, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector4(0f, 0f, 0f, 0f), main, true, false, out item, out itemEquipped);
				}
				else
				{
					global::Item item2;
					ItemEquipped itemEquipped2;
					Links.x.inventory.AddFromGround(null, null, 0, false, 0f, invRowFromName._ID, invRowFromName._MaxStackSize, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector4(num, 0f, 0f, 0f), main, true, false, out item2, out itemEquipped2);
				}
			}
			else
			{
				global::Item item3;
				ItemEquipped itemEquipped3;
				Links.x.inventory.AddFromGround(null, null, 0, false, 0f, invRowFromName._ID, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector4(num, 0f, 0f, 0f), main, true, false, out item3, out itemEquipped3);
			}
			Links.x.gameFeed.AddFeed(invRowFromName._DisplayName + " added to bag");
			return;
		}
		Links.x.gameFeed.AddFeed("Not found");
	}

	// Token: 0x06001091 RID: 4241 RVA: 0x0013C029 File Offset: 0x0013A229
	public void SetQuestState()
	{
		string text = this.questDropdown.options[this.questDropdown.value].text;
	}

	// Token: 0x06001092 RID: 4242 RVA: 0x0013C04C File Offset: 0x0013A24C
	public void CheckEndQuest()
	{
		string text = this.questDropdown.options[this.questDropdown.value].text;
		string text2 = this.questStateDropdown.options[this.questStateDropdown.value].text;
		if (text != "None" && text2 != "NotApplicable")
		{
			QuestLog.SetQuestState(text, Records.x.StringToQuestState(text2));
			Links.x.gameFeed.AddFeed("Set quest state: " + text + " to " + text2);
			Links.x.diorama.CheckQuestActivations();
		}
	}

	// Token: 0x04001B6E RID: 7022
	public GameObject child;

	// Token: 0x04001B6F RID: 7023
	public TextMeshProUGUI questStatus;

	// Token: 0x04001B70 RID: 7024
	public TextMeshProUGUI variableStatus;

	// Token: 0x04001B71 RID: 7025
	private float originalTurnLength;

	// Token: 0x04001B72 RID: 7026
	public TMP_Dropdown sceneDropdown;

	// Token: 0x04001B73 RID: 7027
	public TMP_Dropdown itemDropdown;

	// Token: 0x04001B74 RID: 7028
	public TMP_Dropdown questDropdown;

	// Token: 0x04001B75 RID: 7029
	public TMP_Dropdown questStateDropdown;

	// Token: 0x04001B76 RID: 7030
	public TMP_Dropdown pointsDropdown;

	// Token: 0x04001B77 RID: 7031
	private bool startedPaused;

	// Token: 0x04001B78 RID: 7032
	private List<Transform> jumpPoints = new List<Transform>();

	// Token: 0x04001B79 RID: 7033
	private bool closeNext;

	// Token: 0x04001B7A RID: 7034
	public GameObject exitButton;
}
