Decompiled source of Stalker v1.0.0

Traqueur.dll

Decompiled 36 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Traqueur
{
	internal static class Snd
	{
		public static void Play(Sound s, Vector3 pos, float volume = 1f, float pitch = 1f)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (s == null || s.Sounds == null || s.Sounds.Length == 0)
			{
				return;
			}
			float pitch2 = s.Pitch;
			try
			{
				s.Pitch = pitch2 * pitch;
				s.Play(pos, volume, 1f, 1f, 1f);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("Sound play failed: " + ex.Message));
			}
			finally
			{
				s.Pitch = pitch2;
			}
		}

		public static Sound Make(string name, float volume, float spatial, float pitchRandom, params string[] wavs)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			List<AudioClip> list = new List<AudioClip>();
			foreach (string text in wavs)
			{
				try
				{
					list.Add(Wav.Load("Traqueur." + text, name + " " + text));
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Sound " + text + ": " + ex.Message));
				}
			}
			return new Sound
			{
				Sounds = list.ToArray(),
				Type = (AudioType)0,
				Volume = volume,
				VolumeRandom = 0.05f,
				Pitch = 1f,
				PitchRandom = pitchRandom,
				SpatialBlend = spatial,
				Doppler = 0f,
				ReverbMix = 1f,
				FalloffMultiplier = 1f,
				OffscreenVolume = 1f,
				OffscreenFalloff = 1f,
				LowPassIgnoreColliders = new List<Collider>()
			};
		}

		public static Sound Loop(Sound from, AudioSource src, float volume)
		{
			//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_001f: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			if (from == null || (Object)(object)src == (Object)null)
			{
				return null;
			}
			return new Sound
			{
				Sounds = from.Sounds,
				Type = (AudioType)0,
				Volume = volume,
				VolumeRandom = 0f,
				Pitch = 1f,
				PitchRandom = 0f,
				SpatialBlend = 1f,
				Doppler = 0f,
				ReverbMix = 1f,
				FalloffMultiplier = 1f,
				OffscreenVolume = 1f,
				OffscreenFalloff = 1f,
				LowPassIgnoreColliders = new List<Collider>(),
				Source = src
			};
		}

		public static AudioSource Source(Transform parent, string name, float minD, float maxD)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.loop = true;
			obj.spatialBlend = 1f;
			obj.rolloffMode = (AudioRolloffMode)1;
			obj.minDistance = minD;
			obj.maxDistance = maxD;
			obj.dopplerLevel = 0f;
			obj.volume = 0f;
			return obj;
		}

		public static void Route(AudioSource src)
		{
			if (Object.op_Implicit((Object)(object)src) && Object.op_Implicit((Object)(object)AudioManager.instance))
			{
				src.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
			}
		}

		public static void PlayLoop(Sound s, bool on, float fadeIn, float fadeOut, float pitch = 1f, float vol = 1f)
		{
			if (s == null || (Object)(object)s.Source == (Object)null)
			{
				return;
			}
			try
			{
				s.PlayLoop(on, fadeIn, fadeOut, pitch, vol);
			}
			catch (Exception)
			{
			}
		}
	}
	internal static class Wav
	{
		public static AudioClip Load(string resource, string clipName)
		{
			byte[] array = Resource.Embedded(resource);
			int num = BitConverter.ToInt16(array, 22);
			int num2 = BitConverter.ToInt32(array, 24);
			if (BitConverter.ToInt16(array, 34) != 16)
			{
				throw new Exception("only 16-bit PCM");
			}
			int i = 12;
			int num3 = -1;
			int num4 = 0;
			int num5;
			for (; i + 8 <= array.Length; i += 8 + num5 + (num5 & 1))
			{
				string text = Encoding.ASCII.GetString(array, i, 4);
				num5 = BitConverter.ToInt32(array, i + 4);
				if (text == "data")
				{
					num3 = i + 8;
					num4 = num5;
					break;
				}
			}
			if (num3 < 0)
			{
				throw new Exception("no data chunk");
			}
			int num6 = num4 / 2;
			float[] array2 = new float[num6];
			for (int j = 0; j < num6; j++)
			{
				array2[j] = (float)BitConverter.ToInt16(array, num3 + j * 2) / 32768f;
			}
			AudioClip obj = AudioClip.Create(clipName, num6 / num, num, num2, false);
			obj.SetData(array2, 0);
			((Object)obj).hideFlags = (HideFlags)32;
			return obj;
		}
	}
	internal static class Resource
	{
		public static T Load<T>(string path) where T : Object
		{
			T val = Resources.Load<T>(path);
			if ((Object)(object)val == (Object)null)
			{
				val = Resources.Load<T>(path.ToLowerInvariant());
			}
			return val;
		}

		public static byte[] Embedded(string name)
		{
			using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream(name);
			if (stream == null)
			{
				throw new FileNotFoundException("Embedded resource missing: " + name);
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		public static T AnimOf<T>(string path) where T : Component
		{
			GameObject val = Resource.Load<GameObject>(path);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return default(T);
			}
			return val.GetComponentInChildren<T>(true);
		}
	}
	internal static class U
	{
		public static bool MP => GameManager.Multiplayer();

		public static bool Master => SemiFunc.IsMasterClientOrSingleplayer();

		public static Vector3 Flat(Vector3 v)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			v.y = 0f;
			return v;
		}

		public static bool Valid(PlayerAvatar p)
		{
			if ((Object)(object)p != (Object)null && !p.isDisabled)
			{
				return !p.deadSet;
			}
			return false;
		}

		public static float Damp(float c, float t, float s, float dt)
		{
			return Mathf.Lerp(c, t, 1f - Mathf.Exp((0f - s) * dt));
		}

		public static float Smooth(float a, float b, float x)
		{
			float num = Mathf.Clamp01((x - a) / (b - a));
			return num * num * (3f - 2f * num);
		}

		public static Vector3 Body(PlayerAvatar p)
		{
			//IL_0020: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)p.tumble) || !p.tumble.isTumbling)
			{
				return ((Component)p).transform.position + Vector3.up * 0.9f;
			}
			return ((Component)p.tumble).transform.position;
		}

		public static PlayerAvatar Find(int viewId)
		{
			if (viewId < 0)
			{
				return null;
			}
			PhotonView val = PhotonView.Find(viewId);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return ((Component)val).GetComponent<PlayerAvatar>();
		}

		public static int Id(PlayerAvatar p)
		{
			if (!Object.op_Implicit((Object)(object)p) || !Object.op_Implicit((Object)(object)p.photonView))
			{
				return -1;
			}
			return p.photonView.ViewID;
		}

		public static List<PlayerAvatar> Players()
		{
			return SemiFunc.PlayerGetList() ?? new List<PlayerAvatar>();
		}

		public static void Shake(Vector3 pos, float strength, float time, float dMin, float dMax)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Object.op_Implicit((Object)(object)GameDirector.instance) && Object.op_Implicit((Object)(object)GameDirector.instance.CameraShake))
				{
					GameDirector.instance.CameraShake.ShakeDistance(strength, dMin, dMax, pos, time);
				}
			}
			catch (Exception)
			{
			}
		}

		public static void Hurt(PlayerAvatar p, int dmg, Enemy by)
		{
			//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)
			if (Valid(p) && dmg > 0 && Object.op_Implicit((Object)(object)p.playerHealth))
			{
				p.playerHealth.HurtOther(dmg, ((Component)p).transform.position + Vector3.up, false, SemiFunc.EnemyGetIndex(by), false);
			}
		}

		public static Vector3 TruckPos()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			LevelGenerator instance = LevelGenerator.Instance;
			if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.LevelPathTruck))
			{
				return new Vector3(9999f, 9999f, 9999f);
			}
			return ((Component)instance.LevelPathTruck).transform.position;
		}

		public static void DestroyLater(GameObject go, float delay)
		{
			if (Object.op_Implicit((Object)(object)Plugin.Instance) && Object.op_Implicit((Object)(object)go))
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(DestroyRun(go, delay));
			}
		}

		private static IEnumerator DestroyRun(GameObject go, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			if (Object.op_Implicit((Object)(object)go))
			{
				Object.Destroy((Object)(object)go);
			}
		}

		public static PlayerAvatar BreakGrabs(PhysGrabObject pgo)
		{
			if (!Object.op_Implicit((Object)(object)pgo) || pgo.playerGrabbing.Count == 0)
			{
				return null;
			}
			PlayerAvatar val = null;
			int num = (Object.op_Implicit((Object)(object)pgo.photonView) ? pgo.photonView.ViewID : (-1));
			foreach (PhysGrabber item in new List<PhysGrabber>(pgo.playerGrabbing))
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					if (!Object.op_Implicit((Object)(object)val) && Valid(item.playerAvatar))
					{
						val = item.playerAvatar;
					}
					if (SemiFunc.IsMultiplayer())
					{
						item.ReleaseObject(num, 1.5f);
					}
					else
					{
						item.OverrideGrabRelease(num, 1.5f);
					}
				}
			}
			return val;
		}

		public static bool Linecast(Vector3 a, Vector3 b, int mask, out RaycastHit hit)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0020: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			bool queriesHitBackfaces = Physics.queriesHitBackfaces;
			Physics.queriesHitBackfaces = true;
			try
			{
				bool num = Physics.Linecast(a, b, ref hit, mask, (QueryTriggerInteraction)1);
				if (num && Vector3.Dot(((RaycastHit)(ref hit)).normal, b - a) > 0f)
				{
					((RaycastHit)(ref hit)).normal = -((RaycastHit)(ref hit)).normal;
				}
				return num;
			}
			finally
			{
				Physics.queriesHitBackfaces = queriesHitBackfaces;
			}
		}

		public static bool Blocked(Vector3 a, Vector3 b, int mask)
		{
			//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)
			RaycastHit hit;
			return Linecast(a, b, mask, out hit);
		}

		public static bool Raycast(Vector3 o, Vector3 dir, float max, int mask, out RaycastHit hit)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			bool queriesHitBackfaces = Physics.queriesHitBackfaces;
			Physics.queriesHitBackfaces = true;
			try
			{
				bool num = Physics.Raycast(o, dir, ref hit, max, mask, (QueryTriggerInteraction)1);
				if (num && Vector3.Dot(((RaycastHit)(ref hit)).normal, dir) > 0f)
				{
					((RaycastHit)(ref hit)).normal = -((RaycastHit)(ref hit)).normal;
				}
				return num;
			}
			finally
			{
				Physics.queriesHitBackfaces = queriesHitBackfaces;
			}
		}

		public static bool InSafeRoom(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(p, 0.25f, -1, (QueryTriggerInteraction)2);
			foreach (Collider val in array)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					RoomVolume componentInParent = ((Component)val).GetComponentInParent<RoomVolume>();
					if (Object.op_Implicit((Object)(object)componentInParent) && (componentInParent.Truck || componentInParent.Extraction))
					{
						return true;
					}
				}
			}
			return false;
		}
	}
	internal interface IHeavyHit
	{
		void HeavyHit(PhysGrabObject by, float speed, Vector3 point);
	}
	public class HeavyImpact : MonoBehaviour
	{
		internal IHeavyHit ai;

		internal static float MinMass = 2f;

		internal static float MinSpeed = 4f;

		private void OnCollisionEnter(Collision c)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (ai == null || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			Rigidbody rigidbody = c.rigidbody;
			if ((Object)(object)rigidbody == (Object)null || rigidbody.isKinematic)
			{
				return;
			}
			PhysGrabObject component = ((Component)rigidbody).GetComponent<PhysGrabObject>();
			if ((Object)(object)component == (Object)null || (Object)(object)((Component)rigidbody).GetComponent<PlayerAvatar>() != (Object)null || (Object)(object)((Component)rigidbody).GetComponentInParent<Enemy>() != (Object)null)
			{
				return;
			}
			Vector3 relativeVelocity = c.relativeVelocity;
			float magnitude = ((Vector3)(ref relativeVelocity)).magnitude;
			if (rigidbody.mass >= MinMass && magnitude >= MinSpeed)
			{
				IHeavyHit heavyHit = ai;
				Vector3 point;
				if (c.contactCount <= 0)
				{
					point = ((Component)this).transform.position;
				}
				else
				{
					ContactPoint contact = c.GetContact(0);
					point = ((ContactPoint)(ref contact)).point;
				}
				heavyHit.HeavyHit(component, magnitude, point);
			}
		}
	}
	internal struct Part
	{
		public Mesh Mesh;

		public int[] MatIds;
	}
	internal static class Kit
	{
		public static Material[] Materials;

		public static Texture2D Atlas;

		private static Material baseMat;

		private static Shader standard;

		public static void Init()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			Atlas = new Texture2D(2, 2, (TextureFormat)4, true);
			ImageConversion.LoadImage(Atlas, Resource.Embedded("Traqueur.atlas.png"), false);
			((Object)Atlas).name = "Traqueur Atlas";
			((Texture)Atlas).wrapMode = (TextureWrapMode)1;
			((Texture)Atlas).filterMode = (FilterMode)2;
			((Texture)Atlas).anisoLevel = 4;
			Atlas.Apply(true, true);
			((Object)Atlas).hideFlags = (HideFlags)32;
			GameObject val = Resource.Load<GameObject>("Valuables/03 Medium/Valuable Manor Vase");
			if (Object.op_Implicit((Object)(object)val))
			{
				MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(true);
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					baseMat = ((Renderer)componentInChildren).sharedMaterial;
				}
			}
			standard = Shader.Find("Standard");
		}

		public static Material Mat(string name, float gloss, float metal, Color emission, float alpha = 1f)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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)
			bool num = alpha < 0.999f;
			Material val = ((!num || !Object.op_Implicit((Object)(object)standard) || (Object.op_Implicit((Object)(object)baseMat) && !(((Object)baseMat.shader).name != "Standard"))) ? (Object.op_Implicit((Object)(object)baseMat) ? new Material(baseMat) : new Material(Object.op_Implicit((Object)(object)standard) ? standard : Shader.Find("Diffuse"))) : new Material(standard));
			((Object)val).name = "Traqueur " + name;
			val.mainTexture = (Texture)(object)Atlas;
			val.color = new Color(1f, 1f, 1f, alpha);
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", gloss);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metal);
			}
			if (((Color)(ref emission)).maxColorComponent > 0.001f && val.HasProperty("_EmissionColor"))
			{
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", emission);
				if (val.HasProperty("_EmissionMap"))
				{
					val.SetTexture("_EmissionMap", (Texture)(object)Atlas);
				}
				val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
			}
			else
			{
				val.DisableKeyword("_EMISSION");
				if (val.HasProperty("_EmissionColor"))
				{
					val.SetColor("_EmissionColor", Color.black);
				}
			}
			if (num)
			{
				if (val.HasProperty("_Mode"))
				{
					val.SetFloat("_Mode", 2f);
				}
				val.SetOverrideTag("RenderType", "Transparent");
				val.SetInt("_SrcBlend", 5);
				val.SetInt("_DstBlend", 10);
				val.SetInt("_ZWrite", 0);
				val.DisableKeyword("_ALPHATEST_ON");
				val.EnableKeyword("_ALPHABLEND_ON");
				val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
				val.renderQueue = 3000;
			}
			((Object)val).hideFlags = (HideFlags)32;
			return val;
		}

		public static Material[] MatsFor(int[] ids)
		{
			Material[] array = (Material[])(object)new Material[ids.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Materials[Mathf.Clamp(ids[i], 0, Materials.Length - 1)];
			}
			return array;
		}

		public static Transform MakePart(string name, Part p, Transform parent, Vector3 localPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.AddComponent<MeshFilter>().sharedMesh = p.Mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = MatsFor(p.MatIds);
			return val.transform;
		}

		public static GameObject Prop(string name, Part p, Vector3 pos, Quaternion rot, float scale = 1f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetPositionAndRotation(pos, rot);
			val.transform.localScale = Vector3.one * scale;
			val.AddComponent<MeshFilter>().sharedMesh = p.Mesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterials = MatsFor(p.MatIds);
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			return val;
		}

		public static Dictionary<string, Transform> Build(Transform model, Dictionary<string, Part> parts, Dictionary<string, Part> detached)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			for (int i = 0; i < ModelLayout.Parts.Length; i++)
			{
				string text = ModelLayout.Parts[i];
				if (Array.IndexOf(ModelLayout.Detached, text) >= 0)
				{
					if (detached != null)
					{
						detached[text] = parts[text];
					}
				}
				else
				{
					string text2 = ModelLayout.Parents[i];
					Transform parent = (string.IsNullOrEmpty(text2) ? model : dictionary[text2]);
					Vector3 val = (string.IsNullOrEmpty(text2) ? Vector3.zero : ModelLayout.Pivots[Array.IndexOf(ModelLayout.Parts, text2)]);
					dictionary[text] = MakePart(text, parts[text], parent, ModelLayout.Pivots[i] - val);
				}
			}
			return dictionary;
		}

		public static Dictionary<string, Part> LoadMeshes(byte[] data)
		{
			//IL_0099: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			Dictionary<string, Part> dictionary = new Dictionary<string, Part>();
			using BinaryReader binaryReader = new BinaryReader(new MemoryStream(data));
			if (new string(binaryReader.ReadChars(4)) != "FMSH")
			{
				throw new Exception("Bad mesh data");
			}
			int num = binaryReader.ReadInt32();
			for (int i = 0; i < num; i++)
			{
				string text = Encoding.UTF8.GetString(binaryReader.ReadBytes(binaryReader.ReadInt32()));
				int num2 = binaryReader.ReadInt32();
				Vector3[] array = (Vector3[])(object)new Vector3[num2];
				Vector3[] array2 = (Vector3[])(object)new Vector3[num2];
				Vector2[] array3 = (Vector2[])(object)new Vector2[num2];
				for (int j = 0; j < num2; j++)
				{
					array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
				for (int k = 0; k < num2; k++)
				{
					array2[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
				for (int l = 0; l < num2; l++)
				{
					array3[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
				int num3 = binaryReader.ReadInt32();
				Mesh val = new Mesh
				{
					name = "Traqueur " + text
				};
				if (num2 > 65000)
				{
					val.indexFormat = (IndexFormat)1;
				}
				val.vertices = array;
				val.normals = array2;
				val.uv = array3;
				val.subMeshCount = num3;
				int[] array4 = new int[num3];
				for (int m = 0; m < num3; m++)
				{
					array4[m] = binaryReader.ReadInt32();
					int num4 = binaryReader.ReadInt32();
					int[] array5 = new int[num4];
					for (int n = 0; n < num4; n++)
					{
						array5[n] = binaryReader.ReadInt32();
					}
					val.SetTriangles(array5, m);
				}
				val.RecalculateBounds();
				val.RecalculateTangents();
				((Object)val).hideFlags = (HideFlags)32;
				dictionary[text] = new Part
				{
					Mesh = val,
					MatIds = array4
				};
			}
			return dictionary;
		}
	}
	internal struct Shell
	{
		public GameObject Prefab;

		public Transform Enable;

		public Transform Controller;

		public Transform Rigidbody;

		public Transform Visuals;

		public Transform VisionT;

		public Transform Particles;

		public EnemyParent Parent;

		public Enemy Enemy;

		public EnemyHealth Health;

		public EnemyRigidbody Erb;

		public CapsuleCollider Capsule;

		public const float RigidbodyHeight = 0.5f;

		public static Shell Make(string enemyName)
		{
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Resource.Load<GameObject>("Enemies/Enemy - Valuable Thrower");
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("Vanilla prefab 'Enemies/Enemy - Valuable Thrower' not found");
			}
			Shell result = new Shell
			{
				Prefab = Object.Instantiate<GameObject>(val, Plugin.Holder.transform)
			};
			((Object)result.Prefab).name = "Enemy - " + enemyName;
			result.Enable = result.Prefab.transform.Find("Enable");
			result.Controller = result.Enable.Find("Controller");
			result.Rigidbody = result.Enable.Find("Rigidbody");
			result.Visuals = result.Enable.Find("Visuals");
			if ((Object)(object)result.Controller == (Object)null || (Object)(object)result.Rigidbody == (Object)null || (Object)(object)result.Visuals == (Object)null)
			{
				throw new Exception("Unexpected Rugrat hierarchy (game update?)");
			}
			Kill((Component)(object)((Component)result.Controller).GetComponent<EnemyValuableThrower>());
			Kill((Component)(object)((Component)result.Visuals).GetComponent<EnemyValuableThrowerAnim>());
			Kill((Component)(object)((Component)result.Visuals).GetComponent<Animator>());
			result.VisionT = result.Visuals.Find("Vision Transform");
			List<GameObject> list = new List<GameObject>();
			foreach (Transform visual in result.Visuals)
			{
				Transform val2 = visual;
				if ((Object)(object)val2 != (Object)(object)result.VisionT)
				{
					list.Add(((Component)val2).gameObject);
				}
			}
			Transform val3 = result.Prefab.transform.Find("Plane");
			if (Object.op_Implicit((Object)(object)val3))
			{
				list.Add(((Component)val3).gameObject);
			}
			foreach (GameObject item in list)
			{
				Object.DestroyImmediate((Object)(object)item);
			}
			result.Parent = result.Prefab.GetComponent<EnemyParent>();
			result.Parent.enemyName = enemyName;
			result.Parent.enemyNameLocalized = null;
			result.Parent.difficulty = (Difficulty)Mathf.Clamp(Plugin.CfgDifficulty.Value - 1, 0, 2);
			result.Enemy = ((Component)result.Controller).GetComponent<Enemy>();
			result.Health = ((Component)result.Controller).GetComponent<EnemyHealth>();
			result.Health.spawnValuable = true;
			result.Erb = ((Component)result.Rigidbody).GetComponent<EnemyRigidbody>();
			Transform val4 = result.Rigidbody.Find("Collider");
			if (Object.op_Implicit((Object)(object)val4))
			{
				val4.localScale = Vector3.one;
				val4.localPosition = Vector3.zero;
				val4.localRotation = Quaternion.identity;
				result.Capsule = ((Component)val4).GetComponent<CapsuleCollider>();
			}
			if (!Object.op_Implicit((Object)(object)result.Capsule))
			{
				throw new Exception("Rugrat collider is not a capsule (game update?)");
			}
			new GameObject("Center of Mass").transform.SetParent(result.Rigidbody, false);
			result.Particles = result.Prefab.transform.Find("Particles");
			return result;
		}

		public void Body(float radius, float bottom, float top, float comY)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			float height = Mathf.Max(top - bottom, radius * 2f + 0.01f);
			((Component)Capsule).transform.localPosition = new Vector3(0f, (bottom + top) * 0.5f - 0.5f, 0f);
			Capsule.direction = 1;
			Capsule.radius = radius;
			Capsule.height = height;
			Capsule.center = Vector3.zero;
			Rigidbody.Find("Center of Mass").localPosition = new Vector3(0f, comY - 0.5f, 0f);
		}

		public void ParticleColors(Color a, Color b)
		{
			//IL_0022: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			if (Object.op_Implicit((Object)(object)Particles))
			{
				ParticleSystem[] componentsInChildren = ((Component)Particles).GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					MainModule main = componentsInChildren[i].main;
					((MainModule)(ref main)).startColor = new MinMaxGradient(a, b);
				}
			}
		}

		private static void Kill(Component c)
		{
			if ((Object)(object)c != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)c);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyDirector), "AmountSetup")]
	internal static class DirectorExcludePatch
	{
		private static void Prefix(EnemyDirector __instance)
		{
			if (Plugin.CfgPoolWeight.Value <= 0 && !((Object)(object)Plugin.Setup == (Object)null))
			{
				string name = ((Object)Plugin.Setup).name;
				if (Strip(__instance.enemiesDifficulty1, name) + Strip(__instance.enemiesDifficulty2, name) + Strip(__instance.enemiesDifficulty3, name) > 0)
				{
					Plugin.Log.LogInfo((object)"[Traqueur] Removed from the regular monster picks (PoolWeight = 0).");
				}
			}
		}

		private static int Strip(List<EnemySetup> list, string n)
		{
			return list?.RemoveAll((EnemySetup s) => (Object)(object)s == (Object)(object)Plugin.Setup || ((Object)(object)s != (Object)null && ((Object)s).name == n)) ?? 0;
		}
	}
	[BepInPlugin("maxime.repo.traqueur", "Traqueur", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "maxime.repo.traqueur";

		public const string NAME = "Traqueur";

		public const string VERSION = "1.0.0";

		internal const int DefaultTier = 3;

		internal const KeyCode DefaultKey = (KeyCode)286;

		internal static ConfigEntry<int> CfgHealth;

		internal static ConfigEntry<int> CfgBite;

		internal static ConfigEntry<float> CfgPatrolSpeed;

		internal static ConfigEntry<float> CfgRushSpeed;

		internal static ConfigEntry<float> CfgScanMin;

		internal static ConfigEntry<float> CfgScanMax;

		internal static ConfigEntry<float> CfgWarn;

		internal static ConfigEntry<float> CfgScanTime;

		internal static ConfigEntry<float> CfgGrace;

		internal static ConfigEntry<float> CfgThreshold;

		internal static ConfigEntry<float> CfgRange;

		internal static ConfigEntry<float> CfgObjectSpeed;

		internal static ConfigEntry<float> CfgPounce;

		internal static ConfigEntry<float> CfgPinTime;

		internal static ConfigEntry<float> CfgSniff;

		internal static ConfigEntry<float> CfgStunTime;

		internal static ConfigEntry<float> CfgHeavyMass;

		internal static ConfigEntry<float> CfgHeavySpeed;

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<int> CfgPoolWeight;

		internal static ConfigEntry<int> CfgSpawnChance;

		internal static ConfigEntry<int> CfgDifficulty;

		internal static ConfigEntry<bool> CfgDebugSpawn;

		internal static ConfigEntry<KeyCode> CfgDebugSpawnKey;

		internal const float MinPlayerDistance = 15f;

		internal static EnemySetup Setup;

		internal static GameObject Prefab;

		private static GameObject holder;

		private Harmony harmony;

		private float lastDebugSpawn = -10f;

		private LevelGenerator handledLevel;

		private float levelReadyTime = -1f;

		private float nextSpawnTry;

		private bool rolled;

		internal static GameObject Holder
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)holder == (Object)null)
				{
					holder = new GameObject("TraqueurPrefabHolder");
					holder.SetActive(false);
					((Object)holder).hideFlags = (HideFlags)61;
					Object.DontDestroyOnLoad((Object)(object)holder);
				}
				return holder;
			}
		}

		private static void BindModConfig(ConfigFile c)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Expected O, but got Unknown
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Expected O, but got Unknown
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Expected O, but got Unknown
			CfgHealth = c.Bind<int>("Traqueur", "Health", 300, new ConfigDescription("Hit points.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 3000), Array.Empty<object>()));
			CfgPatrolSpeed = c.Bind<float>("Traqueur", "PatrolSpeed", 3f, new ConfigDescription("Patrol speed (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			CfgRushSpeed = c.Bind<float>("Traqueur", "RushSpeed", 5.5f, new ConfigDescription("Speed when it rushes to where it heard something beyond pounce range (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 12f), Array.Empty<object>()));
			CfgScanMin = c.Bind<float>("Scan", "IntervalMin", 8f, new ConfigDescription("A scan every IntervalMin to IntervalMax seconds...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 60f), Array.Empty<object>()));
			CfgScanMax = c.Bind<float>("Scan", "IntervalMax", 12f, new ConfigDescription("...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 60f), Array.Empty<object>()));
			CfgWarn = c.Bind<float>("Scan", "Warning", 1f, new ConfigDescription("Warning before a scan: the pits glow, the clicks speed up (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			CfgScanTime = c.Bind<float>("Scan", "Duration", 2f, new ConfigDescription("Length of a scan (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			CfgGrace = c.Bind<float>("Scan", "Grace", 0.3f, new ConfigDescription("Nothing is detected during the first part of a scan (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			CfgThreshold = c.Bind<float>("Scan", "MoveThreshold", 1.2f, new ConfigDescription("Detects players moving faster than this (m/s, averaged over 0.3 s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 6f), Array.Empty<object>()));
			CfgRange = c.Bind<float>("Scan", "Range", 15f, new ConfigDescription("Hearing range of a scan (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 50f), Array.Empty<object>()));
			CfgObjectSpeed = c.Bind<float>("Scan", "ObjectSpeed", 3f, new ConfigDescription("Thrown or falling objects faster than this attract it (held objects never do) (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), Array.Empty<object>()));
			CfgPounce = c.Bind<float>("Attack", "PounceRange", 8f, new ConfigDescription("Pounces on what it heard within this range (m), otherwise rushes there.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 15f), Array.Empty<object>()));
			CfgPinTime = c.Bind<float>("Attack", "PinTime", 3f, new ConfigDescription("Pins its victim this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 15f), Array.Empty<object>()));
			CfgBite = c.Bind<int>("Attack", "BiteDamage", 60, new ConfigDescription("Damage of the bite when it pins someone.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			CfgSniff = c.Bind<float>("Attack", "SniffTime", 4f, new ConfigDescription("Sniffs this long where it landed when it caught nothing (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			CfgStunTime = c.Bind<float>("Counterplay", "StunTime", 4f, new ConfigDescription("A heavy hit while it pins someone stuns it this long and frees the victim (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			CfgHeavyMass = c.Bind<float>("Counterplay", "HeavyMass", 2f, new ConfigDescription("A heavy hit = a thrown or swung object of at least this mass (kg)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 50f), Array.Empty<object>()));
			CfgHeavySpeed = c.Bind<float>("Counterplay", "HeavySpeed", 4f, new ConfigDescription("...hitting it at least this fast (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>()));
			HeavyImpact.MinMass = CfgHeavyMass.Value;
			HeavyImpact.MinSpeed = CfgHeavySpeed.Value;
		}

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			CfgSpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "BonusChance", 0, new ConfigDescription("Optional extra copy ON TOP of the level's monsters: chance (%) per level, only if the normal draw did not pick it. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			CfgPoolWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "PoolWeight", 100, new ConfigDescription("Weight in the game's normal monster draw: it takes the place of a vanilla pick, never adds one. 100 = as likely as a standard vanilla monster, 0 = never drawn. Needs a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 300), Array.Empty<object>()));
			CfgDifficulty = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "DifficultyTier", 3, new ConfigDescription("Enemy tier (1-3): size of the orb it drops. Needs a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
			CfgDebugSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableSpawnKey", false, "Host only: the key brings the Traqueur 4 m in front of you (or spawns it).");
			CfgDebugSpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "SpawnKey", (KeyCode)286, "Debug spawn key.");
			BindModConfig(((BaseUnityPlugin)this).Config);
			Lang.Bind(((BaseUnityPlugin)this).Config);
			harmony = new Harmony("maxime.repo.traqueur");
			harmony.PatchAll(typeof(Plugin).Assembly);
			try
			{
				Kit.Init();
				Prefab = PrefabBuilder.Build();
				Register();
				Log.LogInfo((object)"Traqueur v1.0.0 loaded: enemy prefab built and registered with REPOLib.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to build/register the Traqueur: " + ex));
			}
		}

		private static void Register()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Setup = ScriptableObject.CreateInstance<EnemySetup>();
			((Object)Setup).name = "Enemy - Traqueur";
			((Object)Setup).hideFlags = (HideFlags)32;
			Setup.status = (Status)1;
			Setup.spawnObjects = new List<PrefabRef>();
			Setup.levelsCompletedCondition = false;
			Setup.levelsCompletedMin = 0;
			Setup.levelsCompletedMax = 10;
			RarityPreset val = ScriptableObject.CreateInstance<RarityPreset>();
			((Object)val).name = "Traqueur Rarity";
			val.chance = Mathf.Max(1f, (float)CfgPoolWeight.Value);
			((Object)val).hideFlags = (HideFlags)32;
			Setup.rarityPreset = val;
			EnemyContent val2 = ScriptableObject.CreateInstance<EnemyContent>();
			((Object)val2).name = "Traqueur";
			((Object)val2).hideFlags = (HideFlags)32;
			AccessTools.Field(typeof(EnemyContent), "_setup").SetValue(val2, Setup);
			AccessTools.Field(typeof(EnemyContent), "_spawnObjects").SetValue(val2, new List<GameObject> { Prefab });
			Enemies.RegisterEnemy(val2);
		}

		private void Update()
		{
			BonusSpawnTick();
			DebugKeyTick();
			Lang.Tick();
		}

		private void BonusSpawnTick()
		{
			//IL_010a: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Setup == (Object)null)
			{
				return;
			}
			LevelGenerator instance = LevelGenerator.Instance;
			if ((Object)(object)instance == (Object)null || !instance.Generated)
			{
				levelReadyTime = -1f;
			}
			else
			{
				if ((Object)(object)instance == (Object)(object)handledLevel)
				{
					return;
				}
				try
				{
					if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel())
					{
						handledLevel = instance;
						return;
					}
					if (levelReadyTime < 0f)
					{
						levelReadyTime = Time.time;
						rolled = false;
						nextSpawnTry = 0f;
						return;
					}
					float num = Time.time - levelReadyTime;
					if (num < 4f || Time.time < nextSpawnTry)
					{
						return;
					}
					nextSpawnTry = Time.time + 1f;
					if ((Object)(object)TraqueurAI.Existing() != (Object)null)
					{
						handledLevel = instance;
						return;
					}
					if (!rolled)
					{
						rolled = true;
						if (Random.Range(0, 100) >= CfgSpawnChance.Value)
						{
							handledLevel = instance;
							return;
						}
					}
					if (!TryQuietPoint(Vector3.zero, 0f, 999f, out var pos))
					{
						if (!(num < 29f))
						{
							handledLevel = instance;
						}
					}
					else
					{
						handledLevel = instance;
						TraqueurAI.SkipTeleportUntil = Time.time + 5f;
						Enemies.SpawnEnemy(Setup, pos, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), false);
						Log.LogInfo((object)string.Format("[{0}] Bonus copy spawned at {1}.", "Traqueur", pos));
					}
				}
				catch (Exception ex)
				{
					handledLevel = instance;
					Log.LogError((object)("[Traqueur] Level spawn failed: " + ex));
				}
			}
		}

		internal static bool TryQuietPoint(Vector3 from, float minD, float maxD, out Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			pos = Vector3.zero;
			List<LevelPoint> list = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null);
			if (list == null || list.Count == 0)
			{
				return false;
			}
			List<PlayerAvatar> list2 = SemiFunc.PlayerGetList();
			for (int i = 0; i < 60; i++)
			{
				LevelPoint val = list[Random.Range(0, list.Count)];
				if (!Object.op_Implicit((Object)(object)val) || val.Truck)
				{
					continue;
				}
				Vector3 position = ((Component)val).transform.position;
				if (from != Vector3.zero)
				{
					float num = Vector3.Distance(from, position);
					if (num < minD || num > maxD)
					{
						continue;
					}
				}
				bool flag = true;
				if (list2 != null)
				{
					foreach (PlayerAvatar item in list2)
					{
						if (Object.op_Implicit((Object)(object)item) && !item.isDisabled && Vector3.Distance(((Component)item).transform.position, position) < 15f)
						{
							flag = false;
							break;
						}
					}
				}
				if (flag || i >= 45)
				{
					pos = position + Vector3.up * 0.1f;
					return true;
				}
			}
			return false;
		}

		private void DebugKeyTick()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00a8: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00d1: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0102: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (!CfgDebugSpawn.Value || (Object)(object)Setup == (Object)null || !Input.GetKeyDown(CfgDebugSpawnKey.Value) || Time.unscaledTime - lastDebugSpawn < 0.75f)
			{
				return;
			}
			lastDebugSpawn = Time.unscaledTime;
			try
			{
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					Log.LogInfo((object)"[Debug] Only the host can spawn the Traqueur.");
					return;
				}
				if (!SemiFunc.RunIsLevel() || (Object)(object)PlayerAvatar.instance == (Object)null)
				{
					Log.LogInfo((object)"[Debug] Spawn key only works inside a level.");
					return;
				}
				Transform transform = ((Component)PlayerAvatar.instance).transform;
				Vector3 val = Vector3.ProjectOnPlane(transform.forward, Vector3.up);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Vector3 val2 = transform.position + normalized * 4f + Vector3.up * 0.2f;
				NavMeshHit val3 = default(NavMeshHit);
				if (NavMesh.SamplePosition(val2, ref val3, 3f, -1))
				{
					val2 = ((NavMeshHit)(ref val3)).position + Vector3.up * 0.1f;
				}
				TraqueurAI traqueurAI = TraqueurAI.Existing();
				if ((Object)(object)traqueurAI != (Object)null)
				{
					traqueurAI.DebugBring(val2);
					Log.LogInfo((object)string.Format("[Debug] {0} brought to {1}.", "Traqueur", val2));
					return;
				}
				TraqueurAI.SkipTeleportUntil = Time.time + 5f;
				Enemies.SpawnEnemy(Setup, val2, Quaternion.LookRotation(-normalized), false);
				handledLevel = LevelGenerator.Instance;
				Log.LogInfo((object)string.Format("[Debug] {0} spawned at {1}.", "Traqueur", val2));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[Debug] Spawn failed: " + ex));
			}
		}
	}
	internal static class Lang
	{
		internal static readonly string[] Codes = new string[21]
		{
			"en", "fr", "de", "es", "es-419", "it", "pt", "pt-BR", "ru", "uk",
			"pl", "tr", "ja", "ko", "zh-Hans", "zh-Hant", "ar", "da", "fi", "sv",
			"th"
		};

		internal static ConfigEntry<string> Cfg;

		private static string code = "en";

		private static float codeAt = -99f;

		private static float nextTick;

		internal static readonly Dictionary<string, string> NameTable = new Dictionary<string, string>
		{
			{ "en", "Stalker" },
			{ "fr", "Traqueur" },
			{ "de", "Pirscher" },
			{ "es", "Acechador" },
			{ "es-419", "Acechador" },
			{ "it", "Segugio" },
			{ "pt", "Perseguidor" },
			{ "pt-BR", "Perseguidor" },
			{ "ru", "Следопыт" },
			{ "uk", "Слідопит" },
			{ "pl", "Tropiciel" },
			{ "tr", "Avcı" },
			{ "ja", "追跡者" },
			{ "ko", "추적자" },
			{ "zh-Hans", "追猎者" },
			{ "zh-Hant", "追獵者" },
			{ "ar", "المتعق\u0651ب" },
			{ "da", "Forfølger" },
			{ "fi", "Vainooja" },
			{ "sv", "Spårare" },
			{ "th", "ผ\u0e39\u0e49ล\u0e48า" }
		};

		internal const bool HasMessages = false;

		internal static string Code
		{
			get
			{
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				if (Time.unscaledTime - codeAt < 1f)
				{
					return code;
				}
				codeAt = Time.unscaledTime;
				string text = ((Cfg != null) ? Cfg.Value : "Auto");
				if (string.IsNullOrEmpty(text) || text.Trim().Equals("Auto", StringComparison.OrdinalIgnoreCase))
				{
					text = "en";
					try
					{
						Locale selectedLocale = LocalizationSettings.SelectedLocale;
						if ((Object)(object)selectedLocale != (Object)null)
						{
							LocaleIdentifier identifier = selectedLocale.Identifier;
							text = ((LocaleIdentifier)(ref identifier)).Code;
						}
					}
					catch (Exception)
					{
					}
				}
				code = Normalize(text);
				return code;
			}
		}

		internal static string Name => Pick(NameTable);

		internal static void Bind(ConfigFile config)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			List<string> list = new List<string> { "Auto" };
			list.AddRange(Codes);
			Cfg = config.Bind<string>("Language", "Language", "Auto", new ConfigDescription("Language of this monster's in-game texts (its name when grabbed). Auto = the game's language (English if the game's language is not one of these).", (AcceptableValueBase)(object)new AcceptableValueList<string>(list.ToArray()), Array.Empty<object>()));
		}

		internal static void Tick()
		{
			if (Time.unscaledTime < nextTick)
			{
				return;
			}
			nextTick = Time.unscaledTime + 1f;
			try
			{
				string name = Name;
				if (Object.op_Implicit((Object)(object)Plugin.Prefab))
				{
					EnemyParent componentInChildren = Plugin.Prefab.GetComponentInChildren<EnemyParent>(true);
					if (Object.op_Implicit((Object)(object)componentInChildren))
					{
						componentInChildren.enemyName = name;
					}
				}
				foreach (TraqueurAI item in TraqueurAI.All)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						EnemyParent componentInParent = ((Component)item).GetComponentInParent<EnemyParent>(true);
						if (Object.op_Implicit((Object)(object)componentInParent) && componentInParent.enemyName != name)
						{
							componentInParent.enemyName = name;
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		internal static string Normalize(string c)
		{
			c = (c ?? "en").Trim().Replace('_', '-').ToLowerInvariant();
			if (c.StartsWith("zh"))
			{
				if (!c.Contains("hant") && !c.Contains("tw") && !c.Contains("hk") && !c.Contains("mo"))
				{
					return "zh-Hans";
				}
				return "zh-Hant";
			}
			if (c.StartsWith("es"))
			{
				if (!(c == "es") && !(c == "es-es"))
				{
					return "es-419";
				}
				return "es";
			}
			if (c.StartsWith("pt"))
			{
				if (!(c == "pt-br"))
				{
					return "pt";
				}
				return "pt-BR";
			}
			string text = ((c.Length >= 2) ? c.Substring(0, 2) : c);
			if (Array.IndexOf(Codes, text) < 0)
			{
				return "en";
			}
			return text;
		}

		internal static string Pick(Dictionary<string, string> t)
		{
			if (!t.TryGetValue(Code, out var value) || string.IsNullOrEmpty(value))
			{
				return t["en"];
			}
			return value;
		}
	}
	internal static class ModelLayout
	{
		public static readonly string[] Parts = new string[15]
		{
			"body", "head", "mand_l", "mand_r", "tail0", "tail1", "tail2", "leg_fl_u", "leg_fl_l", "leg_fr_u",
			"leg_fr_l", "leg_bl_u", "leg_bl_l", "leg_br_u", "leg_br_l"
		};

		public static readonly string[] Parents = new string[15]
		{
			"", "body", "head", "head", "body", "tail0", "tail1", "body", "leg_fl_u", "body",
			"leg_fr_u", "body", "leg_bl_u", "body", "leg_br_u"
		};

		public static readonly Vector3[] Pivots = (Vector3[])(object)new Vector3[15]
		{
			new Vector3(0f, 0.85f, 0f),
			new Vector3(0f, 0.92f, 0.62f),
			new Vector3(-0.08f, 0.86f, 0.95f),
			new Vector3(0.08f, 0.86f, 0.95f),
			new Vector3(0f, 0.83f, -0.78f),
			new Vector3(0f, 0.8f, -1.22f),
			new Vector3(0f, 0.76f, -1.62f),
			new Vector3(-0.19f, 0.86f, 0.38f),
			new Vector3(-0.46f, 1.22f, 0.55f),
			new Vector3(0.19f, 0.86f, 0.38f),
			new Vector3(0.46f, 1.22f, 0.55f),
			new Vector3(-0.19f, 0.84f, -0.48f),
			new Vector3(-0.48f, 1.12f, -0.62f),
			new Vector3(0.19f, 0.84f, -0.48f),
			new Vector3(0.48f, 1.12f, -0.62f)
		};

		public static readonly string[] Detached = new string[0];
	}
	internal static class Sounds
	{
		public static Sound Click;

		public static Sound Screech;

		public static Sound Bite;

		public static Sound Sniff;

		public static Sound Step;

		public static Sound Land;

		public static Sound Hiss;

		public static Sound Hurt;

		public static Sound Death;

		public static Sound Stun;
	}
	internal static class PrefabBuilder
	{
		internal const int M_CHITIN = 0;

		internal const int M_FLESH = 1;

		internal const int M_PIT = 2;

		internal const int M_BONE = 3;

		internal const int M_DARK = 4;

		public static GameObject Build()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			Shell shell = Shell.Make("Traqueur");
			CollectSounds();
			shell.Parent.SpawnedTimeMin = 240f;
			shell.Parent.SpawnedTimeMax = 360f;
			shell.Parent.DespawnedTimeMin = 60f;
			shell.Parent.DespawnedTimeMax = 120f;
			shell.Enemy.Type = (EnemyType)3;
			shell.Health.health = Plugin.CfgHealth.Value;
			shell.Health.objectHurtStun = false;
			shell.Erb.grabStun = false;
			shell.Erb.positionSpeedIdle = 8f;
			shell.Erb.positionSpeedChase = 8f;
			shell.Erb.distanceWarpIdle = 2f;
			shell.Erb.distanceWarpChase = 2f;
			shell.Erb.rotationSpeedIdle = 0.8f;
			shell.Erb.rotationSpeedChase = 0.8f;
			shell.Body(0.34f, 0f, 1.2f, 0.7f);
			shell.ParticleColors(new Color(0.55f, 0.08f, 0.06f), new Color(0.2f, 0.18f, 0.16f));
			Dictionary<string, Part> parts = Kit.LoadMeshes(Resource.Embedded("Traqueur.traqueur.mesh"));
			Kit.Materials = (Material[])(object)new Material[5]
			{
				Kit.Mat("Chitin", 0.82f, 0.2f, Color.black),
				Kit.Mat("Flesh", 0.45f, 0f, Color.black),
				Kit.Mat("Pit", 0.7f, 0f, new Color(1.2f, 0.45f, 0.15f)),
				Kit.Mat("Bone", 0.6f, 0f, Color.black),
				Kit.Mat("Dark", 0.4f, 0f, Color.black)
			};
			Transform transform = new GameObject("TraqueurModel").transform;
			transform.SetParent(shell.Visuals, false);
			transform.localPosition = new Vector3(0f, -0.5f, 0f);
			Dictionary<string, Transform> dictionary = Kit.Build(transform, parts, null);
			shell.Health.meshParent = transform;
			if (Object.op_Implicit((Object)(object)shell.VisionT))
			{
				shell.VisionT.localPosition = new Vector3(0f, 0.42000002f, 0.8f);
				shell.VisionT.localRotation = Quaternion.identity;
			}
			GameObject val = new GameObject("PitLight");
			val.transform.SetParent(dictionary["head"], false);
			val.transform.localPosition = new Vector3(0f, 0.12f, 0.25f);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(1f, 0.45f, 0.15f);
			obj.range = 3f;
			obj.intensity = 0.4f;
			obj.shadows = (LightShadows)0;
			((Component)shell.Controller).gameObject.AddComponent<TraqueurAI>();
			((Component)shell.Rigidbody).gameObject.AddComponent<HeavyImpact>();
			return shell.Prefab;
		}

		private static void CollectSounds()
		{
			try
			{
				Sounds.Click = Snd.Make("Click", 0.55f, 1f, 0.12f, "click_1", "click_2", "click_3");
				Sounds.Screech = Snd.Make("Screech", 1f, 1f, 0.06f, "screech");
				Sounds.Bite = Snd.Make("Bite", 1f, 1f, 0.06f, "bite");
				Sounds.Sniff = Snd.Make("Sniff", 0.7f, 1f, 0.1f, "sniff");
				Sounds.Step = Snd.Make("Step", 0.4f, 1f, 0.2f, "step_1", "step_2");
				Sounds.Land = Snd.Make("Land", 0.9f, 1f, 0.06f, "land");
				Sounds.Hiss = Snd.Make("Hiss", 0.7f, 1f, 0.08f, "hiss");
				Sounds.Hurt = Snd.Make("Hurt", 0.9f, 1f, 0.1f, "hurt");
				Sounds.Death = Snd.Make("Death", 1f, 1f, 0f, "death");
				Sounds.Stun = Snd.Make("Stun", 0.9f, 1f, 0.05f, "stun");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not prepare sounds: " + ex.Message));
			}
		}
	}
	public class TraqueurAI : MonoBehaviour, IHeavyHit
	{
		public enum State
		{
			Spawn,
			Patrol,
			Warn,
			Scan,
			Rush,
			Crouch,
			Leap,
			Pin,
			Sniff,
			Stunned
		}

		private const int EV_LAND = 1;

		private const int EV_BITE = 2;

		private const int EV_SNIFF = 3;

		private const float FootOffset = 0.5f;

		private Enemy enemy;

		private PhotonView photonView;

		private EnemyHealth health;

		private EnemyRigidbody erb;

		private Transform visuals;

		private Transform model;

		private Transform particles;

		private readonly Dictionary<string, Transform> J = new Dictionary<string, Transform>();

		private readonly List<(Renderer r, int sub)> pits = new List<(Renderer, int)>();

		private MaterialPropertyBlock mpb;

		private Light pitLight;

		private int losMask;

		private bool ready;

		public State state;

		private bool stateImpulse = true;

		private float stateTimer;

		private float stateTime;

		private PlayerAvatar victim;

		private Vector3 heardPoint;

		private float nextScan;

		private float pathTimer;

		private float patrolTimer;

		private float leapTimer;

		private float pinBiteDone;

		private float grabTime;

		private bool leapCaught;

		private bool rushRescan;

		private Vector3 patrolPoint;

		private Vector3 leapTarget;

		private PlayerAvatar leapPrey;

		private readonly Dictionary<int, Queue<Vector4>> tracks = new Dictionary<int, Queue<Vector4>>();

		private PhysGrabObject[] objects;

		private float objectsAt = -99f;

		private float t;

		private float walkPhase;

		private float bodySpeed;

		private float lastStepSin;

		private float clickTimer;

		private float glow;

		private float headYaw;

		private float mand;

		private Vector3 lastVisPos;

		internal static float SkipTeleportUntil;

		internal static readonly List<TraqueurAI> All = new List<TraqueurAI>();

		private readonly Dictionary<string, Vector3> pose = new Dictionary<string, Vector3>();

		private static readonly string[] Legs = new string[4] { "fl", "fr", "bl", "br" };

		private static readonly float[] LegPhase = new float[4]
		{
			0f,
			(float)Math.PI,
			(float)Math.PI,
			0f
		};

		private static readonly float[] LegSide = new float[4] { -1f, 1f, -1f, 1f };

		internal static TraqueurAI Existing()
		{
			All.RemoveAll((TraqueurAI a) => (Object)(object)a == (Object)null);
			if (All.Count <= 0)
			{
				return null;
			}
			return All[0];
		}

		private void Awake()
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			enemy = ((Component)this).GetComponent<Enemy>();
			photonView = ((Component)this).GetComponent<PhotonView>();
			health = ((Component)this).GetComponent<EnemyHealth>();
			Transform parent = ((Component)this).transform.parent;
			erb = ((Component)parent.Find("Rigidbody")).GetComponent<EnemyRigidbody>();
			visuals = parent.Find("Visuals");
			model = (Object.op_Implicit((Object)(object)visuals) ? visuals.Find("TraqueurModel") : null);
			particles = parent.parent.Find("Particles");
			if (Object.op_Implicit((Object)(object)model))
			{
				Transform[] componentsInChildren = ((Component)model).GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					if (Array.IndexOf(ModelLayout.Parts, ((Object)val).name) >= 0)
					{
						J[((Object)val).name] = val;
					}
				}
				MeshRenderer[] componentsInChildren2 = ((Component)model).GetComponentsInChildren<MeshRenderer>(true);
				foreach (MeshRenderer val2 in componentsInChildren2)
				{
					Material[] sharedMaterials = ((Renderer)val2).sharedMaterials;
					for (int j = 0; j < sharedMaterials.Length; j++)
					{
						if ((Object)(object)sharedMaterials[j] == (Object)(object)Kit.Materials[2])
						{
							pits.Add(((Renderer)(object)val2, j));
						}
					}
				}
				pitLight = ((Component)model).GetComponentInChildren<Light>(true);
			}
			mpb = new MaterialPropertyBlock();
			HeavyImpact component = ((Component)erb).GetComponent<HeavyImpact>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.ai = this;
			}
			EnemyStateSpawn component2 = ((Component)this).GetComponent<EnemyStateSpawn>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.OnSpawn.AddListener(new UnityAction(OnSpawn));
			}
			if (Object.op_Implicit((Object)(object)health))
			{
				health.onHurt.AddListener(new UnityAction(OnHurt));
				health.onDeath.AddListener(new UnityAction(OnDeath));
			}
			int num = 1 << ((Component)erb).gameObject.layer;
			Collider[] componentsInChildren3 = ((Component)erb).GetComponentsInChildren<Collider>(true);
			foreach (Collider val3 in componentsInChildren3)
			{
				num |= 1 << ((Component)val3).gameObject.layer;
			}
			losMask = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) & ~num & ~LayerMask.GetMask(new string[3] { "Player", "PhysGrabObject", "Enemy" });
			ready = Object.op_Implicit((Object)(object)model) && Object.op_Implicit((Object)(object)erb) && J.Count >= 15;
			if (!ready)
			{
				Plugin.Log.LogError((object)"TraqueurAI: hierarchy incomplete, behaviour disabled.");
			}
			All.Add(this);
		}

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

		private void OnEnable()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)erb))
			{
				lastVisPos = ((Component)erb).transform.position;
			}
		}

		private void Update()
		{
			if (ready)
			{
				float deltaTime = Time.deltaTime;
				t += deltaTime;
				if (U.Master)
				{
					MasterLogic(deltaTime);
				}
				if (Object.op_Implicit((Object)(object)victim) && victim.isLocal && state == State.Pin && Object.op_Implicit((Object)(object)victim.physGrabber))
				{
					victim.physGrabber.OverrideDisableSpecialGrabPowers(1f);
				}
			}
		}

		private void LateUpdate()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (ready)
			{
				visuals.position = ((Component)erb).transform.position;
				visuals.rotation = ((Component)erb).transform.rotation;
				Animate(Time.deltaTime);
			}
		}

		private void FixedUpdate()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			if (!ready || !U.Master)
			{
				return;
			}
			Rigidbody rb = erb.rb;
			if (!Object.op_Implicit((Object)(object)rb) || rb.isKinematic)
			{
				return;
			}
			if (state == State.Leap)
			{
				LeapFixed(rb);
			}
			if (!enemy.IsStunned() && erb.physGrabObject.playerGrabbing.Count == 0)
			{
				Vector3 val = Vector3.Cross(((Component)rb).transform.up, Vector3.up);
				Vector3 angularVelocity = rb.angularVelocity;
				rb.AddTorque(val * 60f - new Vector3(angularVelocity.x, 0f, angularVelocity.z) * 10f, (ForceMode)5);
			}
			if (state == State.Pin && U.Valid(victim) && Object.op_Implicit((Object)(object)victim.tumble))
			{
				PlayerTumble tumble = victim.tumble;
				if (!tumble.isTumbling)
				{
					tumble.TumbleRequest(true, false);
				}
				tumble.TumbleOverrideTime(1f);
				victim.FallDamageResetSet(0.1f);
				tumble.physGrabObject.OverrideMass(1f, 0.1f);
				tumble.physGrabObject.OverrideAngularDrag(2f, 0.1f);
				tumble.physGrabObject.OverrideDrag(1f, 0.1f);
				tumble.OverrideEnemyHurt(0.1f);
				Vector3 position = ((Component)erb).transform.position;
				Vector3 val2 = U.Flat(((Component)erb).transform.forward);
				Vector3 val3 = position + ((Vector3)(ref val2)).normalized * 0.75f + Vector3.down * 0.35f;
				Vector3 val4 = SemiFunc.PhysFollowPosition(((Component)tumble).transform.position, val3, tumble.rb.linearVelocity, 10f);
				tumble.rb.AddForce(val4 * (10f * Time.fixedDeltaTime), (ForceMode)1);
			}
		}

		private void MasterLogic(float dt)
		{
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: 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_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			stateTime += dt;
			TrackPlayers();
			GrabTick(dt);
			if (enemy.IsStunned() && state != State.Stunned)
			{
				ReleaseVictim();
				SetState(State.Stunned);
			}
			Vector3 val;
			switch (state)
			{
			case State.Spawn:
				if (stateImpulse)
				{
					stateImpulse = false;
					stateTimer = 2f;
				}
				Halt();
				if ((stateTimer -= dt) <= 0f)
				{
					NextScanIn();
					SetState(State.Patrol);
				}
				break;
			case State.Patrol:
				if (stateImpulse)
				{
					stateImpulse = false;
					patrolTimer = 0f;
				}
				Patrol(dt);
				if (Time.time >= nextScan)
				{
					SetState((Plugin.CfgWarn.Value > 0f) ? State.Warn : State.Scan);
				}
				break;
			case State.Warn:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				Halt();
				if (stateTime >= Plugin.CfgWarn.Value)
				{
					SetState(State.Scan);
				}
				break;
			case State.Scan:
				if (stateImpulse)
				{
					stateImpulse = false;
					RefreshObjects();
				}
				Halt();
				if ((!(stateTime >= Plugin.CfgGrace.Value) || !Listen()) && stateTime >= Plugin.CfgScanTime.Value)
				{
					NextScanIn();
					SetState(State.Patrol);
				}
				break;
			case State.Rush:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				GoTo(heardPoint, dt, Plugin.CfgRushSpeed.Value);
				FaceMove(dt, 10f);
				val = U.Flat(heardPoint - ((Component)erb).transform.position);
				if (((Vector3)(ref val)).magnitude < 1.2f || stateTime > 12f)
				{
					SetState(State.Scan);
				}
				break;
			case State.Crouch:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				Halt();
				Face(leapTarget - ((Component)erb).transform.position, dt, 20f);
				if (stateTime >= 0.25f)
				{
					StartLeap();
				}
				break;
			case State.Leap:
			{
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				if (!leapCaught && U.Valid(leapPrey) && Vector3.Distance(U.Body(leapPrey), ((Component)erb).transform.position) < 1.25f)
				{
					leapCaught = true;
				}
				leapTimer -= dt;
				bool flag = !enemy.HasGrounded || !Object.op_Implicit((Object)(object)enemy.Grounded) || enemy.Grounded.grounded;
				if (leapTimer <= 0f || (stateTime > 0.25f && flag && erb.rb.linearVelocity.y <= 0.1f))
				{
					Land();
				}
				break;
			}
			case State.Pin:
				if (stateImpulse)
				{
					stateImpulse = false;
					pinBiteDone = 0f;
				}
				Halt();
				if (!U.Valid(victim))
				{
					ReleaseVictim();
					SetState(State.Sniff);
					break;
				}
				if (pinBiteDone == 0f && stateTime >= 0.3f)
				{
					pinBiteDone = 1f;
					U.Hurt(victim, Plugin.CfgBite.Value, enemy);
					Plugin.Log.LogInfo((object)$"[Traqueur] Bit {victim.playerName} ({Plugin.CfgBite.Value}).");
					Event(2);
				}
				if (stateTime >= Plugin.CfgPinTime.Value)
				{
					PlayerAvatar val2 = victim;
					ReleaseVictim();
					if (U.Valid(val2))
					{
						val = U.Flat(((Component)erb).transform.forward);
						val2.ForceImpulse(((Vector3)(ref val)).normalized * 3f + Vector3.up * 2f);
					}
					NextScanIn();
					SetState(State.Patrol);
				}
				break;
			case State.Sniff:
				if (stateImpulse)
				{
					stateImpulse = false;
					Event(3);
				}
				Halt();
				if (stateTime >= Plugin.CfgSniff.Value)
				{
					NextScanIn();
					SetState(State.Patrol);
				}
				break;
			case State.Stunned:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				Halt();
				if (!enemy.IsStunned())
				{
					NextScanIn();
					SetState(State.Patrol);
				}
				break;
			}
		}

		private void NextScanIn()
		{
			nextScan = Time.time + Random.Range(Plugin.CfgScanMin.Value, Mathf.Max(Plugin.CfgScanMin.Value, Plugin.CfgScanMax.Value));
		}

		private void TrackPlayers()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			foreach (PlayerAvatar item in U.Players())
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					int key = U.Id(item);
					if (!tracks.TryGetValue(key, out var value))
					{
						value = (tracks[key] = new Queue<Vector4>());
					}
					Vector3 val = U.Body(item);
					value.Enqueue(new Vector4(val.x, val.y, val.z, time));
					while (value.Count > 2 && time - value.Peek().w > 0.35f)
					{
						value.Dequeue();
					}
				}
			}
		}

		private float SpeedOf(PlayerAvatar p)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			if (!tracks.TryGetValue(U.Id(p), out var value) || value.Count < 2)
			{
				return 0f;
			}
			Vector4 val = value.Peek();
			Vector4 val2 = Vector4.zero;
			foreach (Vector4 item in value)
			{
				val2 = item;
			}
			float num = val2.w - val.w;
			if (num < 0.2f)
			{
				return 0f;
			}
			return Vector3.Distance(Vector4.op_Implicit(val), Vector4.op_Implicit(val2)) / num;
		}

		private void RefreshObjects()
		{
			if (!(Time.time - objectsAt < 5f) || objects == null)
			{
				objectsAt = Time.time;
				objects = Object.FindObjectsOfType<PhysGrabObject>();
			}
		}

		private bool Listen()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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)
			Vector3 position = ((Component)erb).transform.position;
			float value = Plugin.CfgRange.Value;
			float value2 = Plugin.CfgThreshold.Value;
			PlayerAvatar val = null;
			float num = value;
			foreach (PlayerAvatar item in U.Players())
			{
				if (!U.Valid(item))
				{
					continue;
				}
				Vector3 val2 = U.Body(item);
				float num2 = Vector3.Distance(val2, position);
				if (!(num2 > num) && !(Mathf.Abs(val2.y - position.y) > 4f))
				{
					float num3 = SpeedOf(item);
					if (!(num3 <= value2))
					{
						num = num2;
						val = item;
						Plugin.Log.LogInfo((object)$"[Traqueur] Heard {item.playerName} moving at {num3:0.0} m/s ({num2:0.0} m).");
					}
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				React(U.Body(val), val);
				return true;
			}
			if (objects == null)
			{
				return false;
			}
			PhysGrabObject val3 = null;
			float num4 = value;
			PhysGrabObject[] array = objects;
			foreach (PhysGrabObject val4 in array)
			{
				if (!Object.op_Implicit((Object)(object)val4) || !Object.op_Implicit((Object)(object)val4.rb) || val4.rb.isKinematic || !((Component)val4).gameObject.activeInHierarchy || val4.playerGrabbing.Count > 0 || Object.op_Implicit((Object)(object)((Component)val4).GetComponent<PlayerTumble>()) || Object.op_Implicit((Object)(object)((Component)val4).GetComponentInParent<Enemy>()))
				{
					continue;
				}
				Vector3 linearVelocity = val4.rb.linearVelocity;
				if (!(((Vector3)(ref linearVelocity)).magnitude < Plugin.CfgObjectSpeed.Value))
				{
					float num5 = Vector3.Distance(val4.midPoint, position);
					if (num5 < num4)
					{
						num4 = num5;
						val3 = val4;
					}
				}
			}
			if (Object.op_Implicit((Object)(object)val3))
			{
				Plugin.Log.LogInfo((object)("[Traqueur] Heard an object: " + ((Object)val3).name + "."));
				React(val3.midPoint, null);
				return true;
			}
			return false;
		}

		private void React(Vector3 point, PlayerAvatar prey)
		{
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_008e: 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_00bd: 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)
			Vector3 val = point;
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.SamplePosition(point, ref val2, 2.5f, -1))
			{
				val = ((NavMeshHit)(ref val2)).position;
			}
			heardPoint = val;
			Vector3 a = ((Component)erb).transform.position + Vector3.up * 0.3f;
			Vector3 val3 = U.Flat(val - ((Component)erb).transform.position);
			float magnitude = ((Vector3)(ref val3)).magnitude;
			bool flag = !U.Blocked(a, point, losMask);
			if (magnitude <= Plugin.CfgPounce.Value && flag && Mathf.Abs(val.y - (((Component)erb).transform.position.y - 0.5f)) < 2.5f)
			{
				leapTarget = val;
				leapPrey = prey;
				SetState(State.Crouch);
			}
			else
			{
				SetState(State.Rush);
			}
		}

		private void StartLeap()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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)
			//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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			Rigidbody rb = erb.rb;
			float num = Mathf.Max(1f, 0f - Physics.gravity.y + ((erb.gravity && erb.customGravity > 0f && rb.useGravity) ? (erb.customGravity / Mathf.Max(0.1f, rb.mass)) : 0f));
			Vector3 position = rb.position;
			Vector3 val = leapTarget;
			if (U.Valid(leapPrey))
			{
				Vector3 val2 = U.Body(leapPrey);
				((Vector3)(ref val))..ctor(val2.x, leapTarget.y, val2.z);
			}
			Vector3 val3 = U.Flat(val - position);
			float num2 = Mathf.Min(((Vector3)(ref val3)).magnitude, Plugin.CfgPounce.Value + 0.5f);
			float num3 = val.y + 0.5f - position.y;
			float num4 = Mathf.Clamp(0.6f + num2 * 0.09f, 0.6f, 1.6f);
			num4 = Mathf.Max(num4, num3 + 0.4f);
			if (U.Raycast(position, Vector3.up, 8f, losMask, out var hit))
			{
				num4 = Mathf.Min(num4, Mathf.Max(0.25f, ((RaycastHit)(ref hit)).distance - 0.85f));
			}
			float num5 = Mathf.Sqrt(2f * num * num4);
			float num6 = num5 / num + Mathf.Sqrt(2f * Mathf.Max(0.05f, num4 - num3) / num);
			Vector3 normalized;
			if (!(((Vector3)(ref val3)).sqrMagnitude > 0.01f))
			{
				Vector3 val4 = U.Flat(((Component)erb).transform.forward);
				normalized = ((Vector3)(ref val4)).normalized;
			}
			else
			{
				normalized = ((Vector3)(ref val3)).normalized;
			}
			Vector3 val5 = normalized;
			rb.linearVelocity = val5 * Mathf.Clamp(num2 / num6, 0.5f, 14f) + Vector3.up * num5;
			erb.DisableFollowPosition(num6 + 0.15f, 10f);
			erb.WarpDisable(num6 + 0.6f);
			if (enemy.HasJump && Object.op_Implicit((Object)(object)enemy.Jump))
			{
				enemy.Jump.StuckDisable(num6 + 0.6f);
			}
			leapTimer = num6 + 0.5f;
			leapCaught = false;
			((Component)this).transform.rotation = Quaternion.LookRotation(val5, Vector3.up);
			SetState(State.Leap);
		}

		private void LeapFixed(Rigidbody rb)
		{
			if (stateTime < 0.1f)
			{
				erb.DisableFollowPosition(0.2f, 10f);
			}
		}

		private void Land()
		{
			//IL_0021: 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)
			StopAgentHere();
			if (!leapCaught && U.Valid(leapPrey) && Vector3.Distance(U.Body(leapPrey), ((Component)erb).transform.position) < 1.7f)
			{
				leapCaught = true;
			}
			if (leapCaught && U.Valid(leapPrey))
			{
				victim = leapPrey;
				Plugin.Log.LogInfo((object)("[Traqueur] Pinned " + victim.playerName));
				if (Object.op_Implicit((Object)(object)victim.tumble))
				{
					victim.tumble.TumbleRequest(true, false);
					victim.tumble.TumbleOverrideTime(Plugin.CfgPinTime.Value + 0.5f);
				}
				Event(1);
				SetState(State.Pin);
			}
			else
			{
				Event(1);
				SetState(State.Sniff);
			}
			leapPrey = null;
		}

		private void ReleaseVictim()
		{
			if (Object.op_Implicit((Object)(object)victim) && Object.op_Implicit((Object)(object)victim.tumble))
			{
				victim.tumble.TumbleOverrideTime(0.6f);
			}
			victim = null;
			SyncState();
		}

		private void Patrol(float dt)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_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)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			if (!((patrolTimer -= dt) <= 0f))
			{
				Vector3 val = U.Flat(patrolPoint - ((Component)erb).transform.position);
				if (!(((Vector3)(ref val)).magnitude < 1.5f))
				{
					goto IL_005e;
				}
			}
			patrolTimer = 20f;
			patrolPoint = PickPatrolPoint();
			goto IL_005e;
			IL_005e:
			GoTo(patrolPoint, dt, Plugin.CfgPatrolSpeed.Value);
			FaceMove(dt, 6f);
		}

		private Vector3 PickPatrolPoint()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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)
			List<LevelPoint> list = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null);
			if (list == null || list.Count == 0)
			{
				return ((Component)erb).transform.position;
			}
			Vector3 result = ((Component)erb).transform.position;
			float num = float.MinValue;
			List<PlayerAvatar> list2 = U.Players();
			for (int i = 0; i < 12; i++)
			{
				LevelPoint val = list[Random.Range(0, list.Count)];
				if (!Object.op_Implicit((Object)(object)val) || val.Truck)
				{
					continue;
				}
				Vector3 position = ((Component)val).transform.position;
				float num2 = Vector3.Distance(position, ((Component)erb).transform.position);
				if (num2 < 6f)
				{
					continue;
				}
				float num3 = 99f;
				foreach (PlayerAvatar item in list2)
				{
					if (U.Valid(item))
					{
						num3 = Mathf.Min(num3, Vector3.Distance(((Component)item).transform.position, position));
					}
				}
				float num4 = ((num3 < 25f) ? 10f : 0f) - num2 * 0.05f + Random.Range(0f, 6f);
				if (num4 > num)
				{
					num = num4;
					result = position;
				}
			}
			return result;
		}

		private void GoTo(Vector3 p, float dt, float speed)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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)
			if ((pathTimer -= dt) <= 0f)
			{
				pathTimer = 0.3f;
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(p, ref val, 2f, -1))
				{
					p = ((NavMeshHit)(ref val)).position;
				}
				enemy.NavMeshAgent.SetDestination(p);
			}
			enemy.NavMeshAgent.OverrideAgent(speed, speed * 4f, 0.4f);
		}

		private void Halt()
		{
			enemy.NavMeshAgent.Stop(0.2f);
		}

		private void StopAgentHere()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			enemy.NavMeshAgent.Warp(((Component)erb).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
		}

		private void FaceMove(float dt, float speed)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Vector3 agentVelocity = enemy.NavMeshAgent.AgentVelocity;