using System;
using System.Collections;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
using Pathfinding;
using UnityEngine;

// Token: 0x0200001A RID: 26
public class BreakableActions : MonoBehaviour
{
	// Token: 0x060002D9 RID: 729 RVA: 0x000391FC File Offset: 0x000373FC
	private void Awake()
	{
		if (!this.fromSpell)
		{
			base.enabled = false;
		}
		base.gameObject.layer = 16;
		this.saveName = base.gameObject.name;
		this.mainCollider = base.gameObject.GetComponent<Collider>();
		if (!this.mainCollider && base.transform.childCount > 0)
		{
			foreach (object obj in base.transform)
			{
				Collider component = ((Transform)obj).gameObject.GetComponent<Collider>();
				if (component)
				{
					this.mainCollider = component;
				}
			}
		}
		this.pt = base.gameObject.transform.position;
	}

	// Token: 0x060002DA RID: 730 RVA: 0x000392D8 File Offset: 0x000374D8
	private void OnEnable()
	{
		this.pt = base.gameObject.transform.position;
		if (this.fromSpell)
		{
			this.destroyed = false;
			if (this.renderers.Length == 0)
			{
				this.GetObjects();
			}
			this.mainCollider.enabled = true;
			this.currentHealth = this.breakable.health;
			this.UpdateAstar();
		}
		if (this.particles.Length != 0)
		{
			ParticleSystem[] array = this.particles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].gameObject.SetActive(true);
			}
		}
		if (this.breakable)
		{
			if (this.breakable.component != Breakable.ComponentTypes.None)
			{
				for (int j = 0; j < this.renderers.Length; j++)
				{
					this.renderers[j].enabled = true;
				}
				this.mainCollider.enabled = true;
			}
			if (this.breakable.enemy)
			{
				this.aiShouldBreakIt = true;
			}
		}
	}

	// Token: 0x060002DB RID: 731 RVA: 0x000393C3 File Offset: 0x000375C3
	public void LoadGameSetup(int h)
	{
		this.currentHealth = h;
		if (h <= 0 && this.resourceLocation == 0)
		{
			this.ClickToBreak(null, true, false);
		}
	}

	// Token: 0x060002DC RID: 732 RVA: 0x000393E1 File Offset: 0x000375E1
	public void NewGameSetup()
	{
		if (this.breakable.armor > 0)
		{
			this.currentHealth = this.breakable.health;
			return;
		}
		this.currentHealth = 1;
	}

	// Token: 0x060002DD RID: 733 RVA: 0x0003940C File Offset: 0x0003760C
	public void SetLayers(int x)
	{
		if (x == 6)
		{
			if (this.layers == null)
			{
				this.layers = new List<int>();
				for (int i = 0; i < this.renderers.Length; i++)
				{
					if (this.renderers[i])
					{
						this.layers.Add(this.renderers[i].gameObject.layer);
						if (this.renderers[i].gameObject.layer != 29)
						{
							this.renderers[i].gameObject.layer = 6;
						}
					}
					else
					{
						this.layers.Add(0);
					}
				}
				return;
			}
		}
		else
		{
			for (int j = 0; j < this.renderers.Length; j++)
			{
				if (this.renderers[j])
				{
					this.renderers[j].gameObject.layer = this.layers[j];
				}
			}
		}
	}

	// Token: 0x060002DE RID: 734 RVA: 0x000394F0 File Offset: 0x000376F0
	public void Remove()
	{
		if (this.renderers.Length == 0)
		{
			this.GetObjects();
		}
		this.mainCollider.enabled = false;
		Links.x.hudControl.AddRemoveInteraction(false, null, this, null, null, null, null, null);
		base.enabled = true;
		if (this.interactiveCharacterObject)
		{
			Object.Destroy(this.interactiveCharacterObject);
		}
		base.StartCoroutine(this.UpdatePath(true));
	}

	// Token: 0x060002DF RID: 735 RVA: 0x0003955C File Offset: 0x0003775C
	public void GetNode()
	{
		if (!this.destroyed)
		{
			bool flag = this.fromSpell;
		}
	}

	// Token: 0x060002E0 RID: 736 RVA: 0x00039570 File Offset: 0x00037770
	public void GetObjects()
	{
		if (this.renderers.Length == 0)
		{
			this.renderers = base.gameObject.GetComponentsInChildren<Renderer>(false);
		}
		this.rigidbodies = base.gameObject.GetComponentsInChildren<Rigidbody>(true);
		if (base.gameObject.transform.childCount > 0)
		{
			this.normal = base.gameObject.transform.GetChild(0).gameObject;
			this.broken = base.gameObject.transform.GetChild(1).gameObject;
			if (this.broken && (this.broken.gameObject.layer == 29 || this.broken.gameObject.name.Contains("Block")) && base.gameObject.transform.childCount > 2)
			{
				this.broken = base.gameObject.transform.GetChild(2).gameObject;
			}
		}
		for (int i = 0; i < this.renderers.Length; i++)
		{
			if (this.renderers[i].gameObject.name.Contains("Blocker"))
			{
				this.renderers[i].gameObject.layer = 29;
			}
		}
		this.pt = base.gameObject.transform.position;
	}

	// Token: 0x060002E1 RID: 737 RVA: 0x000396BF File Offset: 0x000378BF
	public void GetDifferentRenderers(GameObject g)
	{
		this.renderers = g.GetComponentsInChildren<Renderer>(false);
	}

	// Token: 0x060002E2 RID: 738 RVA: 0x000396CE File Offset: 0x000378CE
	public void OutOfRange()
	{
		if (this.inRangeFX)
		{
			Links.x.cellar.ReturnPooledGameObject(33, this.inRangeFX);
			this.inRangeFX = null;
		}
	}

	// Token: 0x060002E3 RID: 739 RVA: 0x000396FC File Offset: 0x000378FC
	public void InRange()
	{
		if (!this.inRangeFX)
		{
			this.inRangeFX = Links.x.cellar.GetPooledGameObject(33);
			this.inRangeFX.transform.position = base.transform.position + new Vector3(0f, 1f, 0f);
			this.inRangeFX.SetActive(true);
		}
	}

	// Token: 0x060002E4 RID: 740 RVA: 0x00039770 File Offset: 0x00037970
	public void HoverIn(bool isMainHover)
	{
		if (this.renderers.Length == 0)
		{
			this.GetObjects();
		}
		if (!this.destroyed)
		{
			int num = 0;
			if (this.mainCollider)
			{
				this.bounds = this.mainCollider.bounds;
			}
			else
			{
				this.bounds = default(Bounds);
				if (this.renderers.Length != 0 && this.renderers[0])
				{
					this.bounds = this.renderers[0].bounds;
					if (this.renderers.Length > 1)
					{
						int i = 1;
						int num2 = this.renderers.Length;
						while (i < num2)
						{
							if (this.renderers[i] && this.renderers[i].gameObject.layer != 29)
							{
								this.bounds.Encapsulate(this.renderers[i].bounds);
							}
							i++;
						}
					}
				}
			}
			this.bounds.Expand(0.25f);
			if (Records.x.pocketPause)
			{
				num = 2;
			}
			if (!this.bracket)
			{
				this.bracket = Links.x.cellar.GetBracket(num, this.bounds);
			}
			else
			{
				Links.x.cellar.SetBracketMaterial(num, this.bracket);
			}
			if (isMainHover)
			{
				Links.x.hoverObject = base.gameObject;
				Shader.SetGlobalVector("_DoorLightPosition", this.bounds.center + Links.x.rtsCamera.gameObject.transform.forward * -2f);
				Records.x.hoverLightColor = Color.white * 0.25f;
				Shader.SetGlobalFloat("_DoorLightRange", 2f);
				if (Records.x.pocketPause && !Links.x.gameplay.attackingCharacter.CanAttack())
				{
					bool rallyWheelOpen = Links.x.pocketWheel.rallyWheelOpen;
				}
			}
		}
	}

	// Token: 0x060002E5 RID: 741 RVA: 0x00039964 File Offset: 0x00037B64
	public void HoverOut()
	{
		if (Links.x.hoverObject == base.gameObject)
		{
			Links.x.hoverObject = null;
		}
		if (this.multiHover)
		{
			Links.x.combat.MultiHitCharacters(false);
			Links.x.combat.MultiHitObjects(false, base.gameObject.transform.position, this, null, null);
			this.multiHover = false;
			Links.x.gameplay.CheckIfAnythingShouldRedoMultiTargetHover();
		}
		if (this.bracket)
		{
			Links.x.cellar.ReturnPooledGameObject(61, this.bracket);
			this.bracket = null;
		}
	}

	// Token: 0x060002E6 RID: 742 RVA: 0x00039A10 File Offset: 0x00037C10
	public void CombatSheen(int num)
	{
		if (this.renderers.Length == 0)
		{
			this.GetObjects();
		}
		if (this.destroyed && num == 3)
		{
			return;
		}
		bool flag = false;
		if (num == 3)
		{
			flag = true;
		}
		this.combatTargetID = num;
		for (int i = 0; i < this.renderers.Length; i++)
		{
			if (this.renderers[i].gameObject.layer != 29)
			{
				this.mats = this.renderers[i].materials;
				foreach (Material material in this.mats)
				{
					this.sheen = 0f;
					if (flag)
					{
						this.sheen = 1f;
					}
					material.SetFloat("_InCombatBubble", this.sheen);
				}
			}
		}
	}

	// Token: 0x060002E7 RID: 743 RVA: 0x00039AC8 File Offset: 0x00037CC8
	public void Damage(Character party)
	{
		GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(60);
		pooledGameObject.transform.position = base.gameObject.transform.position + new Vector3(0f, 1f, 0f);
		pooledGameObject.SetActive(true);
	}

	// Token: 0x060002E8 RID: 744 RVA: 0x00039B20 File Offset: 0x00037D20
	public void Bend()
	{
		if (this.currentHealth < this.breakable.health && !this.destroyed && this.currentHealth > 0)
		{
			if (this.timeSinceHeal == 0f)
			{
				this.timeSinceHeal = Links.x.gameplay.seconds;
			}
			if (Links.x.gameplay.seconds > this.timeSinceHeal + 100f || this.timeSinceHeal == 0f)
			{
				this.timeSinceHeal = Links.x.gameplay.seconds;
				float num = (float)this.breakable.health / 5f;
				this.currentHealth += Mathf.RoundToInt(num);
				Vector3 position = this.mainCollider.gameObject.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.repairFX.localPosition = vector;
				Links.x.repairFX.gameObject.SetActive(true);
				Links.x.repairFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
				string text = "Repair 1";
				if (Random.Range(0, 2) == 0)
				{
					text = "Repair 2";
				}
				if (Random.Range(0, 3) == 0)
				{
					text = "Repair 3";
				}
				MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, Random.Range(0.7f, 0.9f), new float?(1f), 0f, text, null);
				if (this.currentHealth == this.breakable.health)
				{
					this.timeSinceHeal = 0f;
				}
			}
		}
	}

	// Token: 0x060002E9 RID: 745 RVA: 0x00039D44 File Offset: 0x00037F44
	public void ClickToBreak(Character party, bool fromSave, bool fromKick)
	{
		this.kicked = fromKick;
		if (!this.destroyed)
		{
			this.destroyed = true;
			if (base.gameObject.activeSelf)
			{
				base.StartCoroutine(this.Breaking(party, fromSave, this.kicked));
			}
			if (!fromSave && this.breakable.puzzle)
			{
				this.breakable.puzzle.gameObject.GetComponent<PuzzleActions>().BreakablePuzzle(false);
			}
		}
	}

	// Token: 0x060002EA RID: 746 RVA: 0x00039DB9 File Offset: 0x00037FB9
	private IEnumerator Breaking(Character party, bool fromSave, bool fromKick)
	{
		if (this.renderers.Length == 0)
		{
			this.GetObjects();
		}
		if (!fromSave)
		{
			while (Links.x.combat.rallyTarget)
			{
				yield return null;
			}
		}
		if (!fromSave && party)
		{
			this.OutOfRange();
			if (this.breakable.armor == 0 && !Records.x.pocketPause && fromKick)
			{
				while (party.moving)
				{
					yield return null;
				}
				party.TargetReached();
				party.alwaysTurn = true;
				party.SetRotation(Quaternion.LookRotation(base.gameObject.transform.position - party.tr.position), false, true);
				if (this.resourceLocation == -1)
				{
					party.EndTurning(false);
					party.PlayAnimation("Kick", 0f);
					Links.x.sensory.LookAtObject(base.transform, 15f, false, party, 4f, 0.5f, null, 0);
				}
				else
				{
					party.EndTurning(false);
					party.PlayAnimation("Use", 0f);
				}
			}
		}
		if (!fromSave)
		{
			this.HoverOut();
		}
		bool canBreak = true;
		if (!fromSave && party && !canBreak)
		{
			this.destroyed = false;
		}
		if (!fromSave && this.breakable.armor == 0 && !Records.x.pocketPause && fromKick)
		{
			yield return new WaitForSeconds(0.25f);
			party.inAction = false;
		}
		if (!fromSave)
		{
			Links.x.sensory.AddNoise(party.gameObject, party.node, "Break", party);
		}
		if (canBreak)
		{
			if (this.normal)
			{
				this.normal.gameObject.SetActive(false);
			}
			if (!fromSave)
			{
				if (this.broken)
				{
					this.broken.gameObject.SetActive(true);
				}
				if (this.resourceLocation >= 0)
				{
					Links.x.diorama.ReturnResource(this.resourceLocation, base.gameObject);
					if (this.breakable.component == Breakable.ComponentTypes.Acorn || this.breakable.component == Breakable.ComponentTypes.Berry || this.breakable.component == Breakable.ComponentTypes.Frog || this.breakable.component == Breakable.ComponentTypes.Mushroom || this.breakable.component == Breakable.ComponentTypes.Rock)
					{
						this.itemA = this.breakable.itemA.ToString();
						if (this.itemA != "" && this.itemA != "None")
						{
							Library.Inventory invRowFromName = Links.x.library.GetInvRowFromName(this.itemA);
							if (invRowFromName != null)
							{
								Item item;
								ItemEquipped itemEquipped;
								Links.x.inventory.AddFromGround(null, null, 0, false, 0f, invRowFromName._ID, 1, Vector3.zero, Vector3.zero, new Vector4((float)invRowFromName._DurabilityMax, 0f, 0f, 0f), party, true, false, out item, out itemEquipped);
							}
							if (this.breakable.component == Breakable.ComponentTypes.Frog)
							{
								party.StartQuip("Got it!");
							}
						}
					}
					if (this.breakable.component == Breakable.ComponentTypes.Stick || this.breakable.component == Breakable.ComponentTypes.HollowStick)
					{
						this.itemA = this.breakable.itemA.ToString();
						if (this.itemA != "" && this.itemA != "None")
						{
							Library.Inventory invRowFromName2 = Links.x.library.GetInvRowFromName(this.itemA);
							if (invRowFromName2 != null && invRowFromName2 != null)
							{
								Item item2;
								ItemEquipped itemEquipped2;
								Links.x.inventory.AddFromGround(null, null, 0, false, 0f, invRowFromName2._ID, 1, Vector3.zero, Vector3.zero, new Vector4((float)invRowFromName2._DurabilityMax, 0f, 0f, 0f), party, true, false, out item2, out itemEquipped2);
							}
							if (this.breakable.component == Breakable.ComponentTypes.Stick)
							{
								GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(60);
								pooledGameObject.transform.position = base.gameObject.transform.position;
								pooledGameObject.SetActive(true);
							}
						}
					}
					Links.x.itemPickupFX.gameObject.SetActive(true);
					Links.x.itemPickupFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
					Vector3 position = base.gameObject.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.itemPickupFX.localPosition = vector;
					MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, 0.5f, new float?(1f), 0f, "Collect Resource", null);
					if (this.breakable.component == Breakable.ComponentTypes.Frog)
					{
						HannahAnimatorSimple component = base.gameObject.GetComponent<HannahAnimatorSimple>();
						if (component)
						{
							component.enabled = true;
						}
					}
					if (this.particles.Length != 0)
					{
						ParticleSystem[] array = this.particles;
						for (int i = 0; i < array.Length; i++)
						{
							array[i].gameObject.SetActive(false);
						}
					}
					for (int j = 0; j < this.renderers.Length; j++)
					{
						this.renderers[j].enabled = false;
					}
				}
				else
				{
					for (int k = 0; k < this.rigidbodies.Length; k++)
					{
						this.rigidbodies[k].gameObject.layer = 20;
						Transform transform = this.rigidbodies[k].gameObject.transform;
						if (!this.rigidbodies[k].gameObject.GetComponent<BoxCollider>())
						{
							this.rigidbodies[k].gameObject.AddComponent<BoxCollider>();
						}
						foreach (object obj in transform)
						{
							((Transform)obj).gameObject.layer = 20;
						}
						if (!fromSave && party)
						{
							Quaternion quaternion = Quaternion.LookRotation(base.gameObject.transform.position - party.body.headBone.position);
							this.rigidbodies[k].AddForce(quaternion * Vector3.forward * 3000f, ForceMode.Force);
						}
						else
						{
							Vector3 position2 = base.gameObject.transform.position;
							Quaternion quaternion2 = Quaternion.LookRotation(position2 - new Vector3(position2.x + Random.Range(-1f, 1f), position2.y + 2f, position2.z + Random.Range(-1f, 1f)));
							this.rigidbodies[k].AddForce(quaternion2 * Vector3.forward * 300f, ForceMode.Force);
						}
					}
					MasterAudio.PlaySound3DAtVector3AndForget("Interactives", Links.x.main.tr.position, 1f, new float?(1f), 0f, "Chest Break", null);
					Breakable.BarrelLiquidTypes barrelLiquid = this.breakable.barrelLiquid;
					if (this.breakable.itemA != SceneItem.xmlNames.None)
					{
						this.itemA = this.breakable.itemA.ToString();
					}
					if (this.breakable.itemB != SceneItem.xmlNames.None)
					{
						this.itemB = this.breakable.itemB.ToString();
					}
					if (this.breakable.itemC != SceneItem.xmlNames.None)
					{
						this.itemC = this.breakable.itemC.ToString();
					}
					if (this.breakable.itemD != SceneItem.xmlNames.None)
					{
						this.itemD = this.breakable.itemD.ToString();
					}
					int num = -1;
					if (this.node != null)
					{
						num = (int)this.node.Area;
					}
					if (this.itemA != "" && this.itemA != "None")
					{
						Library.Inventory inventory = Links.x.library.GetInvRowFromName(this.itemA);
						if (inventory != null)
						{
							Item item3 = Links.x.inventory.groundBag.DropLoot(inventory._ID, this.breakable.itemStackA, Vector3.zero, Vector3.zero, new Vector4((float)inventory._DurabilityMax, 0f, 0f, 0f), null, base.gameObject.transform.position, false, false, num);
							Links.x.diorama.AddItem(item3);
						}
					}
					if (this.itemB != "" && this.itemB != "None")
					{
						Library.Inventory inventory = Links.x.library.GetInvRowFromName(this.itemB);
						if (inventory != null)
						{
							Item item4 = Links.x.inventory.groundBag.DropLoot(inventory._ID, this.breakable.itemStackB, Vector3.zero, Vector3.zero, new Vector4((float)inventory._DurabilityMax, 0f, 0f, 0f), null, base.gameObject.transform.position, false, false, num);
							Links.x.diorama.AddItem(item4);
						}
					}
					if (this.itemC != "" && this.itemC != "None")
					{
						Library.Inventory inventory = Links.x.library.GetInvRowFromName(this.itemC);
						if (inventory != null)
						{
							Item item5 = Links.x.inventory.groundBag.DropLoot(inventory._ID, this.breakable.itemStackC, Vector3.zero, Vector3.zero, new Vector4((float)inventory._DurabilityMax, 0f, 0f, 0f), null, base.gameObject.transform.position, false, false, num);
							Links.x.diorama.AddItem(item5);
						}
					}
					if (this.itemD != "" && this.itemD != "None")
					{
						Library.Inventory inventory = Links.x.library.GetInvRowFromName(this.itemD);
						if (inventory != null)
						{
							Item item6 = Links.x.inventory.groundBag.DropLoot(inventory._ID, this.breakable.itemStackD, Vector3.zero, Vector3.zero, new Vector4((float)inventory._DurabilityMax, 0f, 0f, 0f), null, base.gameObject.transform.position, false, false, num);
							Links.x.diorama.AddItem(item6);
						}
					}
					if (this.breakable.barrelLiquid == Breakable.BarrelLiquidTypes.lizard)
					{
						Vector3 position3 = base.transform.position;
						string text = "SmallLizards";
						Quaternion quaternion3 = Quaternion.LookRotation(Links.x.main.tr.position - base.transform.position);
						bool flag = false;
						Character firstCharacter = Links.x.gaia.CreateCreature(position3, quaternion3, text, flag, 0f, 1).GetFirstCharacter();
						firstCharacter.SetPosition(position3, null);
						firstCharacter.SetRotation(quaternion3, false, false);
						firstCharacter.hostility = 2;
						firstCharacter.UpdateLKP(Links.x.main, Links.x.main.node, "Attack", true);
						firstCharacter.jumpingPosition = false;
						if (!Records.x.InCombat(false))
						{
							Links.x.combat.StartCombat(Links.x.main, firstCharacter, false, true);
						}
						Links.x.combat.AddParty(firstCharacter, false, null, true);
					}
					else if (this.breakable.barrelLiquid != Breakable.BarrelLiquidTypes.none)
					{
						string text2 = this.breakable.barrelLiquid.ToString();
						if (text2 == "none")
						{
							text2 = "Wine";
						}
						base.StartCoroutine(this.FindNodes(text2, base.transform.position, party));
					}
					if (Records.x.pocketPause && party.mainSelected)
					{
						Links.x.gameplay.PocketPause(false);
					}
				}
			}
			this.currentHealth = 0;
			Links.x.hudControl.AddRemoveInteraction(false, null, this, null, null, null, null, null);
			Links.x.combat.AddRemoveInteraction(false, this, null, null, null);
			if (this.mainCollider)
			{
				this.mainCollider.enabled = false;
			}
			if (this.resourceLocation == -1 || this.fromSpell)
			{
				this.UpdateAstar();
			}
		}
		yield break;
	}

	// Token: 0x060002EB RID: 747 RVA: 0x00039DDD File Offset: 0x00037FDD
	public void UpdateAstar()
	{
		if (!this.updatingPath || this.fromSpell)
		{
			this.updatingPath = true;
			base.enabled = true;
			base.StartCoroutine(this.UpdatePath(false));
		}
	}

	// Token: 0x060002EC RID: 748 RVA: 0x00039E0B File Offset: 0x0003800B
	private IEnumerator UpdatePath(bool destroying)
	{
		Vector3 vector = this.currTile;
		yield return new WaitForSecondsRealtime(0.1f);
		this.currTile = base.gameObject.transform.position;
		while (!Links.x.gaia.pathfindingReady)
		{
			yield return null;
		}
		if (!Links.x.gaia.sceneLoaded)
		{
			yield return new WaitForSecondsRealtime(Random.Range(0.2f, 0.5f));
		}
		AstarPath.active.UpdateGraphs(new Bounds(this.currTile + new Vector3(0f, -1f, 0f), new Vector3(4f, 40f, 4f)));
		this.updatingPath = false;
		if (this.fromSpell && this.destroyed)
		{
			if (this.tileEffect)
			{
				this.tileEffect.RemoveTile(this.node, base.gameObject, this);
			}
		}
		else
		{
			bool flag = this.fromSpell && destroying;
		}
		if (!this.fromSpell)
		{
			base.enabled = false;
		}
		if (Links.x.fogOfWar)
		{
			Links.x.fogOfWar.UpdateGrid(this.currTile, 6f);
		}
		if (Links.x.fogOfWarInterior)
		{
			Links.x.fogOfWarInterior.UpdateGrid(this.currTile, 6f);
		}
		yield break;
	}

	// Token: 0x060002ED RID: 749 RVA: 0x00039E21 File Offset: 0x00038021
	private IEnumerator FindNodes(string abilityName, Vector3 startPosition, Character party)
	{
		if (abilityName == "oil")
		{
			abilityName = "Oil";
		}
		if (abilityName == "sap")
		{
			abilityName = "Sap";
		}
		if (abilityName == "wine")
		{
			abilityName = "Wine";
		}
		if (abilityName == "spores")
		{
			abilityName = "Spores";
		}
		Library.Effects effectRow = Links.x.library.GetEffectRow(abilityName);
		this.pickedGroundNodes.Clear();
		this.SetNodeConstraint(false, 0);
		GraphNode targetNode = AstarPath.active.GetNearest(startPosition, this.nodeConstraint).node;
		float num = (float)effectRow._TileRadius;
		float max = (num * Records.x.nodeSize + 0.1f) * (num * Records.x.nodeSize + 0.1f);
		if (Links.x.gaia.pathfindingReady)
		{
			ConstantPath constPath = null;
			constPath = ConstantPath.ConstructFast(targetNode, Records.x.GetConstantPathRadius((int)num), null);
			constPath.nnConstraint = this.nodeConstraint;
			AstarPath.StartPath(constPath, false);
			yield return base.StartCoroutine(constPath.WaitForPath());
			int num2 = 0;
			constPath.Claim(this);
			this.allNodes = constPath.allNodes;
			int count = this.allNodes.Count;
			int num3 = 0;
			for (int i = 0; i < count; i++)
			{
				if (((Vector3)this.allNodes[i].position - (Vector3)targetNode.position).sqrMagnitude < max)
				{
					this.pickedGroundNodes.Add(this.allNodes[i]);
					num3++;
					num2++;
				}
			}
			constPath.Release(this, false);
			int num4 = this.pickedGroundNodes.IndexOf(targetNode);
			if (num4 > -1)
			{
				this.pickedGroundNodes.RemoveAt(num4);
			}
			this.pickedGroundNodes.Add(targetNode);
			num2++;
			if (this.pickedGroundNodes.Count > 0)
			{
				TileEffects tileEffects = Links.x.tileEffects.AddComponent<TileEffects>();
				tileEffects.gameObject.SetActive(true);
				tileEffects.Setup(null, effectRow, null, this, null, party);
			}
			this.pickedGroundNodes.Clear();
			constPath = null;
		}
		yield break;
	}

	// Token: 0x060002EE RID: 750 RVA: 0x00039E48 File Offset: 0x00038048
	public void SetNodeConstraint(bool constrainTags, int uniqueID)
	{
		this.nodeConstraint.constrainWalkability = true;
		this.nodeConstraint.walkable = true;
		this.nodeConstraint.constrainTags = constrainTags;
		this.nodeConstraint.checkCircleID = 0;
		this.nodeConstraint.passID = 0;
		this.nodeConstraint.passID2 = 0;
		this.nodeConstraint.checkConnections = 0;
		this.nodeConstraint.constrainPenalty = 0;
		this.nodeConstraint.constrainToArea = -1;
	}

	// Token: 0x040004FF RID: 1279
	public Breakable breakable;

	// Token: 0x04000500 RID: 1280
	public bool aiShouldBreakIt;

	// Token: 0x04000501 RID: 1281
	public string saveName;

	// Token: 0x04000502 RID: 1282
	public int currentHealth;

	// Token: 0x04000503 RID: 1283
	private string itemA;

	// Token: 0x04000504 RID: 1284
	private string itemB;

	// Token: 0x04000505 RID: 1285
	private string itemC;

	// Token: 0x04000506 RID: 1286
	private string itemD;

	// Token: 0x04000507 RID: 1287
	public Renderer[] renderers = new Renderer[0];

	// Token: 0x04000508 RID: 1288
	public ParticleSystem[] particles = new ParticleSystem[0];

	// Token: 0x04000509 RID: 1289
	public GameObject normal;

	// Token: 0x0400050A RID: 1290
	public GameObject broken;

	// Token: 0x0400050B RID: 1291
	public Rigidbody[] rigidbodies = new Rigidbody[0];

	// Token: 0x0400050C RID: 1292
	public bool destroyed;

	// Token: 0x0400050D RID: 1293
	private bool updatingPath;

	// Token: 0x0400050E RID: 1294
	private Vector3 prevTile;

	// Token: 0x0400050F RID: 1295
	private Vector3 currTile;

	// Token: 0x04000510 RID: 1296
	public Collider mainCollider;

	// Token: 0x04000511 RID: 1297
	public GraphNode node;

	// Token: 0x04000512 RID: 1298
	public List<GraphNode> pickedGroundNodes = new List<GraphNode>();

	// Token: 0x04000513 RID: 1299
	private NNConstraint nodeConstraint = new NNConstraint();

	// Token: 0x04000514 RID: 1300
	private List<GraphNode> allNodes;

	// Token: 0x04000515 RID: 1301
	public bool fromSpell;

	// Token: 0x04000516 RID: 1302
	public TileEffects tileEffect;

	// Token: 0x04000517 RID: 1303
	public int effectID;

	// Token: 0x04000518 RID: 1304
	public int resourceLocation = -1;

	// Token: 0x04000519 RID: 1305
	public Character interactiveCharacterObject;

	// Token: 0x0400051A RID: 1306
	private GameObject inRangeFX;

	// Token: 0x0400051B RID: 1307
	private Material[] mats;

	// Token: 0x0400051C RID: 1308
	public Character caster;

	// Token: 0x0400051D RID: 1309
	public GameObject bracket;

	// Token: 0x0400051E RID: 1310
	private Bounds bounds;

	// Token: 0x0400051F RID: 1311
	private List<int> layers;

	// Token: 0x04000520 RID: 1312
	private bool multiHover;

	// Token: 0x04000521 RID: 1313
	public int combatTargetID;

	// Token: 0x04000522 RID: 1314
	public bool kicked;

	// Token: 0x04000523 RID: 1315
	public Vector3 pt;

	// Token: 0x04000524 RID: 1316
	public float sheen;

	// Token: 0x04000525 RID: 1317
	private float timeSinceHeal;
}
