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

// Token: 0x02000054 RID: 84
public class TileEffects : MonoBehaviour
{
	// Token: 0x06000AD2 RID: 2770 RVA: 0x000D772F File Offset: 0x000D592F
	private void Start()
	{
	}

	// Token: 0x06000AD3 RID: 2771 RVA: 0x000D7731 File Offset: 0x000D5931
	public void Setup(Library.Abilities abilityToUse, Library.Effects effectToUse, Actions actions, BreakableActions breakable, ChestActions chest, Character sourceCharacter)
	{
		base.enabled = true;
		base.StartCoroutine(this.SetupTimed(abilityToUse, effectToUse, actions, breakable, chest, sourceCharacter));
	}

	// Token: 0x06000AD4 RID: 2772 RVA: 0x000D7750 File Offset: 0x000D5950
	private IEnumerator SetupTimed(Library.Abilities abilityToUse, Library.Effects effectToUse, Actions actions, BreakableActions breakable, ChestActions chest, Character sourceCharacter)
	{
		this.tileRadius = Records.x.nodeSize / 2f;
		this.ability = abilityToUse;
		if (this.ability != null)
		{
			this.hasAbility = true;
		}
		else
		{
			this.hasAbility = false;
		}
		this.source = sourceCharacter;
		bool stop = false;
		if (effectToUse == null)
		{
			this.effect = Links.x.library.GetEffectRow(this.ability._Name);
		}
		else
		{
			this.effect = effectToUse;
		}
		this.isInstrument = false;
		this.summonAmount = 0;
		if (!this.doSpellScroll)
		{
			this.spellScroll = null;
		}
		this.influenceRadius = (float)this.effect._TileRadius;
		if (this.ability != null && (this.ability._IsSpell || this.fromEnchantedItem) && this.paganRow != null)
		{
			if (this.fromEnchantedItem)
			{
				this.influenceRadius = this.radius;
			}
			else
			{
				this.spellData = new Vector4(0f, 0f, 0f, 0f);
				if (!this.doSpellScroll)
				{
					this.spellData = this.source.stats.GetAbilityLevel(this.spellIndex);
				}
				else
				{
					this.spellData = Records.x.GetSpellScrollData(this.spellIndex);
				}
				for (int i = 0; i < 3; i++)
				{
					string text = "";
					float num = 0f;
					if (i == 0)
					{
						text = this.paganRow._Slider1;
						num = this.spellData.x;
					}
					if (i == 1)
					{
						text = this.paganRow._Slider2;
						num = this.spellData.y;
					}
					if (i == 2)
					{
						text = this.paganRow._Slider3;
						num = this.spellData.z;
					}
					if (text.Contains("Radius"))
					{
						this.influenceRadius = num;
					}
					if (text.Contains("Time"))
					{
						this.effectTileOverrideDuration = Records.x.RealSecondsToGameSeconds(num);
					}
					if (text.Contains("Summons") && this.paganRow._School == "Fauna")
					{
						this.influenceRadius = (float)this.effect._TileRadius;
						this.summonAmount = (int)num;
						if (this.paganRow._ID.Contains("Frog"))
						{
							this.summonAmount *= 2;
						}
						else
						{
							this.summonAmount *= 3;
						}
					}
				}
			}
		}
		if (this.hasAbility)
		{
			if (this.ability._AINotes.Contains("Summons"))
			{
				this.summonAmount = 1;
				this.isSummons = true;
				if (this.ability._IsSpell)
				{
					if (this.fromEnchantedItem)
					{
						this.summonAmount = this.targetCount;
					}
					else
					{
						this.spellData = new Vector4(0f, 0f, 0f, 0f);
						if (!this.doSpellScroll)
						{
							this.spellData = this.source.stats.GetAbilityLevel(this.spellIndex);
						}
						else
						{
							this.spellData = Records.x.GetSpellScrollData(this.spellIndex);
						}
						for (int j = 0; j < 3; j++)
						{
							string text2 = "";
							float num2 = 0f;
							if (j == 0)
							{
								text2 = this.paganRow._Slider1;
								num2 = this.spellData.x;
							}
							if (j == 1)
							{
								text2 = this.paganRow._Slider2;
								num2 = this.spellData.y;
							}
							if (j == 2)
							{
								text2 = this.paganRow._Slider3;
								num2 = this.spellData.z;
							}
							if (text2.Contains("Summons"))
							{
								float num3 = Mathf.Round(num2);
								this.summonAmount = (int)num3;
							}
						}
					}
				}
				else
				{
					this.summonAmount = 1;
					if (this.ability._Name.Contains("Spawn"))
					{
						this.summonAmount = 2;
					}
				}
				this.influenceRadius = (float)this.summonAmount;
			}
			if (this.ability._IsSpell)
			{
				this.spellData = new Vector4(0f, 0f, 0f, 0f);
				if (!this.doSpellScroll)
				{
					this.spellData = this.source.stats.GetAbilityLevel(this.spellIndex);
				}
				else
				{
					this.spellData = Records.x.GetSpellScrollData(this.spellIndex);
				}
				for (int k = 0; k < 3; k++)
				{
					string text3 = "";
					float num4 = 0f;
					if (k == 0)
					{
						text3 = this.paganRow._Slider1;
						num4 = this.spellData.x;
					}
					if (k == 1)
					{
						text3 = this.paganRow._Slider2;
						num4 = this.spellData.y;
					}
					if (k == 2)
					{
						text3 = this.paganRow._Slider3;
						num4 = this.spellData.z;
					}
					if (text3.Contains("Damage") || text3.Contains("Deterioration") || text3.Contains("Effects") || text3.Contains("Power") || text3.Contains("Healing") || text3.Contains("Skill"))
					{
						this.sourceLevel = num4;
					}
					if (text3.Contains("Durability"))
					{
						this.sourceDurability = num4;
					}
				}
				if (this.ability._RadiusCenter.Contains("Target") || this.ability._RadiusCenter.Contains("Self"))
				{
					this.isSingleTarget = true;
				}
				if (this.effect._TileRadius > 1)
				{
					this.isSingleTarget = false;
				}
				if (this.ability._Name.Contains("CorpseNest") && this.singleTarget)
				{
					this.singleTarget.AddEffect(68, "");
					while (!this.SingleTargetDone())
					{
						this.waitingForTargetDeath = true;
						if (this.singleTarget)
						{
							this.startNode = this.singleTarget.node;
						}
						yield return null;
					}
					if (this.singleTarget)
					{
						this.singleTarget.RemoveEffect(68, "", true);
						if (this.singleTarget.stunned)
						{
							stop = true;
						}
					}
					this.singleTarget = null;
					this.waitingForTargetDeath = false;
				}
				if (this.source && this.source.stats.hasCustomAI && (this.ability._Name == "MushroomWall" || this.ability._Name == "FishPoisonBeam" || this.ability._Name == "BoneSpikes"))
				{
					this.customTileAI = true;
				}
			}
		}
		if (breakable)
		{
			this.pickedGroundNodesSaved = breakable.pickedGroundNodes;
		}
		else if (chest)
		{
			this.pickedGroundNodesSaved = chest.pickedGroundNodes;
		}
		else if (this.ghostBrush)
		{
			this.pickedGroundNodesSaved = this.ghostBrush.pickedGroundNodes;
		}
		else if (this.fromGroup)
		{
			this.pickedGroundNodesSaved = this.group.circleTiles;
			if (this.effect._Name == "Acid")
			{
				this.isPoison = true;
			}
		}
		else if (this.customTileAI)
		{
			this.pickedGroundNodesSaved = new List<GraphNode>();
			Character c = this.spellTarget;
			if (!c)
			{
				c = Links.x.main;
				this.spellTarget = Links.x.main;
			}
			if (c.node != null && Links.x.gaia.pathfindingReady)
			{
				Vector3 vector = (Vector3)this.source.node.position;
				Vector3 cNode = (Vector3)c.node.position;
				cNode.y = vector.y;
				if (this.ability._Name == "FishPoisonBeam")
				{
					float num5 = 6f;
					this.influenceRadius = 6f;
					float max = (num5 * Records.x.nodeSize + 0.1f) * (num5 * Records.x.nodeSize + 0.1f);
					ConstantPath constPath = ConstantPath.ConstructFast(this.source.node, Records.x.GetConstantPathRadius((int)num5), null);
					constPath.nnConstraint = new NNConstraint
					{
						constrainWalkability = false,
						constrainToEnvironment = -1,
						constrainTags = false,
						checkCircleID = 0
					};
					AstarPath.StartPath(constPath, false);
					yield return base.StartCoroutine(constPath.WaitForPath());
					constPath.Claim(this);
					this.allNodes = constPath.allNodes;
					int count = this.allNodes.Count;
					vector = this.source.currentPosition;
					Vector3 vector2 = Quaternion.LookRotation((Vector3)this.startNode.position - vector) * Vector3.forward;
					Vector3 vector3 = vector;
					for (int l = 0; l < count; l++)
					{
						Vector3 vector4 = (Vector3)this.allNodes[l].position;
						vector3.y = vector4.y;
						if ((vector4 - vector3).sqrMagnitude < max)
						{
							float num6 = Vector3.Angle(vector4 - vector3, vector2);
							float num7 = 20f;
							if (num6 <= num7 && num6 >= num7 * -1f)
							{
								this.pickedGroundNodesSaved.Add(this.allNodes[l]);
							}
						}
					}
					constPath.Release(this, false);
					constPath = null;
				}
				if (this.ability._Name == "BoneSpikes")
				{
					float num8 = 10f;
					this.influenceRadius = 10f;
					float max = (num8 * Records.x.nodeSize + 0.1f) * (num8 * Records.x.nodeSize + 0.1f);
					ConstantPath constPath = ConstantPath.ConstructFast(this.source.node, Records.x.GetConstantPathRadius((int)num8), null);
					constPath.nnConstraint = new NNConstraint
					{
						constrainWalkability = false,
						constrainToEnvironment = -1,
						constrainTags = false,
						checkCircleID = 0
					};
					AstarPath.StartPath(constPath, false);
					yield return base.StartCoroutine(constPath.WaitForPath());
					constPath.Claim(this);
					this.allNodes = constPath.allNodes;
					int count2 = this.allNodes.Count;
					vector = this.source.currentPosition;
					Vector3 vector5 = Quaternion.LookRotation((Vector3)this.startNode.position - vector) * Vector3.forward;
					Vector3 vector6 = vector;
					for (int m = 0; m < count2; m++)
					{
						Vector3 vector7 = (Vector3)this.allNodes[m].position;
						vector6.y = vector7.y;
						if ((vector7 - vector6).sqrMagnitude < max)
						{
							float num9 = Vector3.Angle(vector7 - vector6, vector5);
							float num10 = 15f;
							if (num9 <= num10 && num9 >= num10 * -1f)
							{
								this.pickedGroundNodesSaved.Add(this.allNodes[m]);
							}
						}
					}
					constPath.Release(this, false);
					this.pickedGroundNodesSaved.Sort((GraphNode a, GraphNode b) => Vector3.Distance(this.source.currentPosition, (Vector3)a.position).CompareTo(Vector3.Distance(this.source.currentPosition, (Vector3)b.position)));
					constPath = null;
				}
				if (this.ability._Name == "MushroomWall" && (vector - cNode).sqrMagnitude < 25f)
				{
					for (int n = 0; n < 8; n++)
					{
						GraphNode graphNode = c.node.ConnectionFromIndex(n);
						if (graphNode != null && graphNode != this.source.node)
						{
							this.pickedGroundNodesSaved.Add(graphNode);
							if (graphNode.ID != 0 && graphNode.ID != c.nodeStationaryID && graphNode.ID != c.nodeMovingID)
							{
								Character nodeCharacter = c.GetNodeCharacter(graphNode.ID);
								if (nodeCharacter)
								{
									nodeCharacter.Knockback(this.source.currentPosition, 1, false, false, false);
								}
							}
						}
					}
					for (int num11 = 0; num11 < 8; num11++)
					{
						GraphNode graphNode2 = this.source.node.ConnectionFromIndex(num11);
						if (graphNode2 != null && graphNode2 != c.node && !this.pickedGroundNodesSaved.Contains(graphNode2))
						{
							this.pickedGroundNodesSaved.Add(graphNode2);
							if (graphNode2.ID != 0 && graphNode2.ID != this.source.nodeStationaryID && graphNode2.ID != this.source.nodeMovingID)
							{
								Character nodeCharacter2 = this.source.GetNodeCharacter(graphNode2.ID);
								if (nodeCharacter2 && nodeCharacter2 != c && nodeCharacter2 != this.source)
								{
									nodeCharacter2.Knockback(this.source.currentPosition, 1, false, false, false);
								}
							}
						}
					}
				}
				cNode = default(Vector3);
			}
			if (this.effect._Name.Contains("Wall"))
			{
				this.isWall = true;
			}
			c = null;
		}
		else if (!this.isSingleTarget && !stop)
		{
			this.pickedGroundNodesSaved = new List<GraphNode>();
			if (this.startNode != null && Links.x.gaia.pathfindingReady)
			{
				int num12 = (int)this.influenceRadius;
				this.isWall = false;
				bool isNearWall = false;
				if (this.effect._Name.Contains("Wall"))
				{
					this.isWall = true;
					if (this.effect._Name.Contains("Mushroom"))
					{
						isNearWall = true;
						if (this.spellTarget && this.spellTarget.node != null)
						{
							this.startNode = this.spellTarget.node;
						}
					}
				}
				int nodeCount = 0;
				float max = ((float)num12 * Records.x.nodeSize + 0.1f) * ((float)num12 * Records.x.nodeSize + 0.1f);
				ConstantPath constPath = ConstantPath.ConstructFast(this.startNode, Records.x.GetConstantPathRadius(num12), null);
				NNConstraint nnconstraint = new NNConstraint();
				nnconstraint.constrainWalkability = false;
				nnconstraint.constrainToEnvironment = -1;
				nnconstraint.constrainTags = false;
				nnconstraint.checkCircleID = 0;
				if (this.ability._Name.Contains("Moss"))
				{
					nnconstraint.constrainToEnvironment = 3;
				}
				constPath.nnConstraint = nnconstraint;
				AstarPath.StartPath(constPath, false);
				yield return base.StartCoroutine(constPath.WaitForPath());
				constPath.Claim(this);
				this.allNodes = constPath.allNodes;
				int count3 = this.allNodes.Count;
				Vector3 vector8 = (Vector3)this.startNode.position;
				if (this.source)
				{
					vector8 = this.source.tr.position;
				}
				Vector3 vector9 = (Vector3)this.startNode.position;
				if (vector9 == vector8)
				{
					vector9 += new Vector3(0.1f, 0f, 0.1f);
				}
				Vector3 vector10 = vector9 + Quaternion.LookRotation(vector8 - vector9) * Vector3.forward * -3.5f;
				Vector3 vector11 = vector9 + Quaternion.LookRotation(vector8 - vector9) * Vector3.forward * 3.5f;
				float sqrMagnitude = (vector8 - vector10).sqrMagnitude;
				float sqrMagnitude2 = (vector8 - vector11).sqrMagnitude;
				Vector3 vector12 = vector9;
				for (int num13 = 0; num13 < count3; num13++)
				{
					Vector3 vector13 = (Vector3)this.allNodes[num13].position;
					vector12.y = vector13.y;
					if ((vector13 - vector12).sqrMagnitude < max)
					{
						if (this.isWall)
						{
							if (isNearWall)
							{
								float sqrMagnitude3 = (vector13 - new Vector3(this.spellTarget.currentPosition.x, vector13.y, this.spellTarget.currentPosition.z)).sqrMagnitude;
								if (sqrMagnitude3 < 16f && sqrMagnitude3 > 2.25f)
								{
									this.pickedGroundNodesSaved.Add(this.allNodes[num13]);
									int num14 = nodeCount;
									nodeCount = num14 + 1;
								}
							}
							else
							{
								float sqrMagnitude4 = (vector13 - new Vector3(vector8.x, vector13.y, vector8.z)).sqrMagnitude;
								if (sqrMagnitude4 >= sqrMagnitude2 && sqrMagnitude4 <= sqrMagnitude)
								{
									this.pickedGroundNodesSaved.Add(this.allNodes[num13]);
									int num14 = nodeCount;
									nodeCount = num14 + 1;
								}
							}
						}
						else
						{
							this.pickedGroundNodesSaved.Add(this.allNodes[num13]);
							int num14 = nodeCount;
							nodeCount = num14 + 1;
						}
					}
				}
				this.pickedGroundNodesSaved.Remove(this.startNode);
				if (!this.isWall && !this.customTileAI)
				{
					this.pickedGroundNodesSaved.Add(this.startNode);
				}
				constPath.Release(this, false);
				constPath = null;
			}
		}
		if (this.effect._TileRadius == 1 && (this.singleTargetInteractive || this.singleTarget) && this.hasAbility && (this.ability._WeaponReq.Contains("Elixir") || this.ability._WeaponReq.Contains("Bow") || this.ability._WeaponReq.Contains("Sling")))
		{
			this.isSingleTarget = true;
		}
		this.effectTiles.Clear();
		this.allTiles.Clear();
		this.hasTile.Clear();
		if (!this.isSingleTarget)
		{
			if (!stop && this.pickedGroundNodesSaved != null)
			{
				for (int num15 = 0; num15 < this.pickedGroundNodesSaved.Count; num15++)
				{
					this.allTiles.Add(this.pickedGroundNodesSaved[num15]);
				}
			}
		}
		else if (this.singleTarget && this.singleTarget.node != null)
		{
			this.allTiles.Add(this.singleTarget.node);
		}
		if (this.allTiles.Count > 0 && !stop)
		{
			this.mainPosition = (Vector3)this.allTiles[this.allTiles.Count - 1].position;
			this.mainNode = this.allTiles[this.allTiles.Count - 1];
			if (this.ability != null && this.IsInstrument(this.ability._WeaponReq))
			{
				this.isInstrument = true;
			}
			if (!this.customTileAI)
			{
				int num16 = this.allTiles.Count - 1;
				this.allTiles.Insert(0, this.mainNode);
				this.allTiles.RemoveAt(num16 + 1);
			}
			if (this.ability == null)
			{
				this.overallTime = (int)this.effect._OverallTime;
				if (this.effect._OverallTime > 0f && !this.fromEnchantedItem)
				{
					this.timeToWait = this.effect._OverallTime;
				}
			}
			else
			{
				this.overallTime = this.ability._OverallTime;
				if (this.ability._OverallTime > 0 && !this.fromEnchantedItem)
				{
					this.timeToWait = (float)this.ability._OverallTime;
				}
				if (this.paganRow != null && (this.fromEnchantedItem || this.ability._IsSpell))
				{
					if (this.fromEnchantedItem)
					{
						this.timeToWait = Records.x.RealSecondsToGameSeconds(this.spellDuration);
						this.overallTime = (int)this.timeToWait;
					}
					else
					{
						Vector4 vector14 = new Vector4(0f, 0f, 0f, 0f);
						if (!this.doSpellScroll)
						{
							vector14 = this.source.stats.GetAbilityLevel(this.spellIndex);
						}
						else
						{
							vector14 = Records.x.GetSpellScrollData(this.spellIndex);
						}
						for (int num17 = 0; num17 < 3; num17++)
						{
							string text4 = "";
							float num18 = 0f;
							if (num17 == 0)
							{
								text4 = this.paganRow._Slider1;
								num18 = vector14.x;
							}
							if (num17 == 1)
							{
								text4 = this.paganRow._Slider2;
								num18 = vector14.y;
							}
							if (num17 == 2)
							{
								text4 = this.paganRow._Slider3;
								num18 = vector14.z;
							}
							if (text4 != null && text4.Contains("Duration"))
							{
								this.timeToWait = Records.x.RealSecondsToGameSeconds(num18);
							}
						}
						this.overallTime = (int)this.timeToWait;
					}
				}
				else if (this.ability._MainSkill.Contains("Pipe"))
				{
					this.timeToWait = 0f;
					this.overallTime = -1;
				}
				else if (this.effect._IsSong && !this.effect._IsBuff)
				{
					this.timeToWait = this.effect._OverallTime;
				}
			}
			if (this.isSingleTarget)
			{
				if (this.singleTargetInteractive)
				{
					NNConstraint nnconstraint2 = new NNConstraint();
					nnconstraint2.constrainWalkability = true;
					nnconstraint2.walkable = true;
					nnconstraint2.constrainTags = false;
					nnconstraint2.checkCircleID = 0;
					GraphNode node = AstarPath.active.GetNearest(this.singleTargetInteractive.transform.position, nnconstraint2).node;
					if (node != null)
					{
						this.effectTiles.Add(node);
						this.hasTile.Add(true);
					}
					else
					{
						string[] array = new string[6];
						array[0] = "Interactive did not find node for tile effect code ";
						array[1] = ((this != null) ? this.ToString() : null);
						array[2] = " ";
						array[3] = this.effect._Name;
						array[4] = " from ";
						int num19 = 5;
						Character character = this.source;
						array[num19] = ((character != null) ? character.ToString() : null);
						Debug.Log(string.Concat(array));
					}
				}
				else if (this.singleTarget.node != null)
				{
					this.effectTiles.Add(this.singleTarget.node);
					this.hasTile.Add(true);
				}
				else
				{
					string[] array2 = new string[6];
					array2[0] = "Single target effect did not find node for tile effect code ";
					array2[1] = ((this != null) ? this.ToString() : null);
					array2[2] = " ";
					array2[3] = this.effect._Name;
					array2[4] = " from ";
					int num20 = 5;
					Character character2 = this.source;
					array2[num20] = ((character2 != null) ? character2.ToString() : null);
					Debug.Log(string.Concat(array2));
				}
				this.pooledEffects.Add(null);
				if (!this.singleTargetInteractive)
				{
					this.CheckTile(this.singleTarget.node, this.singleTarget, false);
				}
				else
				{
					this.CheckTileInteractive(this.singleTargetInteractive);
				}
				if (this.hasAbility && this.ability._CanBreak > 0 && this.ability._AINotes != "Summons")
				{
					Links.x.diorama.CheckTileEffects(this);
				}
				if (this.hasAbility && this.ability._NoiseRadius > 0 && this.source)
				{
					Links.x.sensory.AddNoise(this.source.gameObject, this.mainNode, this.ability._Name, this.source);
				}
				this.Remove();
			}
			else
			{
				Links.x.cellar.AddTileEffect(this);
				this.scatterRoutine = this.ScatterTiles(0);
				base.StartCoroutine(this.scatterRoutine);
			}
		}
		if (stop)
		{
			Object.Destroy(this);
		}
		yield break;
	}

	// Token: 0x06000AD5 RID: 2773 RVA: 0x000D7788 File Offset: 0x000D5988
	private bool SingleTargetDone()
	{
		return !Links.x.gaia.sceneLoaded || !this.singleTarget || this.singleTarget.dead || this.singleTarget.stunned || Links.x.combat.inPocketAttack;
	}

	// Token: 0x06000AD6 RID: 2774 RVA: 0x000D77E5 File Offset: 0x000D59E5
	private IEnumerator ScatterTiles(int pass)
	{
		this.inScatter = true;
		this.scatterPassTime = Links.x.gameplay.seconds;
		bool hasAnimator = false;
		bool checkIfTileIsTaken = false;
		bool addEffectToTile = true;
		bool changeEnvironment = false;
		bool wall = false;
		bool stop = false;
		bool summons = false;
		int max = 6;
		bool spiritTile = false;
		bool rotateToGround = false;
		bool doAllTiles = false;
		this.isFaunaCreature = false;
		bool rotateForward = false;
		Quaternion look = Quaternion.identity;
		bool onlyOnePass = false;
		this.doWave = false;
		while (Records.x.pocketPause || Records.x.removeControls || Records.x.inMenus)
		{
			yield return null;
		}
		if (pass == 0 && !this.effect._IsBuff && !this.effect._IsSong)
		{
			if (!this.hasAbility)
			{
				this.setPenalty = true;
			}
			if (this.hasAbility)
			{
				if (this.source.npc)
				{
					this.setPenalty = true;
				}
				if (!this.source.npc && (this.ability._TargetsFaction == 6 || this.ability._TargetsFaction == 7))
				{
					this.setPenalty = true;
				}
			}
		}
		if (this.hasAbility)
		{
			if (this.ability._FX == 29 || this.ability._FX == 108)
			{
				hasAnimator = true;
				wall = true;
				checkIfTileIsTaken = true;
				addEffectToTile = false;
			}
			if (this.ability._IsSpell && this.ability._MainSkill == "Fauna" && (this.ability._Name.Contains("Trap") || this.ability._Name.Contains("Nest")))
			{
				this.isFaunaCreature = true;
			}
			if (this.ability._Name == "FishPoisonBeam")
			{
				rotateForward = true;
				look = Quaternion.LookRotation(this.spellTarget.currentPosition - this.source.currentPosition);
				this.doWave = true;
				onlyOnePass = true;
			}
			if (this.ability._Name == "FishPoison")
			{
				rotateToGround = true;
				onlyOnePass = true;
				hasAnimator = true;
				doAllTiles = true;
			}
			if (this.ability._Name == "Web")
			{
				rotateToGround = true;
				onlyOnePass = true;
				hasAnimator = true;
				doAllTiles = true;
			}
			if (this.ability._Name == "BoneSpikes")
			{
				rotateToGround = true;
				onlyOnePass = true;
				this.doWave = true;
				doAllTiles = true;
				MasterAudio.PlaySound3DAtVector3AndForget("SpecialAttacks", this.source.tr.position, 0.8f, new float?(1f), 0f, "Cannonball1", null);
			}
		}
		if (this.effect._Name.Contains("Moss"))
		{
			changeEnvironment = true;
			rotateToGround = true;
		}
		if (this.effect._Name.Contains("AttractionSpores"))
		{
			doAllTiles = true;
		}
		if (wall || changeEnvironment || doAllTiles || (this.isFaunaCreature && this.currentlySummoned >= this.summonAmount))
		{
			if (pass > 0)
			{
				stop = true;
			}
			else
			{
				onlyOnePass = true;
			}
		}
		if (this.isInstrument && pass > 0)
		{
			stop = true;
		}
		if (pass == 0 && this.hasAbility && this.ability._CenterFX > 0)
		{
			this.centerFX = Links.x.cellar.GetPooledGameObject(this.ability._CenterFX);
			this.centerFX.transform.position = (Vector3)this.startNode.position;
			this.centerFX.SetActive(true);
		}
		if (this.hasAbility)
		{
			if (this.isSummons)
			{
				summons = true;
				if (pass > 0 && (this.currentlySummoned >= this.summonAmount || !this.isFaunaCreature))
				{
					stop = true;
				}
				if (!this.ability._IsSpell)
				{
					yield return new WaitForSeconds(1f);
					while (Records.x.pocketPause)
					{
						yield return null;
					}
				}
			}
			if (this.effect._Name.Contains("SlipSlime"))
			{
				rotateToGround = true;
			}
			max = 2;
			if (this.isFaunaCreature)
			{
				max = 10;
			}
		}
		else
		{
			max = 1;
		}
		if (this.removing)
		{
			stop = true;
		}
		if (pass == 0)
		{
			this.effectStartTime = (float)((int)Links.x.gameplay.seconds);
			this.ready = true;
		}
		if (!stop)
		{
			bool remove = false;
			bool removedNode = false;
			float offset = 0.1f;
			if (this.hasAbility && this.ability._FXOffset != 0f)
			{
				offset = this.ability._FXOffset;
			}
			float waitTime = 1f / (float)this.allTiles.Count;
			int added = 0;
			if (changeEnvironment)
			{
				waitTime = 0.0001f;
			}
			int num;
			for (int i = 0; i < this.allTiles.Count; i = num + 1)
			{
				if (!this.waitingToRemove && !this.removing && i < this.allTiles.Count)
				{
					GraphNode node = this.allTiles[i];
					remove = false;
					if (checkIfTileIsTaken && node != null)
					{
						remove = Links.x.sensory.CheckTileTaken(node);
					}
					bool inScatterPass = false;
					if (!this.customTileAI && !wall && (!summons || this.isFaunaCreature) && !doAllTiles && !this.isInstrument && !changeEnvironment && !onlyOnePass)
					{
						if (Random.Range(0, max) == 0)
						{
							inScatterPass = true;
						}
						if (this.isFaunaCreature && this.currentlySummoned >= this.summonAmount)
						{
							inScatterPass = false;
						}
					}
					else if (this.isInstrument && pass == 1)
					{
						inScatterPass = false;
						if (i < this.pooledEffects.Count)
						{
							num = added;
							added = num + 1;
							if (this.pooledEffects[i])
							{
								this.pooledEffects[i].SetActive(false);
							}
						}
						if (added > 10)
						{
							yield return new WaitForSeconds(0.001f);
							while (Records.x.pocketPause)
							{
								yield return null;
							}
							added = 0;
						}
					}
					else if (summons)
					{
						if (added < this.summonAmount)
						{
							inScatterPass = true;
						}
					}
					else if (changeEnvironment)
					{
						if (node != null && Physics.Raycast((Vector3)node.position + new Vector3(0f, 3f, 0f), Vector3.up * -1f, 10f, 4194433))
						{
							inScatterPass = true;
						}
					}
					else
					{
						inScatterPass = true;
					}
					if (!remove && inScatterPass)
					{
						GameObject visual = this.GetVisual();
						if (spiritTile)
						{
							this.AddSpiritTile(visual);
						}
						if (pass > 0 && !this.isFaunaCreature)
						{
							this.RemoveFirstEffect();
						}
						if (node != null)
						{
							Vector3 vector = (Vector3)node.position;
							this.pooledEffects.Add(visual);
							this.effectTiles.Add(node);
							this.hasTile.Add(true);
							num = added;
							added = num + 1;
							if (visual)
							{
								if (!visual.activeSelf)
								{
									visual.SetActive(true);
								}
								visual.transform.Rotate(new Vector3(0f, Random.Range(0f, 180f), 0f));
								Vector3 vector2 = vector + new Vector3(0f, offset, 0f);
								if (this.isInstrument)
								{
									vector2 = vector + new Vector3(Random.Range(-0.3f, 0.3f), offset, Random.Range(-0.3f, 0.3f));
								}
								visual.transform.position = vector2;
								if (this.hasAbility && this.ability._Sound != "" && !this.isInstrument)
								{
									if (this.customTileAI)
									{
										string text = this.ability._Sound;
										if (Random.Range(0, 2) == 0)
										{
											text += "1";
										}
										else
										{
											text += "2";
										}
										MasterAudio.PlaySound3DAtVector3AndForget("SpecialAttacks", this.mainPosition, 1f, new float?(1f), 0f, text, null);
									}
									else
									{
										MasterAudio.PlaySound3DAtVector3AndForget(this.ability._Sound, this.mainPosition, 0.8f, new float?(1f), 0f, "", null);
									}
								}
							}
							if (hasAnimator)
							{
								HannahAnimator component = visual.GetComponent<HannahAnimator>();
								if (component)
								{
									component.stopDuringPocketPause = true;
									this.animators.Add(component);
									if (this.ability._FX == 29 || this.ability._FX == 108)
									{
										component.enabled = true;
										component.Play("Start");
									}
									else
									{
										component.enabled = true;
										if (component.currentAnimation == "End")
										{
											component.Play("Start");
										}
									}
								}
							}
							if (this.hasAbility)
							{
								if (wall && visual)
								{
									this.breakable = visual.GetComponent<BreakableActions>();
									this.breakable.node = node;
									this.breakable.caster = this.source;
									this.breakable.tileEffect = this;
									this.breakables.Add(this.breakable);
								}
								if (this.ability._FX == 31 && this.ability._IsSpell && visual)
								{
									HannahAnimator component2 = visual.GetComponent<HannahAnimator>();
									if (component2)
									{
										component2.currentTileEffect = this;
										component2.enabled = true;
										component2.Play("StartEndSummon");
									}
								}
								if (!this.ability._IsSpell && summons && added <= this.summonAmount)
								{
									this.Flag();
								}
								RaycastHit raycastHit;
								if (rotateToGround && Physics.Raycast((Vector3)node.position + new Vector3(0f, 3f, 0f), Vector3.up * -1f, out raycastHit, 10f, 4194449))
								{
									Vector3 normal = raycastHit.normal;
									normal.y = Mathf.Clamp(normal.y, 0.97f, 1f);
									Quaternion quaternion = Quaternion.FromToRotation(Vector3.up, normal);
									if (visual)
									{
										Quaternion rotation = visual.transform.rotation;
										visual.transform.rotation = quaternion * rotation;
									}
								}
								if (rotateForward && visual)
								{
									visual.transform.rotation = look;
								}
								if (this.isFaunaCreature && visual)
								{
									this.SetupFaunaCreature(visual, node);
								}
							}
							if (this.setPenalty)
							{
								node.Penalty = 30000U;
							}
							if (changeEnvironment)
							{
								node.SetFlowerConnectionsEnvironment("Ground", 0);
							}
							if (addEffectToTile)
							{
								Links.x.sensory.CheckNewSpellNode(this, node, this.GetEffectName(), this.hasAbility, this.ability, this.source);
							}
						}
						if (wall || onlyOnePass)
						{
							if (!changeEnvironment)
							{
								yield return new WaitForSeconds(0.1f);
								while (Records.x.pocketPause)
								{
									yield return null;
								}
							}
						}
						else if (this.isInstrument)
						{
							if (added > 5)
							{
								yield return new WaitForSeconds(0.02f);
								while (Records.x.pocketPause)
								{
									yield return null;
								}
								added = 0;
							}
						}
						else if (!changeEnvironment)
						{
							yield return new WaitForSeconds(0.1f);
							while (Records.x.pocketPause)
							{
								yield return null;
							}
						}
						if (pass > 0)
						{
							yield return new WaitForSeconds(waitTime);
							while (Records.x.pocketPause)
							{
								yield return null;
							}
						}
					}
					if (remove)
					{
						this.allTiles[i] = null;
						removedNode = true;
					}
					node = null;
				}
				num = i;
			}
			if (removedNode && !this.waitingToRemove)
			{
				this.allTiles.RemoveAll((GraphNode item) => item == null);
			}
			if (pass == 0)
			{
				if (this.hasAbility && (this.ability._CanBreak > 0 || this.effect._Health < 0f) && this.ability._AINotes != "Summons")
				{
					Links.x.diorama.CheckTileEffects(this);
				}
				if (this.hasAbility && this.ability._NoiseRadius > 0 && this.source)
				{
					Links.x.sensory.AddNoise(this.source.gameObject, this.mainNode, this.ability._Name, this.source);
				}
				if (this.overallTime < 0 && !summons && !this.isFaunaCreature)
				{
					this.Remove();
				}
			}
			this.scatterRoutine = null;
			this.inScatter = false;
			if (this.waitingToRemove)
			{
				this.Remove();
			}
			if (!this.removing)
			{
				float num2 = 0.3f;
				if (this.isInstrument && pass == 0)
				{
					num2 = 1E-06f;
				}
				yield return new WaitForSeconds(num2);
				while (Records.x.pocketPause)
				{
					yield return null;
				}
				if (!onlyOnePass)
				{
					this.inScatter = true;
					this.scatterPassTime = Links.x.gameplay.seconds;
					if (pass == 1)
					{
						this.scatterRoutine = this.ScatterTiles(2);
					}
					else
					{
						this.scatterRoutine = this.ScatterTiles(1);
					}
					base.StartCoroutine(this.scatterRoutine);
				}
			}
		}
		else
		{
			if (this.isInstrument)
			{
				for (int j = 0; j < this.pooledEffects.Count; j++)
				{
					this.RemoveTile(this.effectTiles[j], this.pooledEffects[j], null);
				}
				this.pooledEffects.Clear();
				this.hasTile.Clear();
				this.animators.Clear();
				this.effectTiles.Clear();
			}
			this.scatterRoutine = null;
			this.inScatter = false;
			if (this.waitingToRemove)
			{
				this.Remove();
			}
		}
		yield break;
	}

	// Token: 0x06000AD7 RID: 2775 RVA: 0x000D77FC File Offset: 0x000D59FC
	private void RemoveFirstEffect()
	{
		if (this.pooledEffects.Count > 0)
		{
			if (this.pooledEffects[0])
			{
				Links.x.cellar.ReturnPooledGameObject(this.fx, this.pooledEffects[0]);
			}
			if (this.setPenalty && !Links.x.cellar.OtherListHasTile(this, this.effectTiles[0], "") && this.effectTiles[0] != null)
			{
				this.effectTiles[0].GetErosionPenalty();
			}
			this.pooledEffects.RemoveAt(0);
			this.effectTiles.RemoveAt(0);
			this.hasTile.RemoveAt(0);
			if (this.animators.Count > 0)
			{
				this.animators.RemoveAt(0);
			}
		}
	}

	// Token: 0x06000AD8 RID: 2776 RVA: 0x000D78D8 File Offset: 0x000D5AD8
	private GameObject GetVisual()
	{
		if (this.isSummons && !this.ability._IsSpell)
		{
			return null;
		}
		if (!this.hasAbility)
		{
			this.fx = this.effect._FX;
		}
		else
		{
			this.fx = this.ability._FX;
		}
		if (this.fx > 0)
		{
			return Links.x.cellar.GetPooledGameObject(this.fx);
		}
		return null;
	}

	// Token: 0x06000AD9 RID: 2777 RVA: 0x000D7948 File Offset: 0x000D5B48
	private void AddSpiritTile(GameObject go)
	{
		Links.x.cameraEffects.AddRemoveGhost(go.GetComponent<MeshRenderer>(), true);
	}

	// Token: 0x06000ADA RID: 2778 RVA: 0x000D7960 File Offset: 0x000D5B60
	public void SetupFaunaCreature(GameObject go, GraphNode n)
	{
		this.currentlySummoned++;
		Fauna component = go.GetComponent<Fauna>();
		if (this.faunas == null)
		{
			this.faunas = new List<Fauna>();
		}
		this.faunas.Add(component);
		component.tileEffect = this;
		component.gameObject.transform.position = (Vector3)n.position;
		component.GetVariables();
		component.Spawn();
		component.node = n;
		component.type = this.effect._Name;
		if (this.effect._Script.Contains("Trap"))
		{
			if (this.effect._Name.Contains("Roly"))
			{
				GraphNode graphNode = n.ConnectionFromIndex(1);
				component.MakePath(graphNode, n.environment);
				return;
			}
			GraphNode graphNode2 = this.allTiles[Random.Range(0, this.allTiles.Count)];
			component.MakePath(graphNode2, n.environment);
		}
	}

	// Token: 0x06000ADB RID: 2779 RVA: 0x000D7A58 File Offset: 0x000D5C58
	public void UpdateFaunaNode(GraphNode currentNode, Fauna fauna)
	{
		for (int i = 0; i < this.faunas.Count; i++)
		{
			if (this.faunas[i] == fauna)
			{
				Links.x.sensory.CheckNewSpellNode(this, currentNode, this.GetEffectName(), this.hasAbility, this.ability, this.source);
			}
		}
	}

	// Token: 0x06000ADC RID: 2780 RVA: 0x000D7AB8 File Offset: 0x000D5CB8
	private GraphNode RolyPoint(GraphNode currentNode, Fauna fauna)
	{
		GraphNode graphNode = currentNode;
		float num = float.PositiveInfinity;
		Vector3 position = fauna.tr.position;
		Quaternion quaternion = Quaternion.LookRotation((Vector3)this.startNode.position - fauna.tr.position);
		Vector3 vector = position + quaternion * Vector3.right * 3f + quaternion * Vector3.forward * Random.Range(0f, 1f);
		for (int i = 0; i < this.allTiles.Count; i++)
		{
			GraphNode graphNode2 = this.allTiles[i];
			float sqrMagnitude = (vector - (Vector3)graphNode2.position).sqrMagnitude;
			if (sqrMagnitude < num && graphNode2 != currentNode)
			{
				num = sqrMagnitude;
				graphNode = graphNode2;
			}
		}
		return graphNode;
	}

	// Token: 0x06000ADD RID: 2781 RVA: 0x000D7B94 File Offset: 0x000D5D94
	public void FaunaRepath(Fauna faunaController)
	{
		if (this.effect._Script.Contains("Trap"))
		{
			if (this.effect._Name.Contains("Roly"))
			{
				GraphNode graphNode = this.RolyPoint(faunaController.node, faunaController);
				faunaController.MakePath(graphNode, faunaController.node.environment);
				return;
			}
			GraphNode graphNode2 = this.allTiles[Random.Range(0, this.allTiles.Count)];
			faunaController.MakePath(graphNode2, faunaController.node.environment);
		}
	}

	// Token: 0x06000ADE RID: 2782 RVA: 0x000D7C20 File Offset: 0x000D5E20
	public void SaveCreatures()
	{
		for (int i = 0; i < this.creatures.Count; i++)
		{
			if (this.creatures[i])
			{
				this.creatures[i].SaveCreatures();
			}
		}
	}

	// Token: 0x06000ADF RID: 2783 RVA: 0x000D7C67 File Offset: 0x000D5E67
	public void Flag()
	{
		if (this.creatures.Count < this.summonAmount)
		{
			base.StartCoroutine(this.DoFlag());
		}
	}

	// Token: 0x06000AE0 RID: 2784 RVA: 0x000D7C89 File Offset: 0x000D5E89
	private IEnumerator DoFlag()
	{
		int amt = this.summonAmount;
		if (this.ability._IsSpell)
		{
			amt = 1;
		}
		int num22;
		for (int i = 0; i < amt; i = num22 + 1)
		{
			bool alliedToParty = false;
			if (this.source)
			{
				alliedToParty = !this.source.npc;
			}
			Vector3 spawnPosition = this.mainPosition;
			if (!this.ability._IsSpell && Links.x.gaia.pathfindingReady)
			{
				ConstantPath constPath = null;
				GraphNode j = this.startNode;
				if (this.source)
				{
					j = this.source.node;
				}
				constPath = ConstantPath.ConstructFast(j, Records.x.GetConstantPathRadius(9), null);
				NNConstraint nnconstraint = new NNConstraint();
				nnconstraint.checkConnections = 0;
				nnconstraint.constrainWalkability = true;
				nnconstraint.walkable = true;
				nnconstraint.constrainTags = false;
				nnconstraint.checkCircleID = 0;
				nnconstraint.passID = 0;
				nnconstraint.passID2 = 0;
				nnconstraint.constrainPenalty = 0;
				nnconstraint.constrainToEnvironment = -1;
				if (this.source && this.source.node != null)
				{
					nnconstraint.constrainToEnvironment = this.source.node.environment;
				}
				if (j != null)
				{
					nnconstraint.constrainToArea = (int)j.Area;
				}
				if (Links.x.gaia.pathfindingReady)
				{
					constPath.nnConstraint = nnconstraint;
					AstarPath.StartPath(constPath, false);
					yield return base.StartCoroutine(constPath.WaitForPath());
					constPath.Claim(this);
					List<GraphNode> list = constPath.allNodes;
					List<GraphNode> list2 = new List<GraphNode>();
					int count = list.Count;
					Vector3 vector = (Vector3)j.position;
					int num = count - 1;
					int num2 = 0;
					for (int l = num; l >= 0; l--)
					{
						float sqrMagnitude = (vector - (Vector3)list[l].position).sqrMagnitude;
						if (sqrMagnitude > 400f && sqrMagnitude < 6400f && list[l] != j)
						{
							list2.Add(list[l]);
							num2++;
						}
					}
					if (num2 == 0)
					{
						for (int m = num; m >= 0; m--)
						{
							if ((vector - (Vector3)list[m].position).sqrMagnitude > 100f && list[m] != j)
							{
								list2.Add(list[m]);
								num2++;
							}
						}
					}
					if (num2 == 0)
					{
						for (int n = num; n >= 0; n--)
						{
							list2.Add(list[n]);
							num2++;
						}
					}
					if (num2 > 0)
					{
						if (num2 == 1)
						{
							spawnPosition = (Vector3)list2[0].position;
						}
						else
						{
							spawnPosition = (Vector3)list2[Random.Range(0, num2)].position;
						}
					}
					constPath.Release(this, false);
				}
				constPath = null;
				j = null;
			}
			float num3 = Links.x.gameplay.seconds + this.timeToWait;
			if (this.overallTime <= 0)
			{
				num3 = 0f;
				this.timeToWait = 0f;
			}
			bool flag = true;
			bool flag2 = false;
			bool flag3 = false;
			string text = this.effect._Name;
			if (text.Contains("Friend"))
			{
				text = this.itemInfo;
			}
			if (text.Contains("Summon"))
			{
				this.attacksAllowed = 1;
				if (text.Contains("Redbird"))
				{
					this.attacksAllowed = 2;
				}
			}
			else
			{
				if (!alliedToParty && text == "AcornMen")
				{
					text += "NPC";
				}
				if (text == "FindShroomer")
				{
					flag = false;
					alliedToParty = false;
					if (this.spellData.y <= 1f)
					{
						int num4 = Random.Range(0, 2);
						if (num4 == 0)
						{
							text = "ShroomerEasy";
						}
						if (num4 == 1)
						{
							text = "ShroomerFlyer";
						}
					}
					else if (this.spellData.y > 1f && this.spellData.y <= 2f)
					{
						int num5 = Random.Range(0, 2);
						if (num5 == 0)
						{
							text = "Shroomer";
						}
						if (num5 == 1)
						{
							text = "ShroomerBomber";
						}
					}
					else
					{
						int num6 = Random.Range(0, 2);
						if (num6 == 0)
						{
							text = "GoldShroomer";
						}
						if (num6 == 1)
						{
							text = "SporeShroomerMed";
						}
					}
					flag2 = true;
					this.needsCreatureSave = true;
					if (this.source.party)
					{
						flag3 = true;
					}
				}
				if (text == "FindForest")
				{
					flag = false;
					alliedToParty = false;
					if (this.spellData.y <= 1f)
					{
						int num7 = Random.Range(0, 2);
						if (num7 == 0)
						{
							text = "Fox";
						}
						if (num7 == 1)
						{
							text = "ImpRat";
						}
					}
					else if (this.spellData.y > 1f && this.spellData.y <= 2f)
					{
						int num8 = Random.Range(0, 2);
						if (num8 == 0)
						{
							text = "Bakka";
						}
						if (num8 == 0)
						{
							text = "StickBakka";
						}
						if (num8 == 1)
						{
							text = "SandFox";
						}
					}
					else
					{
						int num9 = Random.Range(0, 3);
						if (num9 == 0)
						{
							text = "SandFox";
						}
						if (num9 == 1)
						{
							text = "HillBakka";
						}
						if (num9 == 1)
						{
							text = "MountainBakka";
						}
					}
					flag2 = true;
					this.needsCreatureSave = true;
					if (this.source.party)
					{
						flag3 = true;
					}
				}
				if (text == "FindFish")
				{
					flag = false;
					alliedToParty = false;
					if (this.spellData.y <= 1f)
					{
						int num10 = Random.Range(0, 2);
						if (num10 == 0)
						{
							text = "Insectoo";
						}
						if (num10 == 1)
						{
							text = "FishMonster";
						}
					}
					else if (this.spellData.y > 1f && this.spellData.y <= 2f)
					{
						int num11 = Random.Range(0, 2);
						if (num11 == 0)
						{
							text = "FishMonsterPoison";
						}
						if (num11 == 0)
						{
							text = "InsectooYellow";
						}
					}
					else
					{
						int num12 = Random.Range(0, 3);
						if (num12 == 0)
						{
							text = "FishMonsterPoison";
						}
						if (num12 == 1)
						{
							text = "InsectooYellow";
						}
					}
					flag2 = true;
					this.needsCreatureSave = true;
					if (this.source.party)
					{
						flag3 = true;
					}
				}
			}
			Quaternion quaternion = Quaternion.Euler(Vector3.zero);
			if (this.source)
			{
				quaternion = Quaternion.LookRotation(this.source.tr.position - spawnPosition);
			}
			else
			{
				quaternion = Quaternion.Euler(new Vector3(Random.Range(-180f, 180f), 0f, Random.Range(-180f, 180f)));
			}
			CreatureActions creatureActions = Links.x.gaia.CreateCreature(spawnPosition, quaternion, text, alliedToParty, num3, 1);
			this.creatures.Add(creatureActions);
			creatureActions.SetTileEffect(this);
			Character summon = creatureActions.GetFirstCharacter();
			if (flag2)
			{
				creatureActions.onlyTemporary = true;
				string text2 = creatureActions.gameObject.name;
				text2 += i.ToString();
				text2 += "_";
				text2 += Links.x.gameplay.seconds.ToString();
				creatureActions.gameObject.name = text2;
				summon.gameObject.name = text2;
				creatureActions.UpdateName();
			}
			if (this.source)
			{
				summon.TransferLKP(this.source);
			}
			summon.jumpingPosition = false;
			if (flag3 && this.source.inTown)
			{
				Character character = null;
				int num13 = Links.x.combat.NPCCount(true);
				int num15;
				int num14 = Links.x.sensory.NonHostileAttacked(null, base.gameObject.transform.position, this.source, false, true, out character, out num15);
				int num16 = Links.x.combat.NPCCount(true);
				if (Records.x.editor)
				{
					string[] array = new string[10];
					array[0] = "Alert owner non-hostile seen count ";
					array[1] = num14.ToString();
					array[2] = " made noise ";
					array[3] = true.ToString();
					array[4] = " offended character ";
					int num17 = 5;
					Character character2 = character;
					array[num17] = ((character2 != null) ? character2.ToString() : null);
					array[6] = " start npc count ";
					array[7] = num13.ToString();
					array[8] = " current npc count ";
					array[9] = num16.ToString();
					Debug.Log(string.Concat(array));
				}
				if (character && num13 == 0 && !character.party && !Links.x.sensory.ProofState(character))
				{
					Records.x.AddBribeBadge(character, "Seen", false, this.source);
				}
			}
			if (this.ability._IsSpell)
			{
				if (this.source)
				{
					float num18;
					string text3;
					if (this.doSpellScroll || this.fromEnchantedItem)
					{
						num18 = Mathf.Round(this.tether);
						text3 = this.source.stats.PaganPowerCalculation(false, this.tether, true);
					}
					else
					{
						num18 = Mathf.Round(this.source.stats.PaganPower(this.tether, false));
						text3 = this.source.stats.PaganPowerCalculation(false, this.tether, false);
					}
					this.sourceLevel = num18;
					if (flag)
					{
						Effects effects = summon.gameObject.AddComponent<Effects>();
						Links.x.cellar.AddEffects(effects);
						effects.source = this.source;
						effects.target = summon;
						effects.targetInteractive = null;
						effects.fromLoad = false;
						effects.effectName = "SummonFighterPotency";
						effects.sourceLevel = this.sourceLevel;
						effects.Inflicted(true);
						this.str.Clear();
						if (!this.source.npc)
						{
							this.str.Append(Links.x.gameFeed.GetPartyColorText(this.source));
						}
						this.str.Append(this.source.stats.GetName());
						if (!this.source.npc)
						{
							this.str.Append("</color>");
						}
						this.str.Append(" summoned a level ");
						this.str.Append(this.sourceLevel);
						this.str.Append(" ");
						this.str.Append(summon.stats.GetName());
						if (Records.x.showRulesetInfo)
						{
							this.str.Append(" <color #857C6C>... ");
							this.str.Append(text3);
							this.str.Append("</color>");
						}
						Links.x.gameFeed.AddFeed(this.str.ToString());
					}
					else
					{
						this.str.Clear();
						if (!this.source.npc)
						{
							this.str.Append(Links.x.gameFeed.GetPartyColorText(this.source));
						}
						this.str.Append(this.source.stats.GetName());
						if (!this.source.npc)
						{
							this.str.Append("</color>");
						}
						this.str.Append(" summoned ");
						this.str.Append(summon.stats.GetName());
						Links.x.gameFeed.AddFeed(this.str.ToString());
					}
					if (this.source.party)
					{
						summon.GetFriendDock(this.source);
					}
				}
				yield return new WaitForSeconds(0.05f);
			}
			else
			{
				summon.ClearPathUpdates();
				summon.ignoreNodeIDs = true;
				GraphNode graphNode = this.source.NearNode(this.source.tr.position, false, 0, -1, 0);
				summon.MakePath(graphNode, 200, false, false, true);
				summon.pipeSummons = true;
				bool found = false;
				Effects effects2 = summon.gameObject.AddComponent<Effects>();
				effects2.source = null;
				effects2.target = summon;
				effects2.fromLoad = false;
				effects2.effectName = "SecretInvisible";
				effects2.sourceLevel = 0f;
				effects2.Inflicted(false);
				float num19 = 0f;
				float num20 = Records.x.SongSkillMultiplier(this.sourceLevel);
				float num21 = this.source.stats.InstrumentPower(this.severity, this.ability._WeaponReq, false, out num19);
				string text4 = this.source.stats.InstrumentPowerCalculation(false, this.ability._WeaponReq, num19, true, this.sourceLevel, "Pipe");
				this.sourceLevel = this.source.stats.R1(num20);
				this.str.Clear();
				if (!this.source.npc)
				{
					this.str.Append(Links.x.gameFeed.GetPartyColorText(this.source));
				}
				this.str.Append(this.source.stats.GetName());
				if (!this.source.npc)
				{
					this.str.Append("</color>");
				}
				this.str.Append(" summoned a level ");
				this.str.Append(this.sourceLevel);
				this.str.Append(" ");
				this.str.Append(summon.stats.GetName());
				if (Records.x.showRulesetInfo)
				{
					this.str.Append(" <color #857C6C>... ");
					this.str.Append(text4);
					this.str.Append("</color>");
				}
				Links.x.gameFeed.AddFeed(this.str.ToString());
				effects2 = summon.gameObject.AddComponent<Effects>();
				Links.x.cellar.AddEffects(effects2);
				effects2.source = this.source;
				effects2.target = summon;
				effects2.targetInteractive = null;
				effects2.fromLoad = false;
				effects2.effectName = "PipePotency";
				effects2.sourceLevel = num21;
				effects2.Inflicted(true);
				for (int k = 0; k < 50; k = num22 + 1)
				{
					if (!found)
					{
						yield return new WaitForSeconds(2f);
						if (summon)
						{
							if (summon.IsSentient())
							{
								if ((this.source.tr.position - summon.tr.position).sqrMagnitude <= 400f)
								{
									found = true;
									break;
								}
								summon.ClearPathUpdates();
								summon.MakePath(this.source.node, 200, false, false, true);
							}
							else
							{
								found = true;
							}
						}
						else
						{
							found = true;
						}
					}
					num22 = k;
				}
			}
			this.currentlySummoned++;
			spawnPosition = default(Vector3);
			summon = null;
			num22 = i;
		}
		yield break;
	}

	// Token: 0x06000AE1 RID: 2785 RVA: 0x000D7C98 File Offset: 0x000D5E98
	public int ReturnCreatureCount()
	{
		return this.creatures.Count;
	}

	// Token: 0x06000AE2 RID: 2786 RVA: 0x000D7CA8 File Offset: 0x000D5EA8
	public void SetSpellMaterial(float curr, float max)
	{
		for (int i = 0; i < this.pooledEffects.Count; i++)
		{
			if (this.pooledEffects[i])
			{
				SetSpellMaterial component = this.pooledEffects[i].GetComponent<SetSpellMaterial>();
				Debug.Log(component);
				if (component)
				{
					component.Set(curr, max);
				}
			}
		}
	}

	// Token: 0x06000AE3 RID: 2787 RVA: 0x000D7D08 File Offset: 0x000D5F08
	public void RemoveTile(GraphNode n, GameObject pooledObject, BreakableActions b)
	{
		int num = this.effectTiles.IndexOf(n);
		if (num > -1)
		{
			this.effectTiles.RemoveAt(num);
			this.hasTile.RemoveAt(num);
		}
		if (b)
		{
			int num2 = this.breakables.IndexOf(b);
			if (num2 > -1)
			{
				this.breakables.RemoveAt(num2);
			}
		}
		if (!this.isInstrument)
		{
			num = this.pooledEffects.IndexOf(pooledObject);
		}
		if (num > -1)
		{
			this.pooledEffects.RemoveAt(num);
		}
		if (this.animators.Count > 0)
		{
			if (num < this.animators.Count && num > -1)
			{
				this.animators[num].enabled = true;
				this.animators[num].Play("End");
				this.animators[num].gameObject.GetComponent<Flag>().id = this.ability._FX;
				this.animators.RemoveAt(num);
				return;
			}
		}
		else
		{
			Links.x.cellar.ReturnPooledGameObject(this.ability._FX, pooledObject);
		}
	}

	// Token: 0x06000AE4 RID: 2788 RVA: 0x000D7E20 File Offset: 0x000D6020
	public void RemoveSummons(CreatureActions creature, Vector3 pt)
	{
		int num = this.creatures.IndexOf(creature);
		if (num > -1)
		{
			this.creatures.RemoveAt(num);
		}
		this.str.Clear();
		this.str.Append("Summoned creature has left");
		Links.x.gameFeed.AddFeed(this.str.ToString());
		if (!this.effect._Name.Contains("Summon"))
		{
			creature.Unsummon(this.doSpellScroll);
			GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(32);
			pooledGameObject.SetActive(true);
			pooledGameObject.transform.position = pt;
		}
		else if (creature && creature.GetFirstCharacter())
		{
			if (Links.x.gaia.sceneLoaded && Links.x.gaia.pathfindingReady && !Links.x.gaia.waitingToRemoveScene)
			{
				creature.GetFirstCharacter().Leave(false);
			}
			else
			{
				creature.GetFirstCharacter().Missing();
			}
		}
		if (creature)
		{
			Object.Destroy(creature.gameObject);
		}
	}

	// Token: 0x06000AE5 RID: 2789 RVA: 0x000D7F40 File Offset: 0x000D6140
	public void Remove()
	{
		if (!this.removing && this)
		{
			if (this.scatterRoutine != null)
			{
				base.StopCoroutine(this.scatterRoutine);
				this.scatterRoutine = null;
				this.inScatter = false;
			}
			this.removeRoutine = this.Removing();
			base.StartCoroutine(this.removeRoutine);
		}
	}

	// Token: 0x06000AE6 RID: 2790 RVA: 0x000D7F98 File Offset: 0x000D6198
	private IEnumerator Removing()
	{
		this.removing = true;
		this.removeTime = Links.x.gameplay.seconds;
		if (this.songFX)
		{
			if (this.effect._IsBuff)
			{
				this.source.RemoveEffect(72, "", true);
			}
			else
			{
				this.source.RemoveEffect(34, "", true);
			}
		}
		if (Records.x.effectsDebugging)
		{
			Debug.Log(((this != null) ? this.ToString() : null) + " removing tile effect " + this.effect._Name);
		}
		if (this.effect._WhileOnTile)
		{
			for (int j = 0; j < this.affectedCharacters.Count; j++)
			{
				if (this.affectedCharacters[j])
				{
					this.affectedCharacters[j].stats.RemoveTileEffect(this.affectedCharacterEffects[j]);
				}
			}
			for (int k = 0; k < this.affectedObjectsEffects.Count; k++)
			{
				if (k < this.affectedObjectsEffects.Count && this.affectedObjectsEffects[k])
				{
					this.affectedObjectsEffects[k].Healed(false, false);
				}
			}
		}
		if (this.effect._IsSong && !this.effect._IsBuff)
		{
			List<Effects> list = new List<Effects>();
			for (int l = 0; l < this.affectedCharacterEffects.Count; l++)
			{
				if (this.affectedCharacterEffects[l])
				{
					list.Add(this.affectedCharacterEffects[l]);
				}
			}
			for (int m = 0; m < list.Count; m++)
			{
				if (list[m])
				{
					list[m].Healed(false, true);
				}
			}
		}
		if (this.isFaunaCreature)
		{
			for (int n = 0; n < this.faunas.Count; n++)
			{
				if (this.faunas[n])
				{
					this.faunas[n].Remove();
				}
			}
		}
		for (int num = 0; num < this.creatures.Count; num++)
		{
			if (this.creatures[num])
			{
				this.RemoveSummons(this.creatures[num], this.creatures[num].GetPoint());
			}
		}
		if (!this.source)
		{
			for (int num2 = 0; num2 < this.creatures.Count; num2++)
			{
				if (this.creatures[num2])
				{
					Object.Destroy(this.creatures[num2].gameObject);
				}
			}
		}
		int num3;
		for (int i = 0; i < this.pooledEffects.Count; i = num3 + 1)
		{
			if (this.pooledEffects[i])
			{
				if (this.hasAbility && (this.ability._FX == 29 || this.ability._FX == 108) && this.pooledEffects[i])
				{
					this.breakable = this.pooledEffects[i].GetComponent<BreakableActions>();
					if (this.breakable)
					{
						this.breakable.effectID = this.ability._FX;
						this.breakable.Remove();
					}
				}
				if (this.animators.Count > 0)
				{
					if (this.animators[i])
					{
						this.animators[i].enabled = true;
						this.animators[i].Play("End");
						this.animators[i].gameObject.GetComponent<Flag>().id = this.ability._FX;
					}
				}
				else if (this.pooledEffects[i])
				{
					Links.x.cellar.ReturnPooledGameObject(this.fx, this.pooledEffects[i]);
				}
				if (this.effect._Name.Contains("Moss") && !Links.x.cellar.OtherListHasTile(this, this.effectTiles[i], "Moss") && this.effectTiles[i] != null)
				{
					this.effectTiles[i].SetFlowerConnectionsEnvironment("Original", 0);
					if (this.effectTiles[i].ID > 2 && Links.x.main && ((Vector3)this.effectTiles[i].position - Links.x.main.currentPosition).sqrMagnitude > 1600f)
					{
						Character nodeCharacter = Links.x.main.GetNodeCharacter(this.effectTiles[i].ID);
						if (nodeCharacter && nodeCharacter.npc && nodeCharacter.creatures)
						{
							GraphNode walkIndex = nodeCharacter.creatures.GetWalkIndex(0);
							if (walkIndex != null)
							{
								nodeCharacter.SetPosition((Vector3)walkIndex.position, walkIndex);
								nodeCharacter.FirstPosition(walkIndex);
								if (Records.x.editor)
								{
									Debug.Log("Removing NPC from vine rug");
								}
							}
						}
					}
				}
				if (this.setPenalty && !Links.x.cellar.OtherListHasTile(this, this.effectTiles[i], "") && this.effectTiles[i] != null)
				{
					this.effectTiles[i].GetErosionPenalty();
				}
				if (!this.isInstrument && Links.x.gaia.sceneLoaded)
				{
					yield return new WaitForSeconds(0.02f);
				}
				while (Records.x.pocketPause)
				{
					yield return null;
				}
			}
			num3 = i;
		}
		if (this.centerFX)
		{
			Links.x.cellar.ReturnPooledGameObject(this.ability._CenterFX, this.centerFX);
			this.centerFX = null;
		}
		Links.x.cellar.RemoveTileEffect(this);
		Object.Destroy(this);
		yield break;
	}

	// Token: 0x06000AE7 RID: 2791 RVA: 0x000D7FA8 File Offset: 0x000D61A8
	public bool HasTile(GraphNode n)
	{
		int count = this.effectTiles.Count;
		for (int i = 0; i < count; i++)
		{
			if (i < this.effectTiles.Count && this.effectTiles[i] == n)
			{
				return true;
			}
		}
		return false;
	}

	// Token: 0x06000AE8 RID: 2792 RVA: 0x000D7FF0 File Offset: 0x000D61F0
	public bool ShouldBeDone()
	{
		if (this.waitingForTargetDeath)
		{
			return true;
		}
		if (this.removing)
		{
			return false;
		}
		this.currentTime = Links.x.gameplay.seconds;
		if ((float)((int)this.currentTime) > this.timeToWait + this.effectStartTime + 100f && !this.effect._Name.Contains("Moss"))
		{
			Debug.Log("Found effect that should have stopped save " + ((this != null) ? this.ToString() : null) + " " + this.effect._Name);
			return true;
		}
		return this.summonAmount > 0;
	}

	// Token: 0x06000AE9 RID: 2793 RVA: 0x000D8094 File Offset: 0x000D6294
	private void Update()
	{
		if ((!Records.x.pocketPause && Links.x.gaia.sceneLoaded && !Records.x.removeControls && !Records.x.paused && !Links.x.combat.inPocketAttack) || Records.x.partyCamping)
		{
			this.UpdateEffectTime();
		}
	}

	// Token: 0x06000AEA RID: 2794 RVA: 0x000D80FC File Offset: 0x000D62FC
	public void UpdateEffectTime()
	{
		this.currentTime = Links.x.gameplay.seconds;
		if (this.removing && this.currentTime > this.removeTime + 180f)
		{
			if (Records.x.editor)
			{
				Debug.Log("Remove routine stuck for " + this.effect._Name);
			}
			this.removing = false;
			if (this.removeRoutine != null)
			{
				base.StopCoroutine(this.removeRoutine);
				this.removeRoutine = null;
			}
		}
		if (this.ready && !this.removing)
		{
			if (this.waitingForTargetDeath)
			{
				return;
			}
			if (this.overallTime > 0 && !this.removing)
			{
				if (this.summonAmount == 0 && !this.isInstrument && this.source)
				{
					if (this.source.dead || this.source.stunned)
					{
						this.Remove();
						return;
					}
					if (this.customTileAI && this.spellTarget && (this.spellTarget.dead || this.spellTarget.stunned))
					{
						this.Remove();
						return;
					}
				}
				if ((float)((int)this.currentTime) > this.timeToWait + this.effectStartTime)
				{
					if (this.inScatter && (!this.inScatter || this.currentTime <= this.scatterPassTime + 72f || this.summonAmount != 0))
					{
						if (Records.x.effectsDebugging)
						{
							Debug.Log("Removing effect: " + Time.timeSinceLevelLoad.ToString() + " " + Links.x.gameplay.seconds.ToString());
						}
						this.waitingToRemove = true;
						return;
					}
					if (!this.effect._Name.Contains("Moss"))
					{
						this.Remove();
						return;
					}
					bool flag = true;
					int count = this.effectTiles.Count;
					Vector3 position = Links.x.main.tr.position;
					for (int i = 0; i < count; i++)
					{
						if ((this.effectTiles[i].ID > 2 || ((Vector3)this.effectTiles[i].position - position).sqrMagnitude < 9f) && Links.x.main)
						{
							if (((Vector3)this.effectTiles[i].position - Links.x.main.tr.position).sqrMagnitude <= 1600f)
							{
								flag = false;
								break;
							}
							Character nodeCharacter = Links.x.main.GetNodeCharacter(this.effectTiles[i].ID);
							if (nodeCharacter)
							{
								if (!nodeCharacter.npc || !nodeCharacter.creatures)
								{
									flag = false;
									break;
								}
								GraphNode walkIndex = nodeCharacter.creatures.GetWalkIndex(0);
								if (walkIndex != null)
								{
									nodeCharacter.SetPosition((Vector3)walkIndex.position, walkIndex);
									nodeCharacter.FirstPosition(walkIndex);
									if (Records.x.editor)
									{
										Debug.Log("Removing NPC from vine rug");
									}
								}
							}
						}
					}
					if (flag)
					{
						if (Records.x.effectsDebugging)
						{
							Debug.Log("Removing effect: " + Time.timeSinceLevelLoad.ToString() + " " + Links.x.gameplay.seconds.ToString());
						}
						this.Remove();
						return;
					}
				}
				else if (this.summonAmount > 0 && !this.isInstrument && this.creatures.Count == 0 && this.currentlySummoned > 0 && !this.isFaunaCreature)
				{
					this.Remove();
					return;
				}
			}
			else if (this.isInstrument && this.effect._Name.Contains("Summon"))
			{
				int num = 0;
				for (int j = 0; j < this.creatures.Count; j++)
				{
					if (this.creatures[j])
					{
						Character firstCharacter = this.creatures[j].GetFirstCharacter();
						if (firstCharacter && firstCharacter.IsSentient())
						{
							int num2 = 0;
							if (firstCharacter.actions && firstCharacter.actions.ai)
							{
								num2 = firstCharacter.actions.ai.GetSeenCount();
							}
							if (firstCharacter.stats.attackCount >= this.attacksAllowed || (Links.x.gameplay.seconds > this.effectStartTime + 20f && num2 == 0))
							{
								this.RemoveSummons(this.creatures[j], this.creatures[j].GetPoint());
								num++;
							}
						}
					}
				}
				if (Links.x.gaia.waitingToRemoveScene || (this.creatures.Count == 0 && num > 0))
				{
					this.Remove();
				}
			}
		}
	}

	// Token: 0x06000AEB RID: 2795 RVA: 0x000D8626 File Offset: 0x000D6826
	public string GetEffectName()
	{
		if (this.hasAbility)
		{
			return this.ability._Name;
		}
		return this.effect._Name;
	}

	// Token: 0x06000AEC RID: 2796 RVA: 0x000D8648 File Offset: 0x000D6848
	public void CheckTileBreakable(GraphNode n, BreakableActions breakable)
	{
		int count = this.allTiles.Count;
		Vector3 position = breakable.gameObject.transform.position;
		Vector3 vector = Vector3.zero;
		for (int i = 0; i < count; i++)
		{
			vector = (Vector3)this.allTiles[i].position;
			float num = vector.x - position.x;
			if (num < 0f)
			{
				num *= -1f;
			}
			if (num < this.tileRadius)
			{
				float num2 = vector.z - position.z;
				if (num2 < 0f)
				{
					num2 *= -1f;
				}
				if (num2 < this.tileRadius)
				{
					breakable.ClickToBreak(null, false, false);
					return;
				}
			}
		}
	}

	// Token: 0x06000AED RID: 2797 RVA: 0x000D8700 File Offset: 0x000D6900
	public void Recast()
	{
		this.resistedCharacters.Clear();
		this.resistedCharacterNodePosition.Clear();
	}

	// Token: 0x06000AEE RID: 2798 RVA: 0x000D8718 File Offset: 0x000D6918
	public void RemoveCharacterEffect(Character target, Effects eff)
	{
		if (this.effect._IsSong && !this.effect._IsBuff)
		{
			return;
		}
		int num = -1;
		int count = this.affectedCharacters.Count;
		for (int i = 0; i < count; i++)
		{
			if ((this.affectedCharacters[i] == target && eff == this.affectedCharacterEffects[i]) || !this.affectedCharacterEffects[i])
			{
				num = i;
			}
		}
		if (num > -1)
		{
			this.affectedCharacters.RemoveAt(num);
			this.affectedCharacterEffects.RemoveAt(num);
			this.affectedPotency.RemoveAt(num);
		}
		if (Records.x.effectsDebugging)
		{
			Debug.Log("removing " + ((target != null) ? target.ToString() : null));
		}
		this.resistedCharacters.Add(target);
		if (target.tr)
		{
			this.resistedCharacterNodePosition.Add(target.tr.position);
			return;
		}
		this.resistedCharacterNodePosition.Add(Vector3.zero);
	}

	// Token: 0x06000AEF RID: 2799 RVA: 0x000D8828 File Offset: 0x000D6A28
	public void CheckTileInteractive(GameObject t)
	{
		if (!this.effect._ShowInStatus)
		{
			return;
		}
		if (this.removing || this.waitingToRemove)
		{
			return;
		}
		if (this.effect._Health != 0f)
		{
			if (this.singleTargetInteractive)
			{
				if (this.effectTiles[0] != null)
				{
					this.RollForEffect(this.effectTiles[0], (Vector3)this.effectTiles[0].position, this.effectTiles[0], null, t, 3f);
					return;
				}
			}
			else
			{
				this.breakableTarget = t.GetComponent<BreakableActions>();
				this.chestTarget = t.GetComponent<ChestActions>();
				this.doorTarget = t.GetComponent<DoorActions>();
				GraphNode graphNode = null;
				if (this.breakableTarget && this.breakableTarget.node != null)
				{
					graphNode = this.breakableTarget.node;
				}
				if (this.chestTarget && this.chestTarget.node != null)
				{
					graphNode = this.chestTarget.node;
				}
				if (this.doorTarget && this.doorTarget.node != null)
				{
					graphNode = this.doorTarget.node;
				}
				if (graphNode == null)
				{
					NNConstraint nnconstraint = new NNConstraint();
					nnconstraint.constrainWalkability = true;
					nnconstraint.walkable = true;
					nnconstraint.constrainPenalty = 0;
					nnconstraint.constrainTags = false;
					nnconstraint.checkCircleID = 0;
					nnconstraint.passID = 0;
					nnconstraint.passID2 = 0;
					nnconstraint.checkConnections = 0;
					nnconstraint.constrainToArea = -1;
					graphNode = AstarPath.active.GetNearest(t.transform.position, nnconstraint).node;
					if (this.breakableTarget)
					{
						this.breakableTarget.node = graphNode;
					}
					if (this.chestTarget)
					{
						this.chestTarget.node = graphNode;
					}
					if (this.doorTarget)
					{
						this.doorTarget.node = graphNode;
					}
				}
				int count = this.effectTiles.Count;
				bool flag = false;
				for (int i = 0; i < count; i++)
				{
					if (!flag)
					{
						if (this.effectTiles[0] != null)
						{
							flag = this.RollForEffect(this.effectTiles[0], (Vector3)this.effectTiles[0].position, graphNode, null, t, 3f);
						}
						if (flag)
						{
							break;
						}
					}
				}
			}
		}
	}

	// Token: 0x06000AF0 RID: 2800 RVA: 0x000D8A74 File Offset: 0x000D6C74
	public bool CheckTile(GraphNode targetTile, Character target, bool reRoll)
	{
		if (!this.effect._ShowInStatus)
		{
			return false;
		}
		if (target.isBoro)
		{
			return false;
		}
		if (target.stunned || target.dead)
		{
			return false;
		}
		if (this.removing || this.waitingToRemove)
		{
			return false;
		}
		if (Links.x.combat.inRally || Links.x.combat.inPocketAttack)
		{
			return false;
		}
		if (this.isPoison && target.stats.isFishMonster)
		{
			return false;
		}
		if (this.isInstrument && this.pooledEffects.Count == 0)
		{
			return false;
		}
		bool flag = true;
		if (this.hasAbility)
		{
			int num = this.affectedCharacters.IndexOf(target);
			if (num > -1 && num < this.affectedCharacterEffects.Count)
			{
				if (this.affectedCharacterEffects[num] != null)
				{
					flag = false;
				}
				else
				{
					this.affectedCharacters.RemoveAt(num);
					this.affectedCharacterEffects.RemoveAt(num);
					this.affectedPotency.RemoveAt(num);
					if (Records.x.effectsDebugging)
					{
						Debug.Log("removing " + ((target != null) ? target.ToString() : null));
					}
				}
			}
		}
		if (!reRoll)
		{
			int num2 = this.resistedCharacters.IndexOf(target);
			if (num2 > -1)
			{
				if (this.isInstrument)
				{
					flag = false;
				}
				else if ((this.resistedCharacterNodePosition[num2] - target.tr.position).sqrMagnitude < Records.x.nodeSize * Records.x.nodeSize)
				{
					flag = false;
				}
				else
				{
					this.resistedCharacterNodePosition.RemoveAt(num2);
					this.resistedCharacters.RemoveAt(num2);
				}
			}
		}
		if (this.customTileAI && target == this.source)
		{
			flag = false;
		}
		if (this.hasAbility)
		{
			int targetsFaction = this.ability._TargetsFaction;
			if (this.source && !this.isSingleTarget)
			{
				if (targetsFaction == 3)
				{
					if (this.source.vipFollow)
					{
						if (target.npc && target.hostility > 1)
						{
							flag = false;
						}
					}
					else if ((!target.npc || !this.source.npc || this.source.stats.IsTargetAnEnemy(target.stats.allegiance)) && (target.npc || this.source.npc))
					{
						flag = false;
					}
				}
				else if (targetsFaction == 1)
				{
					if (target != this.source)
					{
						flag = false;
					}
				}
				else if (targetsFaction == 8 || targetsFaction == 5 || targetsFaction == 4)
				{
					if (this.source.vipFollow)
					{
						if (!target.npc || target.hostility <= 1)
						{
							flag = false;
						}
					}
					else if ((target.npc && this.source.npc) || (!target.npc && !this.source.npc && !this.source.stats.IsTargetAnEnemy(target.stats.allegiance)))
					{
						flag = false;
					}
				}
				if (!this.isInstrument && (target.stats.flying || target.stats.Floating() > 0))
				{
					bool flag2 = true;
					if (this.hasAbility && !this.ability._OnGround)
					{
						flag2 = false;
					}
					if (!flag2)
					{
						flag = false;
					}
				}
			}
			else
			{
				flag = true;
			}
		}
		int count = this.effectTiles.Count;
		bool flag3 = false;
		bool flag4 = false;
		float num3 = this.tileRadius + target.attackRadius;
		if (!this.effect._CanStack && target)
		{
			if (target.stats.HasEffect(this.effect._Name))
			{
				flag = false;
			}
		}
		if (flag)
		{
			if (this.isFaunaCreature && this.faunas != null)
			{
				int count2 = this.faunas.Count;
			}
			for (int i = 0; i < count; i++)
			{
				if (!flag3)
				{
					if (this.doWave && this.pooledEffects[i] && !this.pooledEffects[i].activeSelf)
					{
						this.hasTile[i] = false;
					}
					if (this.hasTile[i])
					{
						GraphNode graphNode = this.effectTiles[i];
						if (this.isFaunaCreature)
						{
							if (this.faunas != null)
							{
								if (this.faunas[i])
								{
									graphNode = this.faunas[i].node;
								}
								else
								{
									graphNode = null;
								}
							}
							else
							{
								graphNode = null;
							}
						}
						if (graphNode != null)
						{
							Vector3 vector = (Vector3)graphNode.position;
							if (this.isFaunaCreature)
							{
								vector = this.faunas[i].tr.position;
							}
							flag3 = this.RollForEffect(graphNode, vector, targetTile, target, null, num3);
							if (Records.x.effectsDebugging)
							{
								Debug.Log(string.Concat(new string[]
								{
									(target != null) ? target.ToString() : null,
									" on tile ",
									i.ToString(),
									" ",
									flag3.ToString(),
									" ",
									num3.ToString()
								}));
							}
							if (flag3)
							{
								break;
							}
						}
					}
				}
			}
			if (!flag3)
			{
				flag4 = true;
			}
		}
		if (Records.x.effectsDebugging)
		{
			Debug.Log(string.Concat(new string[]
			{
				"can roll ",
				(target != null) ? target.ToString() : null,
				" ",
				flag4.ToString(),
				" ",
				((Vector3)targetTile.position).ToString(),
				" ",
				flag.ToString(),
				" ",
				flag3.ToString()
			}));
		}
		if (!flag && this.effect._WhileOnTile && !this.isFaunaCreature)
		{
			bool flag5 = true;
			int count3 = this.allTiles.Count;
			for (int j = 0; j < count3; j++)
			{
				if (flag5 && this.allTiles[j] != null && this.InTileRange((Vector3)this.allTiles[j].position, targetTile, target, num3, j))
				{
					flag5 = false;
				}
			}
			if (flag5)
			{
				flag4 = true;
			}
		}
		if (!flag3 && this.effect._WhileOnTile && flag4)
		{
			int num4 = this.affectedCharacters.IndexOf(target);
			if (num4 > -1)
			{
				target.stats.RemoveTileEffect(this.affectedCharacterEffects[num4]);
				if (num4 > -1 && num4 < this.affectedCharacterEffects.Count)
				{
					this.affectedCharacterEffects.RemoveAt(num4);
				}
				if (num4 > -1 && num4 < this.affectedPotency.Count)
				{
					this.affectedPotency.RemoveAt(num4);
				}
				if (num4 > -1 && num4 < this.affectedCharacters.Count)
				{
					this.affectedCharacters.RemoveAt(num4);
				}
				if (Records.x.effectsDebugging)
				{
					Debug.Log("removing " + ((target != null) ? target.ToString() : null));
				}
			}
		}
		return flag3;
	}

	// Token: 0x06000AF1 RID: 2801 RVA: 0x000D918C File Offset: 0x000D738C
	public bool InTileRange(Vector3 effectTile, GraphNode targetTile, Character target, float distance, int i)
	{
		if (!this.effect._ShowInStatus)
		{
			return false;
		}
		if (this.isSingleTarget && target == this.singleTarget)
		{
			return true;
		}
		bool flag = false;
		float num = target.radius;
		if (this.InEffectRadius(target.currentPosition, effectTile, distance))
		{
			flag = true;
		}
		return flag;
	}

	// Token: 0x06000AF2 RID: 2802 RVA: 0x000D91E0 File Offset: 0x000D73E0
	private bool InEffectRadius(Vector3 targetPosition, Vector3 effectTile, float distance)
	{
		Vector3 zero = Vector3.zero;
		float num = effectTile.x - targetPosition.x;
		if (num < 0f)
		{
			num *= -1f;
		}
		if (num < distance)
		{
			float num2 = effectTile.z - targetPosition.z;
			if (num2 < 0f)
			{
				num2 *= -1f;
			}
			if (num2 < distance)
			{
				return true;
			}
		}
		return false;
	}

	// Token: 0x06000AF3 RID: 2803 RVA: 0x000D923C File Offset: 0x000D743C
	public bool RollForEffect(GraphNode effectTile, Vector3 effectPosition, GraphNode targetTile, Character target, GameObject targetInteractive, float distance)
	{
		if (!this.effect._ShowInStatus)
		{
			return false;
		}
		bool flag = false;
		if (target)
		{
			if (this.InEffectRadius(target.tr.position, effectPosition, distance))
			{
				flag = true;
			}
		}
		else if (this.InEffectRadius(targetInteractive.transform.position, effectPosition, distance))
		{
			flag = true;
		}
		bool flag2 = false;
		if (targetInteractive)
		{
			this.breakableTarget = targetInteractive.GetComponent<BreakableActions>();
			this.chestTarget = targetInteractive.GetComponent<ChestActions>();
			this.doorTarget = targetInteractive.GetComponent<DoorActions>();
			flag2 = true;
			if (this.isInstrument)
			{
				flag = false;
			}
			if (this.singleTargetInteractive && targetInteractive == this.singleTargetInteractive)
			{
				flag = true;
			}
		}
		if (this.isSingleTarget && this.singleTarget == target)
		{
			flag = true;
		}
		if (flag)
		{
			bool flag3 = true;
			if (this.isFaunaCreature)
			{
				flag3 = false;
				for (int i = 0; i < this.faunas.Count; i++)
				{
					if (this.faunas[i] && this.faunas[i].node == effectTile)
					{
						flag3 = true;
						this.faunas[i].Collide();
						this.faunas[i] = null;
						break;
					}
				}
			}
			if (!flag3)
			{
				return false;
			}
			if (Records.x.effectsDebugging)
			{
				Debug.Log(string.Concat(new string[]
				{
					(target != null) ? target.ToString() : null,
					" is on ",
					flag.ToString(),
					" ",
					Vector3.Distance((Vector3)effectTile.position, target.tr.position).ToString()
				}));
			}
			if (this.hasAbility)
			{
				float num = this.sourceLevel;
				float num2 = 0f;
				string text = "";
				string text2 = "";
				string text3 = "";
				string text4 = "";
				if (this.ability._IsSpell)
				{
					if (this.doSpellScroll || this.fromEnchantedItem)
					{
						num2 = Mathf.Round(this.severity + this.tether);
						text2 = this.source.stats.PaganPowerCalculation(false, this.tether, true);
					}
					else
					{
						num2 = Mathf.Round(this.source.stats.PaganPower(this.tether, false));
						text2 = this.source.stats.PaganPowerCalculation(false, this.tether, false);
					}
					if (this.customTileAI)
					{
						num2 = 1f;
						text2 = "";
						num = (float)this.source.stats.level;
					}
					if (!this.fromEnchantedItem && !this.doSpellScroll)
					{
						text3 = this.source.stats.GetAbilitySpellName(this.spellIndex);
					}
					else
					{
						text3 = this.ability._DisplayName;
					}
					text4 = this.ability._MainSkill;
				}
				else if (this.isInstrument)
				{
					float num3 = 0f;
					float num4 = Records.x.SongSkillMultiplier(this.sourceLevel);
					num2 = Mathf.Round(this.source.stats.InstrumentPower(this.severity, this.ability._WeaponReq, false, out num3));
					text2 = this.source.stats.InstrumentPowerCalculation(false, this.ability._WeaponReq, num3, true, this.sourceLevel, this.ability._WeaponReq);
					num = Mathf.Round(num4 * 10f) / 10f;
					if (!target.npc && this.ability._WeaponReq == "Flute")
					{
						Effects existingEffect = target.stats.GetExistingEffect("ChoraFluteBuff");
						if (existingEffect)
						{
							num += existingEffect.sourceLevel;
						}
					}
				}
				float num5 = 0f;
				float num6 = 0f;
				if (!this.effect._IsBuff && !flag2)
				{
					if (!this.isInstrument)
					{
						float num7 = 0f;
						num5 = Mathf.Round(target.stats.PaganResistance(false, text4, out num7, out num6));
						text = target.stats.PaganResistCalculation(false, num7, text4);
						if (this.customTileAI)
						{
							num5 = 0f;
							num6 = 0f;
							text = "";
						}
					}
					else
					{
						float num8 = 0f;
						num5 = (float)this.GetInstrumentResistRoll(target, out num8);
						text = target.stats.InstrumentResistCalculation(false, num8);
					}
					if (Records.x.miniGame)
					{
						num6 = 0f;
					}
				}
				else if (this.effect._IsBuff && !flag2)
				{
					num5 = 0f;
				}
				if (Records.x.showRuleset && target)
				{
					if (!this.isInstrument)
					{
						if (!this.effect._IsBuff)
						{
							Debug.Log(string.Concat(new string[]
							{
								target.stats.GetName(),
								"'s resistance to ",
								this.ability._DisplayName,
								" (",
								text3,
								") ",
								num5.ToString(),
								" vs. potency: ",
								num2.ToString()
							}));
						}
						else
						{
							Debug.Log(string.Concat(new string[]
							{
								target.stats.GetName(),
								"'s gets buff from ",
								this.ability._DisplayName,
								" (",
								text3,
								"), potency is: ",
								num2.ToString()
							}));
						}
					}
					else if (!this.effect._IsBuff)
					{
						Debug.Log(string.Concat(new string[]
						{
							target.stats.GetName(),
							"'s resistance to ",
							this.ability._DisplayName,
							", resist: ",
							num5.ToString(),
							" vs. potency: ",
							num2.ToString()
						}));
					}
					else
					{
						Debug.Log(string.Concat(new string[]
						{
							target.stats.GetName(),
							"'s gets buff from ",
							this.ability._DisplayName,
							", potency is: ",
							num2.ToString()
						}));
					}
				}
				if (num2 > num5 || this.effect._IsBuff)
				{
					float num9 = 0f;
					flag = true;
					string text5 = "";
					if (this.ability == null)
					{
						text5 = this.AddEffect(this.effect._Name, target, targetInteractive, num, true, num);
					}
					else if (this.isInstrument)
					{
						text5 = this.AddEffect(this.ability._Name, target, targetInteractive, num, true, num);
					}
					else if (this.ability._IsSpell)
					{
						num9 = 1f - num5 / num2 * 0.75f;
						num9 *= 1f - num6 / 10f;
						if (Records.x.showRuleset)
						{
							Debug.Log(string.Concat(new string[]
							{
								target.stats.GetName(),
								"'s spell potency reduction for ",
								this.ability._DisplayName,
								" was ",
								num9.ToString(),
								", source level was ",
								num.ToString()
							}));
						}
						if (!this.effect._IsBuff)
						{
							num *= num9;
						}
						text5 = this.AddEffect(this.ability._Name, target, targetInteractive, num, true, num);
					}
					if (this.isInstrument)
					{
						this.source.stats.AddSkillProgress(this.source.stats.GetCombatSkillID(this.mainSkill), (float)target.combatLevel / 5f, target);
					}
					else
					{
						float num10 = 0f;
						if (flag2)
						{
							if (this.chestTarget)
							{
								num10 = (float)this.chestTarget.chest.health / 10f;
							}
							else if (this.doorTarget)
							{
								num10 = (float)this.doorTarget.door.health / 10f;
							}
							else if (this.breakableTarget)
							{
								num10 = (float)this.breakableTarget.breakable.health / 10f;
							}
						}
						else
						{
							num10 = (float)target.combatLevel / 5f;
						}
						this.source.stats.AddSkillProgress(this.source.stats.GetCombatSkillID(this.mainSkill), num10, target);
					}
					if (flag2)
					{
						if (this.effect._Sound != "" && !this.isInstrument)
						{
							MasterAudio.PlaySound3DAtVector3AndForget(this.effect._Sound, targetInteractive.transform.position, 0.8f, new float?(1f), 0f, "", null);
						}
					}
					else if (this.effect._Sound != "" && !this.isInstrument)
					{
						MasterAudio.PlaySound3DAtVector3AndForget(this.effect._Sound, target.tr.position, 0.8f, new float?(1f), 0f, "", null);
					}
					if (!this.effect._IsBuff)
					{
						this.str.Clear();
						if (!flag2)
						{
							if (!target.npc)
							{
								this.str.Append(Links.x.gameFeed.GetPartyColorText(target));
							}
							this.str.Append(target.stats.GetName());
							if (!target.npc)
							{
								this.str.Append("</color>");
							}
						}
						else
						{
							if (this.chestTarget)
							{
								this.str.Append("Chest");
							}
							if (this.doorTarget)
							{
								this.str.Append("Door");
							}
							if (this.breakableTarget)
							{
								this.str.Append("Breakable");
							}
						}
						this.str.Append(": ");
						if (this.ability._IsSpell)
						{
							this.str.Append(text3);
						}
						else
						{
							this.str.Append(this.ability._DisplayName);
						}
						if (num > 0f)
						{
							this.str.Append(" level ");
							this.str.Append(Mathf.Round(num * 10f) / 10f);
							if (this.ability._IsSpell && !flag2 && Records.x.showRulesetInfo && text2 != "")
							{
								this.str.Append(" <color #857C6C> (Resist reduction: ");
								this.str.Append(Mathf.Round((1f - num9) * 10f) / 10f * 100f);
								this.str.Append("%)</color>");
							}
						}
						if (text5 != "")
						{
							this.str.Append(", ");
							this.str.Append(text5);
						}
						if (Records.x.showRulesetInfo && text2 != "")
						{
							this.str.Append(" <color #857C6C>... ");
							if (!flag2)
							{
								this.str.Append(text2);
								this.str.Append(" vs. ");
								this.str.Append(text);
							}
							else
							{
								this.str.Append(text2);
							}
							this.str.Append("</color>");
						}
						if (!Records.x.miniGame)
						{
							Links.x.gameFeed.AddFeed(this.str.ToString());
						}
					}
					else
					{
						this.str.Clear();
						if (!flag2)
						{
							if (!target.npc)
							{
								this.str.Append(Links.x.gameFeed.GetPartyColorText(target));
							}
							this.str.Append(target.stats.GetName());
							if (!target.npc)
							{
								this.str.Append("</color>");
							}
						}
						else
						{
							if (this.chestTarget)
							{
								this.str.Append("Chest");
							}
							if (this.doorTarget)
							{
								this.str.Append("Door");
							}
							if (this.breakableTarget)
							{
								this.str.Append(this.breakableTarget.breakable.type.ToString());
							}
						}
						this.str.Append(": ");
						if (this.ability._IsSpell)
						{
							this.str.Append(text3);
						}
						else
						{
							this.str.Append(this.ability._DisplayName);
						}
						if (num > 0f)
						{
							this.str.Append(" level ");
							this.str.Append(Mathf.Round(num * 10f) / 10f);
						}
						if (text5 != "")
						{
							this.str.Append(", ");
							this.str.Append(text5);
						}
						if (Records.x.showRulesetInfo && text2 != "")
						{
							this.str.Append(" <color #857C6C>... ");
							this.str.Append(text2);
							this.str.Append("</color>");
						}
						if (!Records.x.miniGame)
						{
							Links.x.gameFeed.AddFeed(this.str.ToString());
						}
					}
				}
				else
				{
					flag = false;
					if (!this.resistedCharacters.Contains(target) || flag2)
					{
						if (!flag2)
						{
							this.resistedCharacters.Add(target);
							this.resistedCharacterNodePosition.Add(target.tr.position);
						}
						if (target)
						{
							GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(86);
							pooledGameObject.transform.position = target.body.HeadPosition(0.5f);
							pooledGameObject.SetActive(true);
						}
						this.str.Clear();
						if (!flag2)
						{
							if (!target.npc)
							{
								this.str.Append(Links.x.gameFeed.GetPartyColorText(target));
							}
							this.str.Append(target.stats.GetName());
							if (!target.npc)
							{
								this.str.Append("</color>");
							}
						}
						else
						{
							if (this.chestTarget)
							{
								this.str.Append("Chest");
							}
							if (this.doorTarget)
							{
								this.str.Append("Door");
							}
							if (this.breakableTarget)
							{
								this.str.Append("Breakable");
							}
						}
						this.str.Append(" blocked ");
						this.str.Append(this.ability._DisplayName);
						if (Records.x.showRulesetInfo && text2 != "")
						{
							this.str.Append(" <color #857C6C>... ");
							if (!flag2)
							{
								this.str.Append(text2);
								this.str.Append(" vs. ");
								this.str.Append(text);
							}
							else
							{
								this.str.Append(text2);
							}
							this.str.Append("</color>");
						}
						Links.x.gameFeed.AddFeed(this.str.ToString());
					}
				}
			}
			else
			{
				int num11 = 0;
				float num12 = 0f;
				if (!flag2 && !(this.effect._StatToResist == "Spore"))
				{
					int num13;
					num11 = Mathf.RoundToInt(target.stats.Stat(this.effect._StatToResist, true, out num13));
					if (num11 < 0)
					{
						num11 = 0;
					}
				}
				int num14 = Random.Range(1, num11 + 1);
				if (!flag2)
				{
					num12 = Mathf.Round(target.stats.Balance() + (float)num14);
				}
				string text6 = target.stats.BalanceResist((float)num14, this.effect._StatToResist);
				if (num11 == 0)
				{
				}
				float num15 = Mathf.Round((float)this.effect._BalanceCheck);
				string text7 = target.stats.BalanceCheck(Mathf.Round((float)this.effect._BalanceCheck));
				if (Records.x.showRuleset)
				{
					if (!this.effect._IsBuff)
					{
						Debug.Log(string.Concat(new string[]
						{
							target.stats.GetName(),
							"'s resistance to ",
							this.effect._DisplayName,
							", resist: ",
							num12.ToString(),
							" vs. potency: ",
							this.effect._BalanceCheck.ToString(),
							", balance: ",
							target.stats.Balance().ToString(),
							", ",
							this.effect._StatToResist,
							": ",
							num11.ToString()
						}));
					}
					else
					{
						Debug.Log(string.Concat(new string[]
						{
							target.stats.GetName(),
							"'s gets buff from ",
							this.effect._DisplayName,
							", potency is: ",
							this.effect._BalanceCheck.ToString()
						}));
					}
				}
				bool flag4 = false;
				bool flag5 = false;
				if (this.effect._StatToResist == "Spore")
				{
					if (target.stats.xmlName.Contains("Spore"))
					{
						flag4 = true;
					}
					else
					{
						flag5 = true;
					}
				}
				if (!flag5 && (num15 >= num12 || this.effect._IsBuff || flag4))
				{
					flag = true;
					string text8;
					if (this.ability == null)
					{
						text8 = this.AddEffect(this.effect._Name, target, targetInteractive, 0f, true, this.sourceLevel);
					}
					else
					{
						text8 = this.AddEffect(this.ability._Name, target, targetInteractive, 0f, true, this.sourceLevel);
					}
					if (this.effect._RemoveOnHit)
					{
						int num16 = this.effectTiles.IndexOf(effectTile);
						if (num16 > -1)
						{
							if (this.pooledEffects[num16])
							{
								Links.x.cellar.ReturnPooledGameObject(this.fx, this.pooledEffects[num16]);
							}
							this.pooledEffects[num16] = null;
							this.effectTiles[num16] = null;
							this.hasTile[num16] = false;
						}
					}
					this.str.Clear();
					if (!flag2)
					{
						if (!target.npc)
						{
							this.str.Append(Links.x.gameFeed.GetPartyColorText(target));
						}
						this.str.Append(target.stats.GetName());
						if (!target.npc)
						{
							this.str.Append("</color>");
						}
					}
					else
					{
						if (this.chestTarget)
						{
							this.str.Append("Chest");
						}
						if (this.doorTarget)
						{
							this.str.Append("Door");
						}
						if (this.breakableTarget)
						{
							this.str.Append(this.breakableTarget.breakable.type.ToString());
						}
					}
					this.str.Append(": ");
					this.str.Append(this.effect._DisplayName);
					if (text8 != "")
					{
						this.str.Append(", ");
						this.str.Append(text8);
					}
					if (!this.effect._IsBuff && !flag4 && Records.x.showRulesetInfo)
					{
						this.str.Append(" <color #857C6C>... ");
						if (!flag2)
						{
							this.str.Append(text7);
							this.str.Append(" vs. ");
							this.str.Append(text6);
						}
						else
						{
							this.str.Append(text7);
						}
						this.str.Append("</color>");
					}
					Links.x.gameFeed.AddFeed(this.str.ToString());
					if (!this.hasAbility && this.effect._Sound != "" && !this.isInstrument)
					{
						MasterAudio.PlaySound3DAtVector3AndForget(this.effect._Sound, target.tr.position, 0.8f, new float?(1f), 0f, "", null);
					}
				}
				else
				{
					flag = false;
					if (!this.resistedCharacters.Contains(target) || flag2)
					{
						if (!flag2)
						{
							this.resistedCharacters.Add(target);
							this.resistedCharacterNodePosition.Add(target.tr.position);
						}
						if (target)
						{
							GameObject pooledGameObject2 = Links.x.cellar.GetPooledGameObject(86);
							pooledGameObject2.transform.position = target.body.HeadPosition(0.5f);
							pooledGameObject2.SetActive(true);
						}
						this.str.Clear();
						if (!flag2)
						{
							if (!target.npc)
							{
								this.str.Append(Links.x.gameFeed.GetPartyColorText(target));
							}
							this.str.Append(target.stats.GetName());
							if (!target.npc)
							{
								this.str.Append("</color>");
							}
						}
						else
						{
							if (this.chestTarget)
							{
								this.str.Append("Chest");
							}
							if (this.doorTarget)
							{
								this.str.Append("Door");
							}
							if (this.breakableTarget)
							{
								this.str.Append("Breakable");
							}
						}
						this.str.Append(" evaded ");
						this.str.Append(this.effect._DisplayName);
						if (Records.x.showRulesetInfo)
						{
							this.str.Append(" <color #857C6C>... ");
							if (!flag2)
							{
								this.str.Append(text7);
								this.str.Append(" vs. ");
								this.str.Append(num12);
							}
							else
							{
								this.str.Append(text7);
							}
							this.str.Append("</color>");
						}
						Links.x.gameFeed.AddFeed(this.str.ToString());
					}
				}
			}
		}
		return flag;
	}

	// Token: 0x06000AF4 RID: 2804 RVA: 0x000DA970 File Offset: 0x000D8B70
	private int GetInstrumentResistRoll(Character target, out float luck)
	{
		luck = 0f;
		return (int)Mathf.Ceil(target.stats.InstrumentResistance(false, out luck));
	}

	// Token: 0x06000AF5 RID: 2805 RVA: 0x000DA98C File Offset: 0x000D8B8C
	public string AddEffect(string abilityName, Character target, GameObject targetInteractive, float potency, bool addToList, float lvl)
	{
		if (!this.effect._CanStack && target && target.stats.HasEffect(this.effect._Name))
		{
			return null;
		}
		Effects effects;
		if (target)
		{
			effects = target.gameObject.AddComponent<Effects>();
		}
		else
		{
			effects = targetInteractive.AddComponent<Effects>();
		}
		Links.x.cellar.AddEffects(effects);
		effects.gameObject.SetActive(true);
		effects.source = this.source;
		effects.target = target;
		effects.targetInteractive = targetInteractive;
		effects.fromLoad = false;
		effects.effectName = this.GetEffectName();
		effects.removeAtSceneSwitch = true;
		effects.tileEffect = this;
		effects.sourceLevel = lvl;
		effects.durability = this.sourceDurability;
		effects.overrideDuration = this.effectTileOverrideDuration;
		string text = effects.Inflicted(true);
		if (addToList)
		{
			if (target)
			{
				this.affectedCharacters.Add(target);
				this.affectedCharacterEffects.Add(effects);
				this.affectedPotency.Add(potency);
			}
			else
			{
				this.affectedObjects.Add(targetInteractive);
				this.affectedObjectsEffects.Add(effects);
			}
		}
		if (this.hasAbility && this.source && target && this.singleTarget == target && !this.effect._IsBuff && !this.source.dead && !this.source.stunned && !target.dead && !target.stunned)
		{
			Links.x.sensory.AddPlayerFromDamage(target, this.source);
		}
		return text;
	}

	// Token: 0x06000AF6 RID: 2806 RVA: 0x000DAB28 File Offset: 0x000D8D28
	private bool IsInstrument(string type)
	{
		return type == "Flute" || type == "Pipe" || type == "Drum" || type == "Horn";
	}

	// Token: 0x04000F70 RID: 3952
	public List<GraphNode> effectTiles = new List<GraphNode>();

	// Token: 0x04000F71 RID: 3953
	public List<GraphNode> allTiles = new List<GraphNode>();

	// Token: 0x04000F72 RID: 3954
	public List<bool> hasTile = new List<bool>();

	// Token: 0x04000F73 RID: 3955
	public bool ready;

	// Token: 0x04000F74 RID: 3956
	public float influenceRadius;

	// Token: 0x04000F75 RID: 3957
	public float radius;

	// Token: 0x04000F76 RID: 3958
	public float timeToWait;

	// Token: 0x04000F77 RID: 3959
	public float effectStartTime;

	// Token: 0x04000F78 RID: 3960
	public float spellDuration;

	// Token: 0x04000F79 RID: 3961
	public float currentTime;

	// Token: 0x04000F7A RID: 3962
	public int turnsToWait;

	// Token: 0x04000F7B RID: 3963
	public int targetCount;

	// Token: 0x04000F7C RID: 3964
	public float severity;

	// Token: 0x04000F7D RID: 3965
	public float tether;

	// Token: 0x04000F7E RID: 3966
	public int spellIndex;

	// Token: 0x04000F7F RID: 3967
	public List<Character> affectedCharacters = new List<Character>();

	// Token: 0x04000F80 RID: 3968
	public List<GameObject> affectedObjects = new List<GameObject>();

	// Token: 0x04000F81 RID: 3969
	public List<Character> resistedCharacters = new List<Character>();

	// Token: 0x04000F82 RID: 3970
	public List<Vector3> resistedCharacterNodePosition = new List<Vector3>();

	// Token: 0x04000F83 RID: 3971
	public string mainSkill;

	// Token: 0x04000F84 RID: 3972
	public string itemInfo;

	// Token: 0x04000F85 RID: 3973
	public Library.Pagan paganRow;

	// Token: 0x04000F86 RID: 3974
	public Character singleTarget;

	// Token: 0x04000F87 RID: 3975
	public bool isSingleTarget;

	// Token: 0x04000F88 RID: 3976
	public Library.Inventory spellScroll;

	// Token: 0x04000F89 RID: 3977
	private bool isSummons;

	// Token: 0x04000F8A RID: 3978
	public List<Fauna> faunas;

	// Token: 0x04000F8B RID: 3979
	public bool isWall;

	// Token: 0x04000F8C RID: 3980
	public bool setPenalty;

	// Token: 0x04000F8D RID: 3981
	private int waveCount;

	// Token: 0x04000F8E RID: 3982
	private bool doWave;

	// Token: 0x04000F8F RID: 3983
	public bool fromGroup;

	// Token: 0x04000F90 RID: 3984
	public bool needsCreatureSave;

	// Token: 0x04000F91 RID: 3985
	public EnemyGroup group;

	// Token: 0x04000F92 RID: 3986
	public Vector3 mainPosition;

	// Token: 0x04000F93 RID: 3987
	private GraphNode mainNode;

	// Token: 0x04000F94 RID: 3988
	public bool hasAbility;

	// Token: 0x04000F95 RID: 3989
	public Library.Abilities ability;

	// Token: 0x04000F96 RID: 3990
	public Library.Effects effect;

	// Token: 0x04000F97 RID: 3991
	private List<GraphNode> pickedGroundNodesSaved;

	// Token: 0x04000F98 RID: 3992
	public Character source;

	// Token: 0x04000F99 RID: 3993
	public Character spellTarget;

	// Token: 0x04000F9A RID: 3994
	public GameObject singleTargetInteractive;

	// Token: 0x04000F9B RID: 3995
	public List<Effects> affectedCharacterEffects = new List<Effects>();

	// Token: 0x04000F9C RID: 3996
	public List<Effects> affectedObjectsEffects = new List<Effects>();

	// Token: 0x04000F9D RID: 3997
	public List<float> affectedPotency = new List<float>();

	// Token: 0x04000F9E RID: 3998
	public List<GameObject> pooledEffects = new List<GameObject>();

	// Token: 0x04000F9F RID: 3999
	public float sourceLevel;

	// Token: 0x04000FA0 RID: 4000
	public int overallTime;

	// Token: 0x04000FA1 RID: 4001
	public int damage;

	// Token: 0x04000FA2 RID: 4002
	private List<HannahAnimator> animators = new List<HannahAnimator>();

	// Token: 0x04000FA3 RID: 4003
	private StringFast str = new StringFast(64);

	// Token: 0x04000FA4 RID: 4004
	public bool removing;

	// Token: 0x04000FA5 RID: 4005
	private BreakableActions breakable;

	// Token: 0x04000FA6 RID: 4006
	public List<BreakableActions> breakables = new List<BreakableActions>();

	// Token: 0x04000FA7 RID: 4007
	private NNConstraint nodeConstraint = new NNConstraint();

	// Token: 0x04000FA8 RID: 4008
	private List<GraphNode> allNodes;

	// Token: 0x04000FA9 RID: 4009
	public List<CreatureActions> creatures = new List<CreatureActions>();

	// Token: 0x04000FAA RID: 4010
	private int summonAmount;

	// Token: 0x04000FAB RID: 4011
	private int currentlySummoned;

	// Token: 0x04000FAC RID: 4012
	private IEnumerator scatterRoutine;

	// Token: 0x04000FAD RID: 4013
	private IEnumerator removeRoutine;

	// Token: 0x04000FAE RID: 4014
	private bool isInstrument;

	// Token: 0x04000FAF RID: 4015
	private int fx;

	// Token: 0x04000FB0 RID: 4016
	public bool waitingToRemove;

	// Token: 0x04000FB1 RID: 4017
	public bool inScatter;

	// Token: 0x04000FB2 RID: 4018
	private float tileRadius;

	// Token: 0x04000FB3 RID: 4019
	private ChestActions chestTarget;

	// Token: 0x04000FB4 RID: 4020
	private DoorActions doorTarget;

	// Token: 0x04000FB5 RID: 4021
	private BreakableActions breakableTarget;

	// Token: 0x04000FB6 RID: 4022
	public GhostBrush ghostBrush;

	// Token: 0x04000FB7 RID: 4023
	public bool ghostBrushMinor;

	// Token: 0x04000FB8 RID: 4024
	public GraphNode startNode;

	// Token: 0x04000FB9 RID: 4025
	public bool fromEnchantedItem;

	// Token: 0x04000FBA RID: 4026
	public bool doSpellScroll;

	// Token: 0x04000FBB RID: 4027
	public bool isSong;

	// Token: 0x04000FBC RID: 4028
	private bool isFaunaCreature;

	// Token: 0x04000FBD RID: 4029
	private float effectTileOverrideDuration;

	// Token: 0x04000FBE RID: 4030
	private float sourceDurability;

	// Token: 0x04000FBF RID: 4031
	private GameObject centerFX;

	// Token: 0x04000FC0 RID: 4032
	public bool waitingForTargetDeath;

	// Token: 0x04000FC1 RID: 4033
	private GameObject songFX;

	// Token: 0x04000FC2 RID: 4034
	public int lastRollTime;

	// Token: 0x04000FC3 RID: 4035
	private float scatterPassTime;

	// Token: 0x04000FC4 RID: 4036
	private bool customTileAI;

	// Token: 0x04000FC5 RID: 4037
	private bool isPoison;

	// Token: 0x04000FC6 RID: 4038
	private int attacksAllowed = 1;

	// Token: 0x04000FC7 RID: 4039
	private float removeTime;

	// Token: 0x04000FC8 RID: 4040
	private Vector4 spellData;
}
