Decompiled source of Mannequin v1.0.0

Mannequin.dll

Decompiled 44 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 Mannequin
{
	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("Mannequin." + 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("Mannequin.atlas.png"), false);
			((Object)Atlas).name = "Mannequin 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 = "Mannequin " + 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 = "Mannequin " + 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)"[Mannequin] 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.mannequin", "Mannequin", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "maxime.repo.mannequin";

		public const string NAME = "Mannequin";

		public const string VERSION = "1.0.0";

		internal const int DefaultTier = 3;

		internal const KeyCode DefaultKey = (KeyCode)285;

		internal static ConfigEntry<int> CfgHealth;

		internal static ConfigEntry<int> CfgDamage;

		internal static ConfigEntry<int> CfgHitsToBreak;

		internal static ConfigEntry<float> CfgSpeed;

		internal static ConfigEntry<float> CfgWanderSpeed;

		internal static ConfigEntry<float> CfgViewAngle;

		internal static ConfigEntry<float> CfgViewRange;

		internal static ConfigEntry<float> CfgGrace;

		internal static ConfigEntry<float> CfgFocusTime;

		internal static ConfigEntry<float> CfgBoredTime;

		internal static ConfigEntry<float> CfgAttackRange;

		internal static ConfigEntry<float> CfgKnockdown;

		internal static ConfigEntry<float> CfgHeavyMass;

		internal static ConfigEntry<float> CfgHeavySpeed;

		internal static ConfigEntry<bool> CfgBoredAfterHit;

		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("MannequinPrefabHolder");
					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_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Expected O, but got Unknown
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Expected O, but got Unknown
			CfgHealth = c.Bind<int>("Mannequin", "Health", 250, new ConfigDescription("Hit points.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 3000), Array.Empty<object>()));
			CfgSpeed = c.Bind<float>("Mannequin", "Speed", 3f, new ConfigDescription("Speed when nobody looks at it while it hunts (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			CfgWanderSpeed = c.Bind<float>("Mannequin", "WanderSpeed", 2f, new ConfigDescription("Speed when it has lost interest and wanders (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			CfgViewAngle = c.Bind<float>("Watching", "ViewAngle", 40f, new ConfigDescription("A player freezes it when it is within this angle from the centre of their screen (degrees)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 90f), Array.Empty<object>()));
			CfgViewRange = c.Bind<float>("Watching", "ViewRange", 20f, new ConfigDescription("...within this distance (m), with a clear line of sight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 60f), Array.Empty<object>()));
			CfgGrace = c.Bind<float>("Watching", "Grace", 0.3f, new ConfigDescription("Delay before it moves once nobody looks at it (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			CfgFocusTime = c.Bind<float>("Mannequin", "FocusTime", 40f, new ConfigDescription("Hunts the same player this long (s)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f), Array.Empty<object>()));
			CfgBoredTime = c.Bind<float>("Mannequin", "BoredTime", 30f, new ConfigDescription("...then loses interest this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f), Array.Empty<object>()));
			CfgBoredAfterHit = c.Bind<bool>("Mannequin", "BoredAfterHit", true, "After a successful hit it also loses interest (fairer than hitting a downed player again).");
			CfgDamage = c.Bind<int>("Attack", "Damage", 70, new ConfigDescription("Damage of its blow (knocks the player down).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			CfgAttackRange = c.Bind<float>("Attack", "Range", 1.3f, new ConfigDescription("Reach of its blow (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 3f), Array.Empty<object>()));
			CfgKnockdown = c.Bind<float>("Attack", "KnockdownTime", 2.5f, new ConfigDescription("The victim stays down this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			CfgHitsToBreak = c.Bind<int>("Counterplay", "HeavyHitsToBreak", 3, new ConfigDescription("Heavy hits that take it apart: left arm, right arm, then the head.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), 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 Mannequin 4 m in front of you (or spawns it).");
			CfgDebugSpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "SpawnKey", (KeyCode)285, "Debug spawn key.");
			BindModConfig(((BaseUnityPlugin)this).Config);
			Lang.Bind(((BaseUnityPlugin)this).Config);
			harmony = new Harmony("maxime.repo.mannequin");
			harmony.PatchAll(typeof(Plugin).Assembly);
			try
			{
				Kit.Init();
				Prefab = PrefabBuilder.Build();
				Register();
				Log.LogInfo((object)"Mannequin v1.0.0 loaded: enemy prefab built and registered with REPOLib.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to build/register the Mannequin: " + 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 - Mannequin";
			((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 = "Mannequin 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 = "Mannequin";
			((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)MannequinAI.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;
						MannequinAI.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}.", "Mannequin", pos));
					}
				}
				catch (Exception ex)
				{
					handledLevel = instance;
					Log.LogError((object)("[Mannequin] 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 Mannequin.");
					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;
				}
				MannequinAI mannequinAI = MannequinAI.Existing();
				if ((Object)(object)mannequinAI != (Object)null)
				{
					mannequinAI.DebugBring(val2);
					Log.LogInfo((object)string.Format("[Debug] {0} brought to {1}.", "Mannequin", val2));
					return;
				}
				MannequinAI.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}.", "Mannequin", 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", "Mannequin" },
			{ "fr", "Mannequin" },
			{ "de", "Gliederpuppe" },
			{ "es", "Maniquí" },
			{ "es-419", "Maniquí" },
			{ "it", "Manichino" },
			{ "pt", "Manequim" },
			{ "pt-BR", "Manequim" },
			{ "ru", "Манекен" },
			{ "uk", "Манекен" },
			{ "pl", "Manekin" },
			{ "tr", "Manken" },
			{ "ja", "マネキン" },
			{ "ko", "마네킹" },
			{ "zh-Hans", "木头人" },
			{ "zh-Hant", "木頭人" },
			{ "ar", "المانيكان" },
			{ "da", "Mannequin" },
			{ "fi", "Mallinukke" },
			{ "sv", "Skyltdocka" },
			{ "th", "ห\u0e38\u0e48นไม\u0e49" }
		};

		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 (MannequinAI item in MannequinAI.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;
		}
	}
	public class MannequinAI : MonoBehaviour, IHeavyHit
	{
		public enum State
		{
			Spawn,
			Hunt,
			Bored,
			Strike
		}

		private const int EV_BLOW = 1;

		private const int EV_WHIFF = 2;

		private const int EV_LIMB = 3;

		private static readonly string[] LimbOrder = new string[3] { "upperarm_l", "upperarm_r", "head" };

		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 int losMask;

		private bool ready;

		public State state;

		private bool stateImpulse = true;

		private float stateTimer;

		private float stateTime;

		private PlayerAvatar target;

		private int broken;

		private float watchTimer;

		private float unseenTime;

		private float focusUntil;

		private float boredUntil;

		private float pathTimer;

		private float strikeReady;

		private float syncTimer;

		private float lastHeavy;

		private float wanderTimer;

		private bool watched = true;

		private bool struck;

		private bool boredNext;

		private Vector3 wanderPoint;

		private float t;

		private float walkPhase;

		private float bodySpeed;

		private float movingTime;

		private float creakTimer;

		private float lastStepSin;

		private float headTilt;

		private float headTiltWant;

		private float reach;

		private float reachWant;

		private Vector3 lastVisPos;

		private bool wasMoving;

		internal static float SkipTeleportUntil;

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

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

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

		private void Awake()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_01c9: 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("MannequinModel") : 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;
					}
				}
			}
			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[] componentsInChildren2 = ((Component)erb).GetComponentsInChildren<Collider>(true);
			foreach (Collider val2 in componentsInChildren2)
			{
				num |= 1 << ((Component)val2).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)"MannequinAI: 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)
			{
				t += Time.deltaTime;
				if (U.Master)
				{
					MasterLogic(Time.deltaTime);
				}
			}
		}

		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_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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0053: 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_005e: 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_006f: 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)
			if (ready && U.Master)
			{
				Rigidbody rb = erb.rb;
				if (Object.op_Implicit((Object)(object)rb) && !rb.isKinematic && !Grabbed())
				{
					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);
				}
			}
		}

		private void MasterLogic(float dt)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			stateTime += dt;
			if ((watchTimer -= dt) <= 0f)
			{
				watchTimer = 0.05f;
				watched = Watched();
			}
			if (watched)
			{
				unseenTime = 0f;
			}
			else
			{
				unseenTime += dt;
			}
			bool flag = !watched && unseenTime >= Plugin.CfgGrace.Value && !Grabbed() && !enemy.IsStunned();
			if ((syncTimer -= dt) <= 0f)
			{
				syncTimer = 0.2f;
				if (!flag && Vector3.Distance(((Component)enemy.NavMeshAgent).transform.position, ((Component)erb).transform.position) > 0.35f)
				{
					StopAgentHere();
				}
			}
			switch (state)
			{
			case State.Spawn:
				if (stateImpulse)
				{
					stateImpulse = false;
					stateTimer = 2f;
				}
				Halt();
				if ((stateTimer -= dt) <= 0f)
				{
					SetState(State.Hunt);
				}
				break;
			case State.Hunt:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				if (!U.Valid(target))
				{
					PlayerAvatar val = PickTarget();
					if (Object.op_Implicit((Object)(object)val))
					{
						target = val;
						focusUntil = Time.time + Plugin.CfgFocusTime.Value;
						SyncState();
					}
				}
				if (Object.op_Implicit((Object)(object)target) && Time.time > focusUntil)
				{
					SetState(State.Bored);
					break;
				}
				if (!flag)
				{
					Halt();
					break;
				}
				if (!Object.op_Implicit((Object)(object)target))
				{
					Wander(dt, Plugin.CfgWanderSpeed.Value);
					break;
				}
				GoTo(((Component)target).transform.position, dt, Plugin.CfgSpeed.Value);
				Face(((Component)target).transform.position - ((Component)erb).transform.position, dt, 18f);
				if (Time.time >= strikeReady && InReach(target, Plugin.CfgAttackRange.Value))
				{
					SetState(State.Strike);
				}
				break;
			case State.Strike:
				if (stateImpulse)
				{
					stateImpulse = false;
					struck = false;
				}
				Halt();
				if (!struck && watched)
				{
					SetState(State.Hunt);
					break;
				}
				if (U.Valid(target))
				{
					Face(((Component)target).transform.position - ((Component)erb).transform.position, dt, 25f);
				}
				if (!struck && stateTime >= 0.28f)
				{
					struck = true;
					Blow();
				}
				if (stateTime >= 0.75f)
				{
					SetState((!boredNext) ? State.Hunt : State.Bored);
				}
				break;
			case State.Bored:
				if (stateImpulse)
				{
					stateImpulse = false;
					boredNext = false;
					target = null;
					boredUntil = Time.time + Plugin.CfgBoredTime.Value;
					wanderTimer = 0f;
					SyncState();
				}
				if (flag)
				{
					Wander(dt, Plugin.CfgWanderSpeed.Value);
				}
				else
				{
					Halt();
				}
				if (Time.time > boredUntil)
				{
					SetState(State.Hunt);
				}
				break;
			}
		}

		private bool Watched()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0074: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			float value = Plugin.CfgViewRange.Value;
			float cosA = Mathf.Cos(Plugin.CfgViewAngle.Value * ((float)Math.PI / 180f));
			Vector3 pt = J["head"].position + Vector3.up * 0.1f;
			Vector3 val = J["torso"].position + Vector3.up * 0.25f;
			Vector3 position = J["shin_l"].position;
			if (broken >= 3)
			{
				pt = val;
			}
			foreach (PlayerAvatar item in U.Players())
			{
				if (U.Valid(item))
				{
					CameraOf(item, out var pos, out var fwd);
					if (Sees(pos, fwd, pt, value, cosA) || Sees(pos, fwd, val, value, cosA) || Sees(pos, fwd, position, value, cosA))
					{
						return true;
					}
				}
			}
			return false;
		}

		private bool Sees(Vector3 cam, Vector3 fwd, Vector3 pt, float range, float cosA)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0029: 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)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = pt - cam;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > range || magnitude < 0.01f)
			{
				return magnitude < 0.01f;
			}
			if (Vector3.Dot(fwd, val / magnitude) < cosA)
			{
				return false;
			}
			return !U.Blocked(cam, pt, losMask);
		}

		private static void CameraOf(PlayerAvatar p, out Vector3 pos, out Vector3 fwd)
		{
			//IL_0074: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_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_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_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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (p.isLocal)
			{
				Camera main = Camera.main;
				if (Object.op_Implicit((Object)(object)main))
				{
					pos = ((Component)main).transform.position;
					fwd = ((Component)main).transform.forward;
					return;
				}
				if (Object.op_Implicit((Object)(object)p.localCamera))
				{
					pos = ((Component)p.localCamera).transform.position;
					fwd = ((Component)p.localCamera).transform.forward;
					return;
				}
			}
			else if (p.clientCameraPosition != Vector3.zero)
			{
				pos = p.clientCameraPosition;
				fwd = p.clientCameraRotation * Vector3.forward;
				return;
			}
			pos = ((Component)p).transform.position + Vector3.up * 1.5f;
			fwd = ((Component)p).transform.forward;
		}

		private PlayerAvatar PickTarget()
		{
			//IL_002b: 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)
			PlayerAvatar val = null;
			float num = 60f;
			foreach (PlayerAvatar item in U.Players())
			{
				if (U.Valid(item))
				{
					float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)erb).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = item;
					}
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				Plugin.Log.LogInfo((object)("[Mannequin] Hunting " + val.playerName));
			}
			return val;
		}

		private bool InReach(PlayerAvatar p, float range)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)p).transform.position - ((Component)erb).transform.position;
			if (Mathf.Abs(val.y + 0.5f) < 1.6f)
			{
				Vector3 val2 = U.Flat(val);
				return ((Vector3)(ref val2)).magnitude < range;
			}
			return false;
		}

		private void Blow()
		{
			//IL_0047: 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_0066: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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)
			//IL_009b: 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)
			PlayerAvatar val = target;
			if (!U.Valid(val) || !InReach(val, Plugin.CfgAttackRange.Value + 0.5f))
			{
				Event(2);
				strikeReady = Time.time + 1f;
				return;
			}
			Vector3 val2 = U.Flat(((Component)val).transform.position - ((Component)erb).transform.position);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			U.Hurt(val, Plugin.CfgDamage.Value, enemy);
			val.ForceImpulse(normalized * 6f + Vector3.up * 2.5f);
			if (Plugin.CfgKnockdown.Value > 0f && Object.op_Implicit((Object)(object)val.tumble))
			{
				val.tumble.TumbleRequest(true, false);
				val.tumble.TumbleOverrideTime(Plugin.CfgKnockdown.Value);
			}
			Plugin.Log.LogInfo((object)$"[Mannequin] Hit {val.playerName} ({Plugin.CfgDamage.Value}).");
			Event(1);
			strikeReady = Time.time + 3f;
			if (Plugin.CfgBoredAfterHit.Value)
			{
				boredNext = true;
			}
		}

		private void Wander(float dt, float speed)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			if (!((wanderTimer -= dt) <= 0f))
			{
				Vector3 val = U.Flat(wanderPoint - ((Component)erb).transform.position);
				if (!(((Vector3)(ref val)).magnitude < 1.5f))
				{
					goto IL_0104;
				}
			}
			wanderTimer = 20f;
			wanderPoint = ((Component)erb).transform.position;
			List<LevelPoint> list = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null);
			if (list != null && list.Count > 0)
			{
				for (int i = 0; i < 10; i++)
				{
					LevelPoint val2 = list[Random.Range(0, list.Count)];
					if (Object.op_Implicit((Object)(object)val2) && !val2.Truck && Vector3.Distance(((Component)val2).transform.position, ((Component)erb).transform.position) > 8f)
					{
						wanderPoint = ((Component)val2).transform.position;
						break;
					}
				}
			}
			goto IL_0104;
			IL_0104:
			GoTo(wanderPoint, dt, speed);
			Vector3 agentVelocity = enemy.NavMeshAgent.AgentVelocity;
			if (((Vector3)(ref agentVelocity)).sqrMagnitude > 0.04f)
			{
				Face(agentVelocity, dt, 12f);
			}
		}

		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, 40f, 0.3f);
		}

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

		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 bool Grabbed()
		{
			if (Object.op_Implicit((Object)(object)erb.physGrabObject))
			{
				return erb.physGrabObject.playerGrabbing.Count > 0;
			}
			return false;
		}

		private void Face(Vector3 dir, float dt, float speed)
		{
			//IL_0027: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			dir.y = 0f;
			if (!(((Vector3)(ref dir)).sqrMagnitude < 0.0001f))
			{
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(((Vector3)(ref dir)).normalized, Vector3.up), 1f - Mathf.Exp((0f - speed) * dt));
			}
		}

		public void HeavyHit(PhysGrabObject by, float speed, Vector3 point)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00e3: 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)
			if (!(Time.time - lastHeavy < 0.6f) && state != State.Spawn && !health.dead)
			{
				lastHeavy = Time.time;
				int value = Plugin.CfgHitsToBreak.Value;
				broken++;
				Plugin.Log.LogInfo((object)$"[Mannequin] Heavy hit by {((Object)by).name} ({by.rb.mass:0.0} kg at {speed:0.0} m/s): {broken}/{value}.");
				SyncState();
				Event(3);
				if (broken >= value)
				{
					EnemyHealth obj = health;
					int num = health.healthCurrent + 50;
					Vector3 val = ((Component)erb).transform.position - point;
					obj.Hurt(num, ((Vector3)(ref val)).normalized);
				}
			}
		}

		private void SetState(State s)
		{
			if (s != state)
			{
				ApplyState(s);
				SyncState();
			}
		}

		private void SyncState()
		{
			if (U.MP)
			{
				photonView.RPC("MannequinStateRPC", (RpcTarget)1, new object[3]
				{
					(int)state,
					U.Id(target),
					broken
				});
			}
		}

		[PunRPC]
		private void MannequinStateRPC(int s, int targetId, int brokenCount, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(info))
			{
				target = U.Find(targetId);
				SetBroken(brokenCount);
				if (s != (int)state)
				{
					ApplyState((State)s);
				}
			}
		}

		private void ApplyState(State s)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			State state = this.state;
			this.state = s;
			stateImpulse = true;
			stateTimer = 0f;
			stateTime = 0f;
			if (U.Master)
			{
				Plugin.Log.LogInfo((object)$"[Mannequin] {state} -> {s}");
			}
			if (s == State.Strike)
			{
				Snd.Play(Sounds.Swing, ((Component)erb).transform.position, 0.9f);
			}
		}

		private void Event(int ev)
		{
			//IL_0040: 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)
			if (U.MP)
			{
				photonView.RPC("MannequinEventRPC", (RpcTarget)0, new object[2] { ev, broken });
			}
			else
			{
				MannequinEventRPC(ev, broken);
			}
		}

		[PunRPC]
		private void MannequinEventRPC(int ev, int brokenCount, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(info))
			{
				Vector3 position = ((Component)erb).transform.position;
				switch (ev)
				{
				case 1:
					Snd.Play(Sounds.Blow, position);
					U.Shake(position, 6f, 0.4f, 2f, 8f);
					break;
				case 2:
					Snd.Play(Sounds.Creak, position, 0.8f, 1.2f);
					break;
				case 3:
					Snd.Play(Sounds.Crack, position);
					SetBroken(brokenCount);
					break;
				}
			}
		}

		private void SetBroken(int n)
		{
			n = Mathf.Clamp(n, 0, LimbOrder.Length);
			for (int i = 0; i < LimbOrder.Length; i++)
			{
				if (J.TryGetValue(LimbOrder[i], out var value))
				{
					bool flag = i < n && i < Plugin.CfgHitsToBreak.Value;
					if (flag && ((Component)value).gameObject.activeSelf)
					{
						DropLimb(value);
					}
					((Component)value).gameObject.SetActive(!flag);
				}
			}
			broken = n;
		}

		private void DropLimb(Transform limb)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Mannequin Limb");
			val.transform.SetPositionAndRotation(limb.position, limb.rotation);
			MeshFilter[] componentsInChildren = ((Component)limb).GetComponentsInChildren<MeshFilter>(false);
			foreach (MeshFilter val2 in componentsInChildren)
			{
				GameObject val3 = new GameObject(((Object)val2).name);
				val3.transform.SetParent(val.transform, true);
				val3.transform.SetPositionAndRotation(((Component)val2).transform.position, ((Component)val2).transform.rotation);
				val3.AddComponent<MeshFilter>().sharedMesh = val2.sharedMesh;
				((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).sharedMaterials;
			}
			CapsuleCollider obj = val.AddComponent<CapsuleCollider>();
			obj.direction = 1;
			obj.radius = 0.06f;
			obj.height = ((((Object)limb).name == "head") ? 0.3f : 0.6f);
			obj.center = new Vector3(0f, (((Object)limb).name == "head") ? 0.12f : (-0.28f), 0f);
			Rigidbody obj2 = val.AddComponent<Rigidbody>();
			obj2.mass = 2f;
			obj2.linearVelocity = (Object.op_Implicit((Object)(object)erb.rb) ? erb.rb.linearVelocity : Vector3.zero);
			Vector3 val4 = limb.position - ((Component)erb).transform.position;
			obj2.AddForce(((Vector3)(ref val4)).normalized * 2f + Vector3.up * 1.5f, (ForceMode)2);
			obj2.AddTorque(Random.insideUnitSphere * 6f, (ForceMode)2);
			U.DestroyLater(val, 25f);
		}

		private void OnSpawn()
		{
			//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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (Object.op_Implicit((Object)(object)erb))
			{
				lastVisPos = ((Component)erb).transform.position;
			}
			SetBroken(0);
			if (!U.Master)
			{
				return;
			}
			bool flag = Time.time < SkipTeleportUntil;
			if (flag)
			{
				SkipTeleportUntil = 0f;
			}
			if (!flag && Plugin.TryQuietPoint(Vector3.zero, 0f, 999f, out var pos))
			{
				enemy.EnemyTeleported(pos);
				flag = true;
			}
			if (!flag)
			{
				flag = SemiFunc.EnemySpawn(enemy);
			}
			if (flag)
			{
				target = null;
				broken = 0;
				boredNext = false;
				Plugin.Log.LogInfo((object)("[Mannequin] Spawned at " + ((object)((Component)erb).transform.position/*cast due to .constrained prefix*/).ToString()));
				if (state == State.Spawn)
				{
					stateImpulse = true;
					stateTimer = 0f;
					stateTime = 0f;
					SyncState();
				}
				else
				{
					SetState(State.Spawn);
				}
			}
		}

		internal void DebugBring(Vector3 pos)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			EnemyParent enemyParent = enemy.EnemyParent;
			if (Object.op_Implicit((Object)(object)enemyParent) && !enemyParent.Spawned)
			{
				SkipTeleportUntil = Time.time + 5f;
				enemyParent.Spawn();
			}
			enemy.EnemyTeleported(pos);
			target = null;
			SetState(State.Spawn);
		}

		private void OnHurt()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Snd.Play(Sounds.Hurt, ((Component)erb).transform.position, 0.8f);
		}

		private void OnDeath()
		{
			//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_0016: 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)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)erb).transform.position;
			Snd.Play(Sounds.Collapse, position);
			if (Object.op_Implicit((Object)(object)particles))
			{
				particles.position = position + Vector3.up * 0.6f;
				ParticleSystem[] componentsInChildren = ((Component)particles).GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].Play(true);
				}
			}
			string[] array = new string[5] { "upperarm_l", "upperarm_r", "head", "thigh_l", "thigh_r" };
			foreach (string key in array)
			{
				if (J.TryGetValue(key, out var value) && ((Component)value).gameObject.activeSelf)
				{
					DropLimb(value);
				}
			}
			if (U.Master)
			{
				enemy.EnemyParent.Despawn();
			}
		}

		private void P(string j, float x, float y = 0f, float z = 0f)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			pose[j] = new Vector3(x, y, z);
		}

		private void Blend(string j, float x, float y, float z, float w)
		{
			//IL_0017: 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_0018: 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_0025: 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)
			Vector3 value;
			Vector3 val = (pose.TryGetValue(j, out value) ? value : Vector3.zero);
			pose[j] = Vector3.Lerp(val, new Vector3(x, y, z), w);
		}

		private void Animate(float dt)
		{
			//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_002f: 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_0036: 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_0042: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: 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_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0726: Unknown result type (might be due to invalid IL or missing references)
			if (dt <= 0f)
			{
				return;
			}
			if (!U.Master)
			{
				stateTime += dt;
			}
			Vector3 position = ((Component)erb).transform.position;
			Vector3 val = U.Flat(position - lastVisPos);
			lastVisPos = position;
			float num = ((Vector3)(ref val)).magnitude / dt;
			if (num > 15f)
			{
				num = 0f;
				val = Vector3.zero;
			}
			bodySpeed = U.Damp(bodySpeed, num, 10f, dt);
			bool flag = num > 0.35f || state == State.Strike;
			if (flag)
			{
				movingTime += dt;
				if ((creakTimer -= dt) <= 0f)
				{
					creakTimer = Random.Range(0.45f, 1f);
					Snd.Play(Sounds.Creak, position + Vector3.up * 0.6f, 0.75f, Random.Range(0.85f, 1.15f));
				}
				walkPhase += ((Vector3)(ref val)).magnitude / 1.5f * (float)Math.PI * 2f;
				headTiltWant = (Mathf.PerlinNoise(walkPhase * 0.13f, 7.3f) - 0.5f) * 90f;
				reachWant = Mathf.PerlinNoise(walkPhase * 0.11f, 2.1f);
				headTilt = U.Damp(headTilt, headTiltWant, 8f, dt);
				reach = U.Damp(reach, reachWant, 6f, dt);
				wasMoving = flag;
				float num2 = Mathf.Sin(walkPhase);
				float num3 = Mathf.Cos(walkPhase);
				float num4 = Mathf.Clamp01(bodySpeed / 2.5f);
				if (num4 > 0.2f && Mathf.Sign(num2) != Mathf.Sign(lastStepSin))
				{
					Snd.Play(Sounds.Step, position - Vector3.up * 0.45f, 0.5f, Random.Range(0.9f, 1.1f));
				}
				lastStepSin = num2;
				pose.Clear();
				float num5 = 34f * num4;
				float num6 = 55f * num4;
				P("thigh_l", (0f - num5) * num2 - 4f);
				P("thigh_r", num5 * num2 - 4f);
				P("shin_l", num6 * Mathf.Pow(Mathf.Max(0f, num3), 1.2f) + 6f * num4);
				P("shin_r", num6 * Mathf.Pow(Mathf.Max(0f, 0f - num3), 1.2f) + 6f * num4);
				P("foot_l", (0f - (pose["thigh_l"].x + pose["shin_l"].x)) * 0.8f);
				P("foot_r", (0f - (pose["thigh_r"].x + pose["shin_r"].x)) * 0.8f);
				P("pelvis", 0f, 8f * num4 * num2);
				P("torso", 10f + 10f * num4 + 8f * reach, -10f * num4 * num2, 3f * Mathf.Sin(walkPhase * 0.5f));
				float num7 = -55f - 30f * reach;
				P("upperarm_l", num7 + 12f * num2, 0f, 6f);
				P("forearm_l", -15f - 20f * (1f - reach));
				P("hand_l", 15f);
				P("upperarm_r", num7 - 12f * num2, 0f, -6f);
				P("forearm_r", -20f - 15f * (1f - reach));
				P("hand_r", 20f);
				P("head", 8f, 0f, headTilt);
				float num8 = -0.03f * num4 * Mathf.Abs(num3);
				if (state == State.Strike)
				{
					float x = stateTime;
					float w = U.Smooth(0f, 0.2f, x) * (1f - U.Smooth(0.22f, 0.32f, x));
					float w2 = U.Smooth(0.22f, 0.32f, x) * (1f - U.Smooth(0.55f, 0.75f, x));
					Blend("upperarm_l", -150f, 0f, 10f, w);
					Blend("upperarm_r", -150f, 0f, -10f, w);
					Blend("torso", -8f, 0f, 0f, w);
					Blend("upperarm_l", -60f, 0f, 4f, w2);
					Blend("upperarm_r", -60f, 0f, -4f, w2);
					Blend("forearm_l", -5f, 0f, 0f, w2);
					Blend("forearm_r", -5f, 0f, 0f, w2);
					Blend("torso", 30f, 0f, 0f, w2);
				}
				foreach (KeyValuePair<string, Vector3> item in pose)
				{
					if (J.TryGetValue(item.Key, out var value))
					{
						value.localRotation = Quaternion.Euler(item.Value);
					}
				}
				model.localPosition = new Vector3(0f, -0.5f + num8, 0f);
			}
			else
			{
				if (wasMoving && movingTime > 0.25f)
				{
					Snd.Play(Sounds.Freeze, position + Vector3.up * 0.8f, 0.6f, Random.Range(0.9f, 1.1f));
				}
				movingTime = 0f;
				wasMoving = false;
			}
		}
	}
	internal static class ModelLayout
	{
		public static readonly string[] Parts = new string[15]
		{
			"pelvis", "torso", "head", "upperarm_l", "forearm_l", "hand_l", "upperarm_r", "forearm_r", "