Decompiled source of After Hours v1.1.10

BepInEx/plugins/AfterHours/AfterHours.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Brendan")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.10.0")]
[assembly: AssemblyInformationalVersion("1.1.10")]
[assembly: AssemblyProduct("AfterHours")]
[assembly: AssemblyTitle("AfterHours")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.10.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AfterHours
{
	public sealed class CreatureDef
	{
		public string id;

		public string name;

		public string color;

		public string mechanic;

		public string counter;

		public int index;

		public int tier;

		public int health;

		public int damage;

		public float speed;

		public float cooldown;

		public float tell;

		public float range;

		public bool meme;

		public GaitDef locomotion;
	}
	public sealed class GaitDef
	{
		public string gait;

		public string feet;

		public string route;

		public float period;

		public float stride;

		public float lift;

		public float bob;

		public float roll;
	}
	public sealed class LimbDef
	{
		public float[] hip;

		public float[] knee;

		public float[] foot;

		public float phase;

		public int side;

		public int slot;

		public string role;
	}
	public sealed class ModelFile
	{
		public string id;

		public PartFile[] parts;
	}
	public sealed class PartFile
	{
		public string name;

		public string anim;

		public string parent;

		public float[] pivot;

		public float[] vertices;

		public float[] color;

		public int[] triangles;

		public float phase;

		public LimbDef limb;

		public bool smooth;

		public bool wheel;

		public float metallic;

		public float roughness;
	}
	internal static class Assets
	{
		public static CreatureDef[] Roster;

		public static string Root;

		private static readonly Dictionary<string, ModelFile> Models = new Dictionary<string, ModelFile>();

		private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>();

		private static readonly Dictionary<string, Mesh> Meshes = new Dictionary<string, Mesh>();

		private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>();

		private static readonly Dictionary<int, Texture2D> WearTextures = new Dictionary<int, Texture2D>();

		public static AudioMixerGroup Mixer;

		public static Vector3 V(float[] v)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(v[0], v[1], v[2]);
		}

		public static void Load(string directory)
		{
			Root = Path.Combine(directory, "assets");
			Roster = JsonConvert.DeserializeObject<CreatureDef[]>(File.ReadAllText(Path.Combine(Root, "catalog.json")));
			if (Roster.Length != 42 || Roster.Select((CreatureDef d) => d.id).Distinct().Count() != Roster.Length)
			{
				throw new InvalidDataException("The After Hours catalog must contain 42 distinct creatures.");
			}
			CreatureDef[] roster = Roster;
			foreach (CreatureDef creatureDef in roster)
			{
				if (creatureDef.index < 0 || creatureDef.index >= Roster.Length || creatureDef.tell < 1f || creatureDef.damage < 0)
				{
					throw new InvalidDataException(creatureDef.id);
				}
				Models.Add(creatureDef.id, JsonConvert.DeserializeObject<ModelFile>(File.ReadAllText(Path.Combine(Root, "models", creatureDef.id + ".json"))));
				string[] array = new string[8] { "idle", "tell", "attack", "hurt", "death", "idle_alt", "attack_alt", "step" };
				foreach (string text in array)
				{
					Clips.Add(creatureDef.id + "_" + text, ReadWave(Path.Combine(Root, "audio", creatureDef.id + "_" + text + ".wav")));
				}
			}
		}

		public static void LoadLoot()
		{
			LootFactory.Definitions = JsonConvert.DeserializeObject<LootDef[]>(File.ReadAllText(Path.Combine(Root, "loot.json")));
			LootDef[] definitions = LootFactory.Definitions;
			foreach (LootDef lootDef in definitions)
			{
				Models.Add("loot_" + lootDef.id, JsonConvert.DeserializeObject<ModelFile>(File.ReadAllText(Path.Combine(Root, "loot-models", lootDef.id + ".json"))));
				string[] array = new string[3] { "idle", "tell", "attack" };
				foreach (string text in array)
				{
					Clips.Add("loot_" + lootDef.id + "_" + text, ReadWave(Path.Combine(Root, "audio", "loot_" + lootDef.id + "_" + text + ".wav")));
				}
			}
		}

		public static AudioClip LootClip(LootDef d, string cue)
		{
			return Clips["loot_" + d.id + "_" + cue];
		}

		public static AudioClip Clip(CreatureDef d, string ev)
		{
			return Clips[d.id + "_" + ev];
		}

		public static Material Material(Color color, bool glow = false, float metallic = 0.08f, float roughness = 0.7f, int pattern = 0)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			pattern = Math.Abs(pattern) % 16;
			string text = ColorUtility.ToHtmlStringRGB(color) + (glow ? "g" : "m") + metallic.ToString("F2") + roughness.ToString("F2") + "p" + pattern;
			if (Materials.TryGetValue(text, out var value))
			{
				return value;
			}
			Shader obj = Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse");
			if (!Object.op_Implicit((Object)(object)obj))
			{
				throw new InvalidOperationException("No compatible surface shader available.");
			}
			value = new Material(obj)
			{
				name = "AH_" + text,
				color = color
			};
			value.SetFloat("_Glossiness", 1f - roughness);
			value.SetFloat("_Metallic", metallic);
			if (!WearTextures.TryGetValue(pattern, out var value2))
			{
				value2 = new Texture2D(128, 128, (TextureFormat)3, true)
				{
					name = "AH worn surface " + pattern,
					wrapMode = (TextureWrapMode)0,
					anisoLevel = 2
				};
				Color[] array = (Color[])(object)new Color[16384];
				for (int i = 0; i < 128; i++)
				{
					for (int j = 0; j < 128; j++)
					{
						float num = (float)pattern * 0.392699f;
						float num2 = Mathf.Cos(num);
						float num3 = Mathf.Sin(num);
						float num4 = ((float)j * num2 - (float)i * num3) * (0.042f + (float)(pattern % 4) * 0.011f) + (float)pattern * 3.1f;
						float num5 = ((float)j * num3 + (float)i * num2) * (0.048f + (float)(pattern % 3) * 0.014f) + (float)pattern * 1.7f;
						float num6 = Mathf.PerlinNoise(num4, num5);
						float num7 = Mathf.PerlinNoise((float)j * 0.31f + (float)pattern, (float)i * 0.27f - (float)pattern);
						float num8 = 0.55f + num6 * 0.31f + num7 * 0.14f;
						if ((j * (13 + pattern) + i * (29 - pattern)) % (101 + pattern * 3) < 1 + pattern % 3)
						{
							num8 *= 0.55f;
						}
						float num9 = (float)(pattern % 5 - 2) * 0.012f;
						array[i * 128 + j] = new Color(num8 * (1f + num9), num8 * 0.985f, num8 * (0.95f - num9));
					}
				}
				value2.SetPixels(array);
				value2.Apply(true, true);
				WearTextures[pattern] = value2;
			}
			value.mainTexture = (Texture)(object)value2;
			value.mainTextureScale = new Vector2(1.15f + (float)(pattern % 4) * 0.27f, 1.05f + (float)(pattern % 3) * 0.31f);
			if (value.HasProperty("_ParallaxMap"))
			{
				value.SetTexture("_ParallaxMap", (Texture)(object)value2);
				value.SetFloat("_Parallax", 0.012f + (float)(pattern % 4) * 0.003f);
				value.EnableKeyword("_PARALLAXMAP");
			}
			if (glow)
			{
				value.EnableKeyword("_EMISSION");
				value.SetColor("_EmissionColor", color * 0.22f);
			}
			Materials[text] = value;
			return value;
		}

		public static GameObject BuildModel(CreatureDef d, Transform parent)
		{
			return BuildModel(d.id, d.index, parent);
		}

		public static GameObject BuildModel(string id, int index, Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("After Hours Visuals");
			val.transform.SetParent(parent, false);
			CreatureRig creatureRig = val.AddComponent<CreatureRig>();
			List<CreatureRig.Node> list = new List<CreatureRig.Node>();
			int num = 0;
			PartFile[] parts = Models[id].parts;
			Vector3 val3 = default(Vector3);
			foreach (PartFile partFile in parts)
			{
				GameObject val2 = new GameObject(partFile.name);
				val2.transform.SetParent(val.transform, false);
				val2.transform.localPosition = V(partFile.pivot);
				string text = id + "/" + partFile.name;
				if (!Meshes.TryGetValue(text, out var value))
				{
					List<Vector3> list2 = new List<Vector3>();
					int[] array = new int[partFile.triangles.Length];
					Dictionary<Vector3, int> dictionary = new Dictionary<Vector3, int>();
					for (int j = 0; j < array.Length; j++)
					{
						int num2 = partFile.triangles[j] * 3;
						((Vector3)(ref val3))..ctor(partFile.vertices[num2], partFile.vertices[num2 + 1], partFile.vertices[num2 + 2]);
						if (!partFile.smooth || !dictionary.TryGetValue(val3, out var value2))
						{
							value2 = list2.Count;
							list2.Add(val3);
							if (partFile.smooth)
							{
								dictionary[val3] = value2;
							}
						}
						array[j] = value2;
					}
					value = new Mesh
					{
						name = text
					};
					value.SetVertices(list2);
					value.triangles = array;
					value.RecalculateNormals();
					value.RecalculateBounds();
					value.uv = ((IEnumerable<Vector3>)list2).Select((Func<Vector3, Vector2>)((Vector3 v) => new Vector2(v.x * 1.7f + v.z * 0.7f, v.y * 1.7f))).ToArray();
					Meshes[text] = value;
				}
				val2.AddComponent<MeshFilter>().sharedMesh = value;
				((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = Material(new Color(partFile.color[0], partFile.color[1], partFile.color[2]), partFile.anim == "pulse" || partFile.anim == "flame", partFile.metallic, partFile.roughness, index * 11 + num++);
				list.Add(new CreatureRig.Node
				{
					transform = val2.transform,
					origin = val2.transform.localPosition,
					animation = partFile.anim,
					phase = partFile.phase,
					limb = partFile.limb,
					wheel = partFile.wheel
				});
			}
			parts = Models[id].parts;
			foreach (PartFile p in parts)
			{
				if (!string.IsNullOrEmpty(p.parent))
				{
					CreatureRig.Node node = list.First((CreatureRig.Node n) => ((Object)n.transform).name == p.name);
					CreatureRig.Node node2 = list.FirstOrDefault((CreatureRig.Node n) => ((Object)n.transform).name == p.parent);
					if (node2 != null)
					{
						node.transform.SetParent(node2.transform, true);
						node.origin = node.transform.localPosition;
					}
				}
			}
			creatureRig.nodes = list.ToArray();
			creatureRig.index = index;
			return val;
		}

		public static Bounds Bounds(CreatureDef d)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Bounds(d.id);
		}

		public static Bounds Bounds(string id)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Bounds result = default(Bounds);
			((Bounds)(ref result))..ctor(Vector3.zero, Vector3.zero);
			PartFile[] parts = Models[id].parts;
			foreach (PartFile partFile in parts)
			{
				for (int j = 0; j < partFile.vertices.Length; j += 3)
				{
					((Bounds)(ref result)).Encapsulate(new Vector3(partFile.vertices[j], partFile.vertices[j + 1], partFile.vertices[j + 2]) + V(partFile.pivot));
				}
			}
			return result;
		}

		internal static AudioClip ReadWave(string path)
		{
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path));
			if (new string(binaryReader.ReadChars(4)) != "RIFF")
			{
				throw new InvalidDataException(path);
			}
			binaryReader.ReadInt32();
			if (new string(binaryReader.ReadChars(4)) != "WAVE")
			{
				throw new InvalidDataException(path);
			}
			int num = 22050;
			int num2 = 1;
			short num3 = 16;
			short num4 = 1;
			byte[] array = null;
			while (binaryReader.BaseStream.Position + 8 <= binaryReader.BaseStream.Length)
			{
				string text = new string(binaryReader.ReadChars(4));
				int num5 = binaryReader.ReadInt32();
				long num6 = binaryReader.BaseStream.Position + num5;
				if (num5 < 0 || num6 > binaryReader.BaseStream.Length)
				{
					throw new InvalidDataException(path);
				}
				if (text == "fmt ")
				{
					num4 = binaryReader.ReadInt16();
					num2 = binaryReader.ReadInt16();
					num = binaryReader.ReadInt32();
					binaryReader.ReadInt32();
					binaryReader.ReadInt16();
					num3 = binaryReader.ReadInt16();
				}
				if (text == "data")
				{
					array = binaryReader.ReadBytes(num5);
				}
				binaryReader.BaseStream.Position = num6 + num5 % 2;
			}
			if (num4 != 1 || num3 != 16 || num2 != 1 || array == null)
			{
				throw new InvalidDataException("Expected mono PCM16: " + path);
			}
			float[] array2 = new float[array.Length / 2];
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i] = (float)BitConverter.ToInt16(array, i * 2) / 32768f;
			}
			AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), array2.Length, 1, num, false);
			obj.SetData(array2, 0);
			return obj;
		}
	}
	public sealed class CreatureRig : MonoBehaviour
	{
		[Serializable]
		public sealed class Node
		{
			public Transform transform;

			public Vector3 origin;

			public string animation;

			public float phase;

			public LimbDef limb;

			public bool smooth;

			public bool wheel;

			public float metallic;

			public float roughness;
		}

		public Node[] nodes;

		public int index;

		public float motion = 1f;

		public float threat;

		internal float strideRate = 1f;

		internal int attackPhase;

		internal float attackTime;

		internal int attackMode;

		internal float attackProgress;

		internal float poseTime;

		public bool preview;

		private float gaitClock;

		private float hurtUntil;

		private int hurtSeed;

		internal int FootfallSerial;

		private Vector3 restPosition;

		private Quaternion restRotation;

		private Vector3 restScale;

		internal void Hurt(int seed)
		{
			hurtSeed = seed;
			hurtUntil = Time.time + 0.42f + (float)(index % 4) * 0.06f;
		}

		private void Start()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			restPosition = ((Component)this).transform.localPosition;
			restRotation = ((Component)this).transform.localRotation;
			restScale = ((Component)this).transform.localScale;
		}

		private void LateUpdate()
		{
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0edb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee0: Unknown result type (might be due to invalid IL or missing references)
			if (nodes == null)
			{
				return;
			}
			float num = (preview ? Time.unscaledTime : Time.time);
			motion = Mathf.Clamp01(motion);
			threat = Mathf.Clamp01(threat);
			AttackPose.Weights(index, attackMode, attackPhase, attackProgress, poseTime, out var draw, out var strike);
			threat = draw;
			GaitDef gaitDef = ((index >= 0 && index < Assets.Roster.Length) ? Assets.Roster[index].locomotion : null);
			float num2 = gaitClock;
			float num3 = ((gaitDef == null || gaitDef.stride <= 0f || gaitDef.gait == "undulate") ? 1f : (gaitDef.period * Assets.Roster[index].speed * ((gaitDef.gait == "scuttle") ? 0.62f : 0.68f) / gaitDef.stride));
			gaitClock += (preview ? Time.unscaledDeltaTime : Time.deltaTime) * Mathf.Max(0f, strideRate) * num3;
			Node[] array;
			if (gaitDef != null && motion > 0.1f)
			{
				array = nodes;
				foreach (Node node in array)
				{
					if (node.limb != null && node.limb.role == "upper" && Mathf.FloorToInt(num2 / gaitDef.period + node.limb.phase) != Mathf.FloorToInt(gaitClock / gaitDef.period + node.limb.phase))
					{
						FootfallSerial++;
						break;
					}
				}
				if ((gaitDef.feet == "belly" || gaitDef.feet == "none" || gaitDef.feet == "tendril") && Mathf.FloorToInt(num2 / gaitDef.period) != Mathf.FloorToInt(gaitClock / gaitDef.period))
				{
					FootfallSerial++;
				}
			}
			float num4 = gaitClock;
			Vector3 val = ((gaitDef == null) ? Vector3.zero : Locomotion.Body(gaitDef, num4, motion));
			float num5 = ((index == 18 && attackPhase == 2) ? (Mathf.Sin(Mathf.Clamp01(Mathf.Repeat(attackTime, 0.5f) / 0.35f) * MathF.PI) * 0.28f) : 0f);
			AttackPose.Evaluate(index, attackMode, attackPhase, attackProgress, poseTime, out var offset, out var angles, out var scale);
			float num6 = Mathf.Clamp01((hurtUntil - Time.time) / 0.5f);
			float num7 = Mathf.Sin((1f - num6) * MathF.PI * (float)(3 + index % 4)) * num6;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor((float)(((index + hurtSeed) % 2 == 0) ? 1 : (-1)) * num7 * 0.06f, num7 * 0.025f, (0f - Mathf.Abs(num7)) * 0.08f);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(num7 * (float)(5 + index % 5), 0f, num7 * (float)(((index % 2 == 0) ? 1 : (-1)) * (7 + index % 6)));
			((Component)this).transform.localPosition = restPosition + val + Vector3.up * num5 + offset + val2;
			((Component)this).transform.localRotation = restRotation * Quaternion.Euler(angles + val3);
			float num8 = ((index != 9 || attackMode != 0) ? 1f : ((attackPhase == 1) ? (1f - 0.98f * AttackPose.Ease((attackProgress - 0.75f) / 0.25f)) : ((attackPhase == 2) ? (0.02f + 0.98f * AttackPose.Ease(attackTime / 0.18f)) : 1f)));
			((Component)this).transform.localScale = Vector3.Scale(restScale, new Vector3(1f, num8, 1f));
			array = nodes;
			foreach (Node node2 in array)
			{
				float num9 = Mathf.Sin(num * (2.2f + (float)index * 0.017f) + node2.phase);
				Vector3 origin = node2.origin;
				Vector3 zero = Vector3.zero;
				Vector3 val4 = Vector3.one;
				if (node2.limb != null && gaitDef != null)
				{
					Locomotion.Limb(gaitDef, node2.limb, num4, motion, val.y, offset, Quaternion.Euler(angles), out var pivot, out var rotation);
					if (node2.wheel)
					{
						rotation = Quaternion.AngleAxis(Locomotion.WheelAngle(gaitDef, num4, Assets.Roster[index].speed), Vector3.right);
					}
					node2.transform.localPosition = pivot + rotation * (node2.origin - Assets.V((node2.limb.role == "upper") ? node2.limb.hip : ((node2.limb.role == "lower") ? node2.limb.knee : node2.limb.foot)));
					node2.transform.localRotation = rotation;
					node2.transform.localScale = Vector3.one;
					continue;
				}
				switch (node2.animation)
				{
				case "salute":
					zero.z = Mathf.Sin(num * 1.7f + node2.phase) * 12f + threat * 38f;
					zero.x = (0f - threat) * 22f;
					break;
				case "scroll":
					origin.y += Mathf.Sin(num * 2f + node2.phase) * 0.025f;
					break;
				case "fan_yaw":
					zero.y = ((index == 37 && attackMode == 0 && attackPhase >= 2) ? SpecialAttackRules.SpinDegrees(attackTime) : 0f);
					break;
				case "spinface":
					zero.z = num * 65f + ((index == 37 && attackMode == 0 && attackPhase >= 2) ? SpecialAttackRules.SpinDegrees(attackTime) : 0f);
					break;
				case "pop":
					origin.y += -0.5f + threat * 0.6f;
					zero.x = (0f - threat) * 35f;
					break;
				case "ventral":
					origin.z += Mathf.Sin(num4 * 4f + node2.phase) * 0.07f * motion;
					val4.x = 1f + Mathf.Sin(num4 * 4f + node2.phase) * 0.07f * motion;
					break;
				case "tendril":
					zero.x = Mathf.Sin(num * 2f + node2.phase) * 12f;
					zero.z = Mathf.Cos(num * 1.4f + node2.phase) * 8f;
					break;
				case "walk":
					zero.x = Mathf.Sin(num * (5f + motion * 3f) + node2.phase) * motion * 18f;
					origin.y += Mathf.Abs(Mathf.Sin(num * 6f + node2.phase)) * 0.055f * motion;
					break;
				case "sway":
					zero.z = num9 * (4f + threat * 7f);
					zero.x = Mathf.Sin(num * 1.8f + node2.phase) * 3f;
					break;
				case "breathe":
					val4.y = 1f + num9 * 0.035f;
					break;
				case "pulse":
					val4 = Vector3.one * (1f + Mathf.Sin(num * 4f + node2.phase) * (0.03f + threat * 0.06f));
					break;
				case "flame":
					val4.y = 1f + num9 * 0.18f;
					origin.x += Mathf.Sin(num * 7f + node2.phase) * 0.035f;
					break;
				case "jaw":
					zero.x = (0f - threat) * 30f + Mathf.Sin(num * 3f) * 4f;
					break;
				case "tongue":
					val4.z = 1f + threat * 0.8f;
					zero.x = num9 * 7f;
					break;
				case "pendulum":
					zero.z = Mathf.Sin(num * 3f + node2.phase) * (14f + threat * 32f);
					origin.x += Mathf.Sin(num * 3f + node2.phase) * 0.08f;
					break;
				case "head":
					zero.y = num9 * 8f;
					zero.x = (0f - threat) * 18f;
					break;
				case "wing":
					zero.z = Mathf.Sin(num * 7f + node2.phase) * (10f + threat * 20f);
					break;
				case "ear":
					zero.z = num9 * 8f + threat * 15f;
					break;
				case "spin":
					zero.y = num * 45f + ((index == 37 && attackMode == 0 && attackPhase >= 2) ? SpecialAttackRules.SpinDegrees(attackTime) : 0f);
					break;
				case "orbit":
				{
					float num10 = num * 2f + node2.phase;
					((Vector3)(ref origin))..ctor(Mathf.Cos(num10) * 0.6f, 1.35f + Mathf.Sin(num10) * 0.6f, 0f);
					zero.z = num10 * 57.29578f;
					break;
				}
				}
				if (attackPhase != 0)
				{
					if (node2.animation == "jaw")
					{
						zero.x += (0f - draw) * 24f + strike * 38f;
					}
					if (node2.animation == "tongue")
					{
						val4.z += strike * 1.5f;
					}
					if (node2.animation == "head")
					{
						zero.x += draw * 12f - strike * 22f;
					}
					if (node2.animation == "salute" || node2.animation == "pendulum")
					{
						zero.x += (0f - draw) * 35f + strike * 60f;
						zero.z += draw * 20f - strike * 45f;
					}
					if (node2.animation == "breathe" || node2.animation == "pulse")
					{
						val4 = Vector3.Scale(val4, scale);
					}
				}
				node2.transform.localPosition = origin;
				node2.transform.localRotation = Quaternion.Euler(zero);
				node2.transform.localScale = val4;
			}
		}
	}
	internal static class AttackPose
	{
		internal static readonly int[] Families = new int[42]
		{
			0, 3, 7, 4, 2, 3, 4, 0, 0, 5,
			1, 2, 7, 0, 8, 4, 2, 9, 5, 1,
			0, 7, 4, 3, 0, 4, 4, 3, 4, 1,
			5, 4, 2, 2, 3, 0, 2, 10, 6, 6,
			6, 6
		};

		internal static readonly float[] Durations = new float[42]
		{
			1f, 2.6f, 1.7f, 3f, 0.45f, 0.7f, 1f, 1f, 0.9f, 1f,
			1f, 0.6f, 2.7f, 0.8f, 2.3f, 1.2f, 1.3f, 3f, 1.6f, 1.9f,
			0.8f, 2.6f, 2.5f, 1f, 0.85f, 0.55f, 1.4f, 2f, 0.7f, 2.5f,
			2.1f, 1.1f, 2f, 1.2f, 2.2f, 1.8f, 3.5f, 3.2f, 0.7f, 1.5f,
			1.6f, 1.2f
		};

		internal static readonly float[][] Beats = new float[42][]
		{
			new float[1] { 0.14f },
			new float[3] { 0.2f, 0.75f, 1.3f },
			new float[1] { 0.1f },
			new float[1] { 0.14f },
			new float[1] { 0.09f },
			new float[1] { 0.12f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[1] { 0.2f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[3] { 0.08f, 0.42f, 0.76f },
			new float[1] { 0.14f },
			new float[1] { 1.35f },
			new float[2] { 0.12f, 0.67f },
			new float[1] { 0.14f },
			new float[1] { 1.65f },
			new float[3] { 0.18f, 0.68f, 1.18f },
			new float[3] { 0.1f, 0.65f, 1.2f },
			new float[1] { 0.14f },
			new float[3] { 0.12f, 0.34f, 0.56f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[1] { 0.12f },
			new float[2] { 0.12f, 0.9f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[3] { 0.12f, 0.82f, 1.52f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[1] { 0.14f },
			new float[2] { 0.12f, 1.3f },
			new float[1] { 0.14f },
			new float[3] { 0.1f, 0.9f, 1.7f },
			new float[1] { 0.4f },
			new float[1] { 0.14f },
			new float[1] { 0.55f },
			new float[1] { 0.24f },
			new float[1] { 0.2f }
		};

		internal static float Ease(float x)
		{
			x = Mathf.Clamp01(x);
			return x * x * (3f - 2f * x);
		}

		internal static float Pulse(float t, float peak, float duration)
		{
			float num = Mathf.Max(0f, peak - 0.14f);
			float num2 = Mathf.Min(duration, peak + 0.38f);
			if (!(t <= peak))
			{
				return 1f - Ease((t - peak) / Mathf.Max(0.01f, num2 - peak));
			}
			return Ease((t - num) / Mathf.Max(0.01f, peak - num));
		}

		internal static int Family(int index, int mode)
		{
			return mode switch
			{
				0 => Families[index], 
				4 => 5, 
				_ => CloseCombatRules.Consequence(index) switch
				{
					0 => 0, 
					1 => 5, 
					2 => 7, 
					3 => 4, 
					4 => 8, 
					5 => 9, 
					_ => 6, 
				}, 
			};
		}

		internal static void Weights(int index, int mode, int phase, float progress, float time, out float draw, out float strike)
		{
			draw = 0f;
			strike = 0f;
			switch (phase)
			{
			case 1:
				draw = Ease(progress);
				break;
			case 2:
			{
				float duration = ((mode == 0) ? Durations[index] : CloseCombatRules.Duration(index, mode));
				float num = ((mode == 0) ? Beats[index][0] : 0.16f);
				draw = 1f - Ease(time / Mathf.Max(0.08f, num + 0.04f));
				float[] array = mode switch
				{
					3 => new float[2] { 0.16f, 0.76f }, 
					0 => Beats[index], 
					_ => new float[1] { 0.16f }, 
				};
				foreach (float peak in array)
				{
					strike = Mathf.Max(strike, Pulse(time, peak, duration));
				}
				break;
			}
			}
		}

		internal static void Evaluate(int index, int mode, int phase, float progress, float time, out Vector3 offset, out Vector3 angles, out Vector3 scale)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			offset = Vector3.zero;
			angles = Vector3.zero;
			scale = Vector3.one;
			if (index >= 0 && index < 42 && phase != 0)
			{
				Weights(index, mode, phase, progress, time, out var draw, out var strike);
				float num = 0.85f + (float)(index % 5) * 0.075f;
				float num2 = 0.85f + (float)(index % 7) * 0.04f;
				switch (Family(index, mode))
				{
				case 0:
					offset = new Vector3(0f, (0f - draw) * 0.09f, (0f - draw) * 0.08f + strike * 0.14f);
					angles.x = (0f - draw) * 13f + strike * 18f;
					break;
				case 1:
					offset.y = draw * 0.09f - strike * 0.065f;
					angles.x = (0f - draw) * 11f + strike * 16f;
					break;
				case 2:
					angles.x = (0f - draw) * 7f + strike * 12f;
					angles.z = draw * 5f - strike * 7f;
					break;
				case 3:
					scale = new Vector3(1f + draw * 0.07f, 1f + draw * 0.055f, 1f + draw * 0.06f);
					angles.x = (0f - draw) * 8f + strike * 13f;
					break;
				case 4:
					angles.y = (0f - draw) * 26f + strike * 38f;
					angles.z = (0f - draw) * 8f + strike * 11f;
					break;
				case 5:
					offset.y = (0f - draw) * 0.12f + strike * 0.1f;
					angles.x = draw * 12f - strike * 15f;
					break;
				case 6:
					angles.x = (0f - draw) * 12f + strike * 18f;
					angles.z = draw * 12f - strike * 16f;
					offset.z = strike * 0.1f;
					break;
				case 7:
					angles.x = (0f - draw) * 18f + strike * 23f;
					angles.y = (0f - draw) * 12f + strike * 16f;
					offset.y = draw * 0.07f - strike * 0.04f;
					break;
				case 8:
					scale = new Vector3(1f + draw * 0.1f, 1f + draw * 0.05f, 1f + draw * 0.08f);
					angles.x = (0f - draw) * 10f + strike * 22f;
					break;
				case 9:
					angles.x = draw * 8f - strike * 9f;
					angles.z = (0f - draw) * 6f + strike * 12f;
					break;
				case 10:
					angles.z = (0f - draw) * 9f;
					break;
				}
				offset *= num;
				angles *= num2;
			}
		}
	}
	internal static class AttackPresentationRules
	{
		internal static string Visual(int i)
		{
			return i switch
			{
				0 => "tether", 
				1 => "breath", 
				2 => "bomb", 
				3 => "tripwire", 
				4 => "beam", 
				5 => "chorus", 
				6 => "hook", 
				7 => "body-ram", 
				8 => "body-lunge", 
				9 => "eruption", 
				10 => "body-verdict", 
				11 => "binding-tape", 
				12 => "bomb-volley", 
				13 => "body-pounce", 
				14 => "suction", 
				15 => "body-pendulum", 
				16 => "ink-spray", 
				17 => "scrap-vortex", 
				18 => "body-hop", 
				19 => "memory-stamp", 
				20 => "body-lunge", 
				21 => "seed-bombs", 
				22 => "movement-tether", 
				23 => "light-shards", 
				24 => "body-dash", 
				25 => "body-sweep", 
				26 => "stomp-debris", 
				27 => "furnace-breath", 
				28 => "body-lunge", 
				29 => "grass-growth", 
				30 => "body-zigzag", 
				31 => "body-cargo", 
				32 => "brick-projectile", 
				33 => "physical-panels", 
				34 => "reversal-cards", 
				35 => "body-drift", 
				36 => "panel-projectiles", 
				37 => "wind-debris", 
				38 => "body-backhand", 
				39 => "body-clap", 
				40 => "crossing-cords", 
				41 => "body-ambush", 
				_ => "", 
			};
		}

		internal static bool RequiresDetachedGeometry(int i)
		{
			switch (i)
			{
			case 0:
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 9:
			case 11:
			case 12:
			case 14:
			case 16:
			case 17:
			case 19:
			case 21:
			case 22:
			case 23:
			case 26:
			case 27:
			case 29:
			case 32:
			case 33:
			case 34:
			case 36:
			case 37:
			case 40:
				return true;
			default:
				return false;
			}
		}

		internal static bool HasStagedAudio(int i)
		{
			if (i >= 0)
			{
				return i < 42;
			}
			return false;
		}
	}
	public sealed class AttackVisual : MonoBehaviour
	{
		internal CreatureBrain Brain;

		private readonly List<Transform> motes = new List<Transform>();

		private int used;

		private LineRenderer strand;

		public void Clear()
		{
			foreach (Transform mote in motes)
			{
				if (Object.op_Implicit((Object)(object)mote))
				{
					((Component)mote).gameObject.SetActive(false);
				}
			}
			if (Object.op_Implicit((Object)(object)strand))
			{
				((Renderer)strand).enabled = false;
			}
		}

		private void Strand(Vector3 from, Vector3 to, float width, bool taut = false)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)strand))
			{
				GameObject val = new GameObject("Physical thread");
				val.transform.SetParent(((Component)this).transform, false);
				strand = val.AddComponent<LineRenderer>();
				((Renderer)strand).sharedMaterial = Assets.Material(new Color(0.72f, 0.38f, 0.46f), glow: true, 0.02f, 0.82f, 22);
				strand.numCapVertices = 4;
				strand.numCornerVertices = 3;
				strand.useWorldSpace = true;
			}
			((Renderer)strand).enabled = true;
			strand.widthMultiplier = width;
			strand.positionCount = (taut ? 7 : 2);
			if (!taut)
			{
				strand.SetPosition(0, from);
				strand.SetPosition(1, to);
				return;
			}
			float num = Mathf.Clamp(Vector3.Distance(from, to) * 0.055f, 0.035f, 0.24f);
			for (int i = 0; i < 7; i++)
			{
				float num2 = (float)i / 6f;
				strand.SetPosition(i, Vector3.Lerp(from, to, num2) + Vector3.down * (Mathf.Sin(num2 * MathF.PI) * num));
			}
		}

		private void Mote(Vector3 position, Vector3 scale, bool angular = false, Quaternion? rotation = null)
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (used >= motes.Count)
			{
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)(angular ? 3 : 0));
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
				((Object)val).name = "After Hours material particle";
				val.transform.SetParent(((Component)this).transform, false);
				Color val2 = default(Color);
				ColorUtility.TryParseHtmlString("#" + Brain.Def.color, ref val2);
				Renderer component = val.GetComponent<Renderer>();
				component.sharedMaterial = Assets.Material(val2 * 0.7f);
				component.shadowCastingMode = (ShadowCastingMode)0;
				motes.Add(val.transform);
			}
			Transform obj = motes[used++];
			((Component)obj).gameObject.SetActive(true);
			obj.position = position;
			obj.rotation = (Quaternion)(((??)rotation) ?? Quaternion.identity);
			obj.localScale = scale;
		}

		private void Strip(Vector3 from, Vector3 to, float width)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				Mote((from + to) * 0.5f, new Vector3(width, width, ((Vector3)(ref val)).magnitude), angular: true, Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up));
			}
		}

		private void Update()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0692: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			//IL_0768: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_079e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0791: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0923: Unknown result type (might be due to invalid IL or missing references)
			//IL_0924: Unknown result type (might be due to invalid IL or missing references)
			//IL_092b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0930: Unknown result type (might be due to invalid IL or missing references)
			//IL_0935: Unknown result type (might be due to invalid IL or missing references)
			//IL_093b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_0945: Unknown result type (might be due to invalid IL or missing references)
			//IL_094f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0954: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eaa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eaf: Unknown result type (might be due to invalid IL or missing references)
			//IL_099b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_0883: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bde: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_086a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0890: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0daf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dbd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e03: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cbb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cdd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fdf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fbf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ff7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ffc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1001: Unknown result type (might be due to invalid IL or missing references)
			//IL_1014: Unknown result type (might be due to invalid IL or missing references)
			//IL_1019: Unknown result type (might be due to invalid IL or missing references)
			//IL_101e: Unknown result type (might be due to invalid IL or missing references)
			//IL_103a: Unknown result type (might be due to invalid IL or missing references)
			//IL_103f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1044: Unknown result type (might be due to invalid IL or missing references)
			//IL_1047: Unknown result type (might be due to invalid IL or missing references)
			//IL_1049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ace: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_106f: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Brain) || !Brain.IsCombat || Brain.Phase == 0 || Brain.Phase == 3)
			{
				Clear();
				return;
			}
			used = 0;
			if (Object.op_Implicit((Object)(object)strand))
			{
				((Renderer)strand).enabled = false;
			}
			bool flag = Brain.Phase == 1;
			float num = Mathf.Max(0f, Brain.Age - Brain.Windup);
			Vector3 val = Brain.Origin + Vector3.up * 0.65f;
			Vector3 forward = Brain.Forward;
			Vector3 val2 = Vector3.Cross(Vector3.up, forward);
			int index = Brain.index;
			if (Brain.AttackMode == 0)
			{
				if (index == 22)
				{
					Vector3 val3 = Brain.A + Vector3.up * 0.1f;
					Vector3 to = (Object.op_Implicit((Object)(object)Brain.Target) ? (((Component)Brain.Target).transform.position + Vector3.up * 0.72f) : val3);
					Strand(flag ? val : val3, to, flag ? 0.022f : 0.032f, taut: true);
					Mote(val3, new Vector3(0.22f, 0.1f, 0.22f), angular: true, Quaternion.Euler(0f, (float)(Brain.Sequence * 37), 0f));
					for (int i = 0; i < 4; i++)
					{
						Vector3 val4 = Brain.A + Quaternion.Euler(0f, (float)(i * 90 + 45), 0f) * Vector3.forward * 1.55f;
						Mote(val4 + Vector3.up * 0.13f, new Vector3(0.045f, 0.26f, 0.045f), angular: true, Quaternion.Euler((float)(i * 11), (float)(i * 90), 0f));
					}
				}
				if (index == 11)
				{
					for (int j = 0; j < 5; j++)
					{
						float num2 = (float)j * 1.2566f + num * 1.4f;
						Vector3 val5 = Brain.A + new Vector3(Mathf.Cos(num2) * (0.45f + (float)j * 0.08f), 0.28f + (float)j * 0.11f, Mathf.Sin(num2) * (0.45f + (float)j * 0.08f));
						Strip(val5, val5 + val2 * (0.42f + (float)j * 0.05f), 0.025f);
					}
				}
				if (index == 23)
				{
					for (int k = 0; k < 7; k++)
					{
						float num3 = (float)k * 0.8976f + num * 2.2f;
						Vector3 position = Brain.Origin + (val2 * Mathf.Cos(num3) + forward * Mathf.Sin(num3)) * (0.42f + (float)(k % 2) * 0.18f) + Vector3.up * (0.42f + (float)(k % 3) * 0.22f);
						Mote(position, new Vector3(0.035f, 0.12f, 0.08f), angular: true, Quaternion.Euler((float)(k * 31), num3 * 57.29578f, (float)(k * 17)));
					}
				}
				if (!flag && index == 26)
				{
					float num4 = AttackPose.Pulse(num, 0.9f, Brain.ActiveDuration);
					for (int l = 0; l < 10; l++)
					{
						Vector3 val6 = Quaternion.Euler(0f, (float)(l * 36), 0f) * forward;
						Vector3 position2 = Brain.Origin + val6 * (0.35f + num4 * 2.2f) + Vector3.up * (0.05f + num4 * 0.16f);
						Mote(position2, new Vector3(0.055f, 0.08f, 0.18f), angular: true, Quaternion.LookRotation(val6));
					}
				}
				if (index == 33)
				{
					for (int m = 0; m < 3; m++)
					{
						float num5 = (float)m * 0.16f;
						float num6 = (flag ? Mathf.Clamp01(Brain.Age / Mathf.Max(0.1f, Brain.Windup)) : Mathf.Clamp01((num - num5) / 0.32f));
						Vector3 position3 = Vector3.Lerp(val, Brain.B + Vector3.up * (0.45f + (float)m * 0.28f), num6);
						Mote(position3, new Vector3(0.48f, 0.3f, 0.035f), angular: true, Quaternion.LookRotation(-forward, Vector3.up));
					}
				}
				if (index == 34)
				{
					float num7 = (flag ? 0f : Mathf.Clamp01(num / Brain.ActiveDuration));
					for (int n = 0; n < 8; n++)
					{
						float num8 = (float)n * 0.7854f + num7 * MathF.PI;
						Vector3 position4 = Brain.Origin + (val2 * Mathf.Cos(num8) + forward * Mathf.Sin(num8)) * (0.55f + Mathf.Abs(0.5f - num7) * 1.4f) + Vector3.up * (0.35f + (float)(n % 3) * 0.18f);
						Mote(position4, new Vector3(0.16f, 0.025f, 0.24f), angular: true, Quaternion.Euler(18f, (float)(n * 45) + num7 * 180f, 8f));
					}
				}
				if (index == 40)
				{
					Vector3 val7 = Brain.A + Vector3.up * 0.75f;
					Strip(val7 - val2 * 2f, val7 + val2 * 2f, 0.045f);
					Strip(val7 - forward * 2f, val7 + forward * 2f, 0.045f);
					Mote(val7, new Vector3(0.13f, 0.13f, 0.13f), angular: true, Quaternion.Euler(0f, num * 180f, 0f));
				}
				if (!flag && (index == 0 || index == 6 || index == 3 || index == 4))
				{
					Strand((index == 3) ? (Brain.A + Vector3.up * 0.9f) : val, (Vector3)(index switch
					{
						4 => Brain.B + Vector3.up * 0.65f, 
						3 => Brain.B + Vector3.up * 0.9f, 
						_ => Brain.A + Vector3.up * 0.5f, 
					}), index switch
					{
						4 => 0.024f, 
						3 => 0.016f, 
						_ => 0.055f, 
					});
				}
				if (index == 32 || index == 36)
				{
					int num9 = ((index != 36) ? 1 : 3);
					for (int num10 = 0; num10 < num9; num10++)
					{
						float num11 = num - (float)num10 * 0.8f;
						float num12 = Mathf.Max(0f, num11) * ((index == 32) ? 3.6f : 3.8f);
						if ((flag && num10 == 0) || (!flag && num11 >= 0f && num12 <= Vector3.Distance(Brain.A, Brain.B)))
						{
							Mote(val + forward * (flag ? 0.4f : num12), (index == 32) ? new Vector3(0.65f, 0.3f, 0.4f) : new Vector3(0.7f, 0.55f, 0.08f), angular: true);
						}
					}
				}
				else if (SpecialAttackRules.Bomb(index))
				{
					for (int num13 = 0; num13 < SpecialAttackRules.Count(index); num13++)
					{
						float num14 = SpecialAttackRules.Fuse(index, num13);
						float num15 = SpecialAttackRules.Release(index, num13);
						if (flag)
						{
							if (num13 == 0)
							{
								Mote(val + val2 * 0.32f + forward * 0.32f + Vector3.up * 0.38f, new Vector3(0.25f, 0.29f, 0.25f));
							}
						}
						else
						{
							if (num < num15)
							{
								continue;
							}
							if (num < num14)
							{
								Vector3 val8 = Brain.BombPosition(num13, num);
								Mote(val8, new Vector3(0.24f, 0.27f, 0.24f));
								Mote(val8 + Vector3.up * 0.18f, new Vector3(0.055f, 0.08f, 0.055f));
								for (int num16 = 1; num16 <= 3; num16++)
								{
									float time = Mathf.Max(num15, num - (float)num16 * 0.055f);
									Vector3 position5 = Brain.BombPosition(num13, time);
									Mote(position5, new Vector3(0.085f, 0.055f, 0.085f) * (1f - (float)num16 * 0.16f));
								}
							}
							else if (num < num14 + 0.42f)
							{
								float num17 = num - num14;
								Vector3 val9 = (Vector3)(num13 switch
								{
									1 => Brain.B, 
									0 => Brain.A, 
									_ => Brain.C, 
								});
								for (int num18 = 0; num18 < 12; num18++)
								{
									float num19 = (float)num18 * 2.39996f;
									Mote(val9 + new Vector3(Mathf.Cos(num19) * num17 * 3.4f, 0.3f + Mathf.Sin((float)num18) * num17 - num17 * num17, Mathf.Sin(num19) * num17 * 3.4f), Vector3.one * 0.08f, angular: true);
								}
							}
						}
					}
				}
				else if (!flag && (index == 14 || index == 17 || index == 37))
				{
					if (index == 14 && num < 1.35f)
					{
						for (int num20 = 0; num20 < 8; num20++)
						{
							float num21 = Mathf.Repeat(num * 0.65f + (float)num20 / 8f, 1f);
							float num22 = 3.8f - num21 * 3.1f;
							float num23 = Mathf.Sin((float)num20 * 1.7f) * num22 * 0.42f;
							Mote(Brain.Origin + val2 * num23 + forward * num22 + Vector3.up * (0.45f + Mathf.Cos((float)num20) * 0.2f), new Vector3(0.13f, 0.11f, 0.16f), angular: true);
						}
					}
					if (index == 17)
					{
						for (int num24 = 0; num24 < 12; num24++)
						{
							float num25 = (float)num24 * MathF.PI / 6f + num * 3f;
							float num26 = ((num < 1.65f) ? (2.8f - 1.6f * SpecialAttackRules.Smooth(num / 1.6f)) : (1.2f + (num - 1.65f) * 4f));
							Mote(Brain.Origin + (val2 * Mathf.Sin(num25) + forward * Mathf.Cos(num25)) * num26 + Vector3.up * (0.6f + Mathf.Sin(num25 * 2f) * 0.3f), new Vector3(0.16f, 0.06f, 0.2f), angular: true);
						}
					}
					if (index == 37 && num < 2.95f)
					{
						for (int num27 = 0; num27 < 12; num27++)
						{
							float num28 = Mathf.Repeat(num * 1.4f + (float)num27 / 12f, 1f);
							float num29 = 0.5f + num28 * 4f;
							Vector3 val10 = Quaternion.Euler(0f, SpecialAttackRules.SpinDegrees(num), 0f) * forward;
							Mote(Brain.Origin + val10 * num29 + Vector3.Cross(Vector3.up, val10) * Mathf.Sin((float)num27) * 0.2f + Vector3.up * (0.65f + Mathf.Cos((float)num27) * 0.18f), new Vector3(0.06f, 0.06f, 0.15f), angular: true);
						}
					}
				}
				else if (!flag && (index == 9 || index == 19 || index == 29))
				{
					Vector3[] array = (Vector3[])(object)new Vector3[3] { Brain.A, Brain.B, Brain.C };
					foreach (Vector3 val11 in array)
					{
						for (int num31 = 0; num31 < 3; num31++)
						{
							Mote(val11 + new Vector3(Mathf.Sin((float)num31 * 2.4f) * 0.35f, 0.1f + Mathf.Repeat(num * 1.4f + (float)num31 * 0.1f, 0.4f), Mathf.Cos((float)num31 * 2.4f) * 0.35f), new Vector3(0.05f, (index == 29) ? 0.45f : 0.12f, 0.05f));
						}
					}
				}
				else if (!flag && (index == 1 || index == 5 || index == 16 || index == 27))
				{
					for (int num32 = 0; num32 < 12; num32++)
					{
						float num33 = Mathf.Repeat(num + (float)num32 * 0.071f, 0.7f);
						float num34 = num33 * ((index == 16) ? 0.6f : 1.3f);
						Vector3 val12 = ((index == 17) ? (Quaternion.Euler(0f, (num - 1.2f) * 100f - 60f, 0f) * forward) : forward);
						Vector3 position6 = val + val12 * (num33 * 5f) + val2 * (Mathf.Sin((float)num32 * 2.4f) * num34) + Vector3.up * (Mathf.Cos((float)num32 * 1.7f) * num34 * 0.55f);
						Mote(position6, Vector3.one * (((index == 16) ? 0.04f : 0.09f) * (1f - num33 * 0.65f)), index == 17);
					}
				}
			}
			for (int num35 = used; num35 < motes.Count; num35++)
			{
				((Component)motes[num35]).gameObject.SetActive(false);
			}
		}

		internal static void Burst(Vector3 p, CreatureDef d)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			Color color = default(Color);
			ColorUtility.TryParseHtmlString("#" + d.color, ref color);
			int num = d.index % 6;
			int num2 = num switch
			{
				4 => 9, 
				2 => 18, 
				_ => 12, 
			};
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < num2; i++)
			{
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val).name = "After Hours debris";
				val.transform.position = p;
				float num3 = 0.055f + (float)(i % 4) * 0.018f;
				val.transform.localScale = ((num == 4) ? new Vector3(num3 * 1.8f, num3 * 0.45f, num3 * 1.8f) : new Vector3(num3, num3 * 1.15f, num3 * 1.8f));
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
				val.GetComponent<Renderer>().sharedMaterial = Assets.Material(color, glow: false, 0.12f, 0.72f, d.index * 23 + i);
				((Vector3)(ref val2))..ctor(Mathf.Cos((float)i * 2.39996f), 0f, Mathf.Sin((float)i * 2.39996f));
				Debris debris = val.AddComponent<Debris>();
				debris.style = num;
				Debris debris2 = debris;
				debris2.velocity = (Vector3)(num switch
				{
					1 => val2 * (0.7f + (float)(i % 3) * 0.3f) + Vector3.up * 2.2f, 
					2 => val2 * 2.4f + Vector3.up * 0.6f, 
					3 => val2 * 0.9f + Vector3.up * 1.2f, 
					4 => val2 * 0.35f + Vector3.up * 0.25f, 
					_ => Random.onUnitSphere * 1.8f + Vector3.up, 
				});
				Object.Destroy((Object)(object)val, (num == 4) ? 2.1f : (1.3f + ((num == 3) ? 0.5f : 0f)));
			}
		}
	}
	public sealed class Debris : MonoBehaviour
	{
		public Vector3 velocity;

		public int style;

		private void Update()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			if (style == 3)
			{
				velocity = Quaternion.Euler(0f, 180f * deltaTime, 0f) * velocity;
			}
			velocity += Vector3.down * ((style == 1) ? 4.5f : ((style == 4) ? 1.4f : 3f)) * deltaTime;
			velocity *= Mathf.Pow((style == 4) ? 0.35f : 0.78f, deltaTime);
			Transform transform = ((Component)this).transform;
			transform.position += velocity * deltaTime;
			((Component)this).transform.Rotate(new Vector3((float)(120 + style * 23), (float)(220 - style * 17), (float)(150 + style * 11)) * deltaTime);
			Transform transform2 = ((Component)this).transform;
			transform2.localScale *= Mathf.Pow((style == 4) ? 0.55f : 0.3f, deltaTime);
		}
	}
	internal enum HuntStyle
	{
		Pursuer,
		Artillery,
		Flanker,
		Sentry,
		Skirmisher,
		Ambusher,
		Charger,
		Swarm,
		Lurker,
		Shepherd,
		Mimic,
		Trapper,
		Predator,
		Juggernaut
	}
	internal static class BehaviorRules
	{
		internal static HuntStyle Style(int i)
		{
			switch (i)
			{
			case 1:
			case 2:
			case 12:
			case 21:
			case 32:
			case 36:
				return HuntStyle.Artillery;
			case 3:
			case 9:
			case 11:
			case 16:
				return HuntStyle.Flanker;
			case 4:
			case 33:
				return HuntStyle.Sentry;
			case 0:
			case 10:
			case 14:
			case 34:
				return HuntStyle.Skirmisher;
			case 8:
			case 19:
			case 20:
			case 28:
			case 41:
				return HuntStyle.Ambusher;
			case 7:
			case 18:
			case 24:
			case 30:
				return HuntStyle.Charger;
			case 5:
			case 26:
			case 37:
				return HuntStyle.Shepherd;
			case 22:
			case 23:
				return HuntStyle.Lurker;
			case 29:
				return HuntStyle.Trapper;
			case 6:
			case 13:
			case 25:
			case 31:
			case 35:
				return HuntStyle.Predator;
			case 17:
			case 27:
				return HuntStyle.Juggernaut;
			case 38:
			case 39:
			case 40:
				return HuntStyle.Mimic;
			default:
				return HuntStyle.Pursuer;
			}
		}

		internal static float PreferredRange(int i, float cooldown, bool hunting)
		{
			HuntStyle huntStyle = Style(i);
			float num = (float)(i % 4) * 0.28f;
			return huntStyle switch
			{
				HuntStyle.Artillery => 3.8f + num, 
				HuntStyle.Flanker => 1.5f + num * 0.45f, 
				HuntStyle.Sentry => 2.8f + num, 
				HuntStyle.Skirmisher => (cooldown > 0.35f) ? (3.2f + num) : 1.15f, 
				HuntStyle.Ambusher => hunting ? 1.1f : (2.6f + num), 
				HuntStyle.Charger => (cooldown > 0.35f) ? (4.4f + num) : 0f, 
				HuntStyle.Shepherd => 2.2f + num, 
				HuntStyle.Lurker => hunting ? 1f : (3f + num), 
				HuntStyle.Trapper => 4.2f, 
				HuntStyle.Predator => 0f, 
				HuntStyle.Juggernaut => 0.7f, 
				HuntStyle.Mimic => hunting ? 0.8f : (2.1f + num), 
				_ => 0.35f + (float)(i % 3) * 0.22f, 
			};
		}

		internal static float Lateral(int i, float time, bool hunting)
		{
			HuntStyle huntStyle = Style(i);
			float num = 0.43f + (float)(i % 7) * 0.073f;
			float num2 = (float)Math.Sin(time * num + (float)i * 1.618f);
			return huntStyle switch
			{
				HuntStyle.Flanker => num2 * (2.2f + (float)(i % 3) * 0.45f), 
				HuntStyle.Ambusher => hunting ? (num2 * 0.45f) : (num2 * 2.4f), 
				HuntStyle.Shepherd => num2 * (1.5f + (float)(i % 2) * 0.55f), 
				HuntStyle.Skirmisher => num2 * (0.65f + (float)(i % 3) * 0.3f), 
				HuntStyle.Mimic => hunting ? (num2 * 0.7f) : (num2 * 0.25f), 
				HuntStyle.Sentry => num2 * 0.35f, 
				HuntStyle.Trapper => num2 * 1.1f, 
				HuntStyle.Predator => num2 * 0.28f, 
				_ => 0f, 
			};
		}

		internal static float SpeedFactor(int i, float cooldown, bool hunting, float gaze, float targetSpeed)
		{
			return Math.Max(0.12f, Math.Min(1.35f, Style(i) switch
			{
				HuntStyle.Artillery => (cooldown > 0.35f) ? 0.82f : 1.08f, 
				HuntStyle.Flanker => 1.04f, 
				HuntStyle.Sentry => (cooldown > 0.35f) ? 0.62f : 1.12f, 
				HuntStyle.Skirmisher => (cooldown > 0.35f) ? 0.88f : 1.14f, 
				HuntStyle.Ambusher => (!hunting && gaze > 0.72f) ? 0.18f : 1.18f, 
				HuntStyle.Charger => (cooldown > 0.35f) ? 0.72f : 1.32f, 
				HuntStyle.Shepherd => 0.92f, 
				HuntStyle.Lurker => (!hunting && gaze > 0.72f) ? 0.12f : 1.22f, 
				HuntStyle.Trapper => 0.78f, 
				HuntStyle.Predator => (targetSpeed > 1.3f) ? 1.25f : 1.04f, 
				HuntStyle.Juggernaut => 0.86f, 
				HuntStyle.Mimic => hunting ? 1.18f : 0.78f, 
				_ => 1f, 
			} * (1f + (float)(i % 5) * 0.018f)));
		}

		internal static bool HoldsWhenWatched(int i, bool hunting, float gaze)
		{
			if (!hunting && gaze > 0.72f)
			{
				if (Style(i) != HuntStyle.Ambusher)
				{
					return Style(i) == HuntStyle.Lurker;
				}
				return true;
			}
			return false;
		}

		internal static string Identity(int i)
		{
			return Style(i).ToString() + ":" + PreferredRange(i, 1f, hunting: false).ToString("F2") + ":" + i % 7 + ":" + i % 5;
		}
	}
	internal static class CloseCombatRules
	{
		internal static float Tell(int i, int mode)
		{
			return mode switch
			{
				4 => 1.02f, 
				3 => 0.96f, 
				2 => 0.78f, 
				_ => 0.86f, 
			} + (float)(i % 5) * 0.045f + (float)i * 0.0007f;
		}

		internal static float Duration(int i, int mode)
		{
			return mode switch
			{
				4 => 0.86f, 
				3 => 1.22f, 
				2 => 0.52f, 
				_ => 0.78f, 
			} + (float)(i % 4) * 0.055f;
		}

		internal static float Speed(int i, int mode)
		{
			return Math.Min(8.4f, mode switch
			{
				4 => 5f, 
				3 => 6.1f, 
				_ => 6.7f, 
			} + (float)(i % 6) * 0.24f);
		}

		internal static float Radius(int i, int mode)
		{
			return mode switch
			{
				3 => 1.72f, 
				4 => 1.42f, 
				_ => 1.78f, 
			} + (float)(i % 5) * 0.055f;
		}

		internal static float DamageScale(int i, int mode)
		{
			return mode switch
			{
				4 => 0.78f + (float)(i % 3) * 0.04f, 
				3 => 0.58f + (float)(i % 4) * 0.035f, 
				_ => 0.94f + (float)(i % 5) * 0.025f, 
			};
		}

		internal static float Force(int i, int mode)
		{
			return 1.4f + (float)(i % 6) * 0.24f + ((mode == 4) ? 0.6f : 0f);
		}

		internal static int Consequence(int i)
		{
			return i % 7;
		}

		internal static bool HitWindow(int i, int mode, int stage, float now, float previous)
		{
			float num = mode switch
			{
				4 => 0.26f, 
				2 => 0.07f, 
				3 => (stage == 0) ? 0.16f : 0.72f, 
				_ => 0.1f + (float)(i % 3) * 0.018f, 
			};
			float num2 = num + mode switch
			{
				4 => 0.36f, 
				2 => 0.3f, 
				_ => 0.28f, 
			};
			if (stage < ((mode != 3) ? 1 : 2) && now >= num)
			{
				return previous <= num2;
			}
			return false;
		}

		internal static string Identity(int i)
		{
			return CloseMode(i) + ":" + Tell(i, CloseMode(i)).ToString("F3") + ":" + Speed(i, CloseMode(i)).ToString("F2") + ":" + Radius(i, CloseMode(i)).ToString("F3") + ":" + DamageScale(i, CloseMode(i)).ToString("F3") + ":" + Consequence(i);
		}

		internal static int CloseMode(int i)
		{
			return 1 + i % 3;
		}
	}
	public static class CombatRules
	{
		public static float SegmentDistance(float x, float z, float ax, float az, float bx, float bz)
		{
			float num = bx - ax;
			float num2 = bz - az;
			float num3 = num * num + num2 * num2;
			float num4 = ((num3 < 0.0001f) ? 0f : Math.Max(0f, Math.Min(1f, ((x - ax) * num + (z - az) * num2) / num3)));
			num = x - (ax + num4 * num);
			num2 = z - (az + num4 * num2);
			return (float)Math.Sqrt(num * num + num2 * num2);
		}

		public static bool Cone(float dx, float dz, float fx, float fz, float radius, float cosine)
		{
			float num = (float)Math.Sqrt(dx * dx + dz * dz);
			if (num <= radius)
			{
				if (!(num < 0.05f))
				{
					return (dx * fx + dz * fz) / num >= cosine;
				}
				return true;
			}
			return false;
		}

		public static bool Ring(float distance, float radius, float previousRadius, float width)
		{
			if (distance >= Math.Max(0f, Math.Min(previousRadius, radius) - width))
			{
				return distance <= Math.Max(previousRadius, radius) + width;
			}
			return false;
		}

		public static bool Donut(float distance, float inner, float outer)
		{
			if (distance > inner)
			{
				return distance <= outer;
			}
			return false;
		}

		public static bool Peripheral(float dot)
		{
			if (dot > 0.05f)
			{
				return dot < 0.7f;
			}
			return false;
		}

		public static bool Enabled(long mask, int index)
		{
			if (index >= 0 && index < 63)
			{
				return (mask & (1L << index)) != 0;
			}
			return false;
		}
	}
	public sealed class CreatureAffliction : MonoBehaviour
	{
		private float until;

		private float immuneUntil;

		private int kind;

		internal void Apply(int type)
		{
			if (!(Time.time < immuneUntil))
			{
				kind = type;
				until = Time.time + type switch
				{
					1 => 2.4f, 
					3 => 1.4f, 
					_ => 3f, 
				};
				immuneUntil = Time.time + 6f;
			}
		}

		private void Update()
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar instance = PlayerAvatar.instance;
			if (!Object.op_Implicit((Object)(object)instance) || !instance.isLocal || instance.isDisabled || (Object.op_Implicit((Object)(object)instance.RoomVolumeCheck) && instance.RoomVolumeCheck.inTruck))
			{
				until = 0f;
			}
			else
			{
				if (Time.time >= until)
				{
					return;
				}
				if (kind == 3)
				{
					if (Object.op_Implicit((Object)(object)PlayerController.instance))
					{
						PlayerController.instance.OverrideSpeed(0.65f, 0.1f);
					}
				}
				else if (Object.op_Implicit((Object)(object)PostProcessing.Instance))
				{
					float num = Mathf.Clamp01((until - Time.time) / 0.65f);
					PostProcessing.Instance.VignetteOverride((Color)((kind == 1) ? new Color(0.018f, 0.025f, 0.02f) : Color.black), 0.72f * num, 0.9f, 5f, 3f, 0.1f, ((Component)this).gameObject);
					PostProcessing.Instance.SaturationOverride(-55f * num, 5f, 3f, 0.1f, ((Component)this).gameObject);
				}
			}
		}
	}
	public sealed class CreatureBrain : MonoBehaviour, IPunObservable
	{
		private sealed class HazardState
		{
			public int id;

			public int kind;

			public Vector3 point;

			public float radius;

			public double expires;
		}

		public int index;

		internal CreatureDef Def;

		internal Enemy Enemy;

		internal EnemyParent Parent;

		internal EnemyRigidbody Body;

		internal CreatureRig Rig;

		internal AudioSource Source;

		internal int AttackMode;

		internal int Sequence;

		internal int Phase;

		internal Vector3 Origin;

		internal Vector3 A;

		internal Vector3 B;

		internal Vector3 C;

		internal Vector3 Forward;

		internal double Began;

		internal float ActiveDuration;

		internal PlayerAvatar Target;

		internal static readonly HashSet<CreatureBrain> Live = new HashSet<CreatureBrain>();

		private readonly HashSet<long> hit = new HashSet<long>();

		private readonly List<HazardState> activeHazards = new List<HazardState>();

		private PhotonView view;

		private AttackVisual visual;

		private MimicPersona persona;

		private float cooldown;

		private float senseTimer;

		private float idleTimer;

		private float roamTimer;

		private float lastActiveAge;

		private float exposure;

		private float lastSeenTime = -100f;

		private float pathCheck;

		private float stuckFor;

		private float traversalCooldown;

		private float noticeUntil;

		private float nextSearchStep;

		private int searchLeg;

		private Vector3 seenPosition;

		private Vector3 pathPosition;

		private Vector3 searchWaypoint;

		private Vector3 destination;

		private Vector3 lastTarget;

		private Vector3 olderTarget;

		private Vector3 visualPosition;

		private Vector3 attackPathPrevious;

		private bool spawned;

		private bool visualPositionReady;

		private float visualSpeed;

		private AudioSource footsteps;

		private AudioSource detailSource;

		private AudioLowPassFilter occlusionFilter;

		private float occlusionTimer;

		private int lastFootfall;

		private float lastStepTime;

		private int idlePlaybackCount;

		private int hazardSerial;

		private readonly MaterialTrigger surfaceMaterial = new MaterialTrigger();

		private int audioAttackSequence = -1;

		internal float Windup
		{
			get
			{
				if (AttackMode != 0)
				{
					return CloseCombatRules.Tell(index, AttackMode);
				}
				return Def.tell;
			}
		}

		internal Vector3 Feet => ((Component)Body).transform.position;

		internal bool CanAttack
		{
			get
			{
				if (Phase == 0)
				{
					return cooldown <= 0f;
				}
				return false;
			}
		}

		internal bool Hunting => ThreatRules.Pressured(index, exposure);

		internal static double Clock
		{
			get
			{
				if (!SemiFunc.IsMultiplayer())
				{
					return Time.timeAsDouble;
				}
				return PhotonNetwork.Time;
			}
		}

		internal bool Authority => SemiFunc.IsMasterClientOrSingleplayer();

		internal float Age => (float)(Clock - Began);

		internal bool IsCombat
		{
			get
			{
				if (Object.op_Implicit((Object)(object)Parent) && Parent.Spawned && Parent.SetupDone && Object.op_Implicit((Object)(object)Enemy))
				{
					return !Enemy.Health.dead;
				}
				return false;
			}
		}

		private void Awake()
		{
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			Def = Assets.Roster[index];
			Enemy = ((Component)this).GetComponent<Enemy>();
			Parent = ((Component)this).GetComponentInParent<EnemyParent>();
			Body = ((Component)Parent).GetComponentInChildren<EnemyRigidbody>(true);
			Rig = ((Component)Parent).GetComponentInChildren<CreatureRig>(true);
			Source = ((Component)Body).GetComponent<AudioSource>();
			view = ((Component)this).GetComponent<PhotonView>();
			if ((Object)(object)Assets.Mixer == (Object)null)
			{
				Assets.Mixer = ((IEnumerable<AudioMixerGroup>)Resources.FindObjectsOfTypeAll<AudioMixerGroup>()).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup g) => ((Object)g).name == "Enemies")) ?? ((IEnumerable<AudioMixerGroup>)Resources.FindObjectsOfTypeAll<AudioMixerGroup>()).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup g) => ((Object)g).name == "SFX"));
			}
			Source.outputAudioMixerGroup = Assets.Mixer;
			detailSource = ((Component)Body).gameObject.AddComponent<AudioSource>();
			detailSource.playOnAwake = false;
			detailSource.spatialBlend = 1f;
			detailSource.minDistance = 1.5f;
			detailSource.maxDistance = 22f;
			detailSource.dopplerLevel = 0f;
			detailSource.rolloffMode = (AudioRolloffMode)1;
			detailSource.outputAudioMixerGroup = Assets.Mixer;
			occlusionFilter = ((Component)Body).gameObject.AddComponent<AudioLowPassFilter>();
			occlusionFilter.cutoffFrequency = 22000f;
			occlusionFilter.lowpassResonanceQ = 1f;
			footsteps = ((Component)Body).gameObject.AddComponent<AudioSource>();
			footsteps.playOnAwake = false;
			footsteps.spatialBlend = 1f;
			footsteps.minDistance = 1f;
			footsteps.maxDistance = 12f;
			footsteps.dopplerLevel = 0f;
			footsteps.outputAudioMixerGroup = Assets.Mixer;
			((Component)Enemy).GetComponent<EnemyStateSpawn>().OnSpawn.AddListener(new UnityAction(Spawn));
			EnemyHealth component = ((Component)Enemy).GetComponent<EnemyHealth>();
			component.onHurt.AddListener((UnityAction)delegate
			{
				Play("hurt");
				Rig.Hurt(Sequence);
				SpawnDiagnostics.CreatureEvent(this, "hurt; health=" + Enemy.Health.healthCurrent + "/" + Def.health, throttle: true);
			});
			component.onDeath.AddListener(new UnityAction(Die));
			PhysGrabObjectImpactDetector component2 = ((Component)Body).GetComponent<PhysGrabObjectImpactDetector>();
			component2.onImpactLight.AddListener(new UnityAction(Body.LightImpact));
			component2.onImpactMedium.AddListener(new UnityAction(Body.MediumImpact));
			component2.onImpactHeavy.AddListener(new UnityAction(Body.HeavyImpact));
			visual = ((Component)this).gameObject.AddComponent<AttackVisual>();
			visual.Brain = this;
			idleTimer = 7f + (float)index * 0.19f;
			cooldown = 3f;
			Live.Add(this);
		}

		private void Start()
		{
			Enemy.Health.healthCurrent = Def.health;
			persona = ((Component)this).GetComponent<MimicPersona>();
		}

		private void OnDestroy()
		{
			Live.Remove(this);
		}

		private void OnDisable()
		{
			if (Object.op_Implicit((Object)(object)visual))
			{
				visual.Clear();
			}
			Phase = 0;
			Target = null;
			spawned = false;
			activeHazards.Clear();
		}

		private void Spawn()
		{
			spawned = true;
			Phase = 0;
			AttackMode = 0;
			exposure = 0f;
			lastSeenTime = -100f;
			stuckFor = 0f;
			traversalCooldown = 0f;
			noticeUntil = 0f;
			nextSearchStep = 0f;
			searchLeg = 0;
			hazardSerial = 0;
			activeHazards.Clear();
			cooldown = 2f;
			hit.Clear();
			lastActiveAge = 0f;
			Rig.threat = 0f;
			visualPositionReady = false;
			visualSpeed = 0f;
			if (Authority)
			{
				if (!Plugin.IsEnabled(index))
				{
					SpawnDiagnostics.CreatureEvent(this, "spawn rejected: disabled in host roster", throttle: true);
					Parent.Despawn();
					return;
				}
				if (!SemiFunc.EnemySpawn(Enemy))
				{
					SpawnDiagnostics.CreatureEvent(this, "spawn deferred: native spawn-point/clearance check failed; native retry scheduled", throttle: true);
					return;
				}
			}
			SpawnDiagnostics.CreatureEvent(this, "spawn active; health=" + Def.health + "; baseDamage=" + Def.damage + "; signatureCooldown=" + ThreatRules.Cooldown(Def.cooldown));
			if (index < 38 || index > 40)
			{
				Play("idle");
			}
		}

		private void Die()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			SpawnDiagnostics.CreatureEvent(this, "death");
			PlayDetached("death");
			AttackVisual.Burst(Enemy.CenterTransform.position, Def);
			if (Authority)
			{
				Parent.Despawn();
			}
		}

		private void Play(string cue)
		{
			if (Object.op_Implicit((Object)(object)Source))
			{
				bool flag = ((cue == "idle") ? ((idlePlaybackCount++ + index) % 2 == 1) : (cue == "attack" && (Sequence + index) % 2 == 1));
				Source.volume = Plugin.Volume.Value;
				Source.pitch = SpeciesStateRules.AudioPitch(index, Sequence + idlePlaybackCount);
				Source.PlayOneShot(Assets.Clip(Def, flag ? (cue + "_alt") : cue));
				if (cue == "attack" && Object.op_Implicit((Object)(object)detailSource))
				{
					detailSource.volume = Plugin.Volume.Value * 0.16f;
					detailSource.pitch = Mathf.Clamp(Source.pitch * (flag ? 0.91f : 1.08f), 0.82f, 1.18f);
					detailSource.PlayOneShot(Assets.Clip(Def, flag ? "attack" : "attack_alt"));
				}
			}
		}

		private void PlayDetached(string cue)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			GameObject val = new GameObject("After Hours death sound");
			val.transform.position = Enemy.CenterTransform.position;
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.spatialBlend = 1f;
			val2.minDistance = 2f;
			val2.maxDistance = 24f;
			val2.dop