Decompiled source of Wendigo v1.0.0

Wendigo.dll

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

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

		public const string NAME = "Wendigo";

		public const string VERSION = "1.0.0";

		internal const int DefaultTier = 3;

		internal const KeyCode DefaultKey = (KeyCode)287;

		internal static ConfigEntry<int> CfgHealth;

		internal static ConfigEntry<int> CfgBite;

		internal static ConfigEntry<int> CfgIceHits;

		internal static ConfigEntry<float> CfgSpeed;

		internal static ConfigEntry<float> CfgSense;

		internal static ConfigEntry<float> CfgFrostRange;

		internal static ConfigEntry<float> CfgFillFar;

		internal static ConfigEntry<float> CfgFillNear;

		internal static ConfigEntry<float> CfgDecay;

		internal static ConfigEntry<float> CfgSlow;

		internal static ConfigEntry<float> CfgFreezeTime;

		internal static ConfigEntry<float> CfgStunTime;

		internal static ConfigEntry<float> CfgHeavyMass;

		internal static ConfigEntry<float> CfgHeavySpeed;

		internal static ConfigEntry<float> CfgDimRange;

		internal static ConfigEntry<float> CfgDim;

		internal static ConfigEntry<float> CfgIceHitSpeed;

		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("WendigoPrefabHolder");
					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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Expected O, but got Unknown
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Expected O, but got Unknown
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Expected O, but got Unknown
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Expected O, but got Unknown
			CfgHealth = c.Bind<int>("Wendigo", "Health", 350, new ConfigDescription("Hit points.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 3000), Array.Empty<object>()));
			CfgSpeed = c.Bind<float>("Wendigo", "Speed", 2f, new ConfigDescription("Walking speed (m/s). It never runs.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 8f), Array.Empty<object>()));
			CfgSense = c.Bind<float>("Wendigo", "SenseRange", 20f, new ConfigDescription("Senses the nearest player through walls within this range (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 80f), Array.Empty<object>()));
			CfgBite = c.Bind<int>("Wendigo", "BiteDamage", 45, new ConfigDescription("Damage of its bite.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			CfgFrostRange = c.Bind<float>("Frost", "Range", 10f, new ConfigDescription("Your frost gauge fills while it sees you within this range (m)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), Array.Empty<object>()));
			CfgFillFar = c.Bind<float>("Frost", "FillTimeFar", 12f, new ConfigDescription("...in this time at the edge of the range (s)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
			CfgFillNear = c.Bind<float>("Frost", "FillTimeNear", 4f, new ConfigDescription("...and in this time at 2 m (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 60f), Array.Empty<object>()));
			CfgDecay = c.Bind<float>("Frost", "DecayTime", 5f, new ConfigDescription("A full gauge empties in this time once out of its sight (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 60f), Array.Empty<object>()));
			CfgSlow = c.Bind<float>("Frost", "SlowFromHalf", 0.7f, new ConfigDescription("Speed multiplier once the gauge is half full.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			CfgFreezeTime = c.Bind<float>("Frost", "FreezeTime", 5f, new ConfigDescription("A full gauge traps you in ice this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>()));
			CfgIceHits = c.Bind<int>("Frost", "IceHits", 2, new ConfigDescription("Hits with an object (thrown or swung) a teammate needs to break the ice.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
			CfgIceHitSpeed = c.Bind<float>("Frost", "IceHitSpeed", 2.5f, new ConfigDescription("Minimum speed of the object for a hit on the ice (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), Array.Empty<object>()));
			CfgDimRange = c.Bind<float>("Atmosphere", "LightDimRange", 7f, new ConfigDescription("Lights within this range of it dim (m, 0 = off).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			CfgDim = c.Bind<float>("Atmosphere", "LightDimMin", 0.2f, new ConfigDescription("Brightness left to the lights right next to it (0-1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			CfgStunTime = c.Bind<float>("Counterplay", "StunTime", 5f, new ConfigDescription("A heavy hit stuns it this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			CfgHeavyMass = c.Bind<float>("Counterplay", "HeavyMass", 2f, new ConfigDescription("A heavy hit = a thrown or swung object of at least this mass (kg)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 50f), Array.Empty<object>()));
			CfgHeavySpeed = c.Bind<float>("Counterplay", "HeavySpeed", 4f, new ConfigDescription("...hitting it at least this fast (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>()));
			HeavyImpact.MinMass = CfgHeavyMass.Value;
			HeavyImpact.MinSpeed = CfgHeavySpeed.Value;
		}

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			CfgSpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "BonusChance", 0, new ConfigDescription("Optional extra copy ON TOP of the level's monsters: chance (%) per level, only if the normal draw did not pick it. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			CfgPoolWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "PoolWeight", 100, new ConfigDescription("Weight in the game's normal monster draw: it takes the place of a vanilla pick, never adds one. 100 = as likely as a standard vanilla monster, 0 = never drawn. Needs a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 300), Array.Empty<object>()));
			CfgDifficulty = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "DifficultyTier", 3, new ConfigDescription("Enemy tier (1-3): size of the orb it drops. Needs a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
			CfgDebugSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableSpawnKey", false, "Host only: the key brings the Wendigo 4 m in front of you (or spawns it).");
			CfgDebugSpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "SpawnKey", (KeyCode)287, "Debug spawn key.");
			BindModConfig(((BaseUnityPlugin)this).Config);
			Lang.Bind(((BaseUnityPlugin)this).Config);
			harmony = new Harmony("maxime.repo.wendigo");
			harmony.PatchAll(typeof(Plugin).Assembly);
			try
			{
				Kit.Init();
				Prefab = PrefabBuilder.Build();
				Register();
				Log.LogInfo((object)"Wendigo v1.0.0 loaded: enemy prefab built and registered with REPOLib.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to build/register the Wendigo: " + 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 - Wendigo";
			((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 = "Wendigo 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 = "Wendigo";
			((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)WendigoAI.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;
						WendigoAI.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}.", "Wendigo", pos));
					}
				}
				catch (Exception ex)
				{
					handledLevel = instance;
					Log.LogError((object)("[Wendigo] 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 Wendigo.");
					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;
				}
				WendigoAI wendigoAI = WendigoAI.Existing();
				if ((Object)(object)wendigoAI != (Object)null)
				{
					wendigoAI.DebugBring(val2);
					Log.LogInfo((object)string.Format("[Debug] {0} brought to {1}.", "Wendigo", val2));
					return;
				}
				WendigoAI.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}.", "Wendigo", 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", "Wendigo" },
			{ "fr", "Wendigo" },
			{ "de", "Wendigo" },
			{ "es", "Wendigo" },
			{ "es-419", "Wendigo" },
			{ "it", "Wendigo" },
			{ "pt", "Wendigo" },
			{ "pt-BR", "Wendigo" },
			{ "ru", "Вендиго" },
			{ "uk", "Вендіго" },
			{ "pl", "Wendigo" },
			{ "tr", "Wendigo" },
			{ "ja", "ウェンディゴ" },
			{ "ko", "웬디고" },
			{ "zh-Hans", "温迪戈" },
			{ "zh-Hant", "溫迪戈" },
			{ "ar", "ويندغو" },
			{ "da", "Wendigo" },
			{ "fi", "Wendigo" },
			{ "sv", "Wendigo" },
			{ "th", "เวนด\u0e34โก" }
		};

		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 (WendigoAI item in WendigoAI.All)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						EnemyParent componentInParent = ((Component)item).GetComponentInParent<EnemyParent>(true);
						if (Object.op_Implicit((Object)(object)componentInParent) && componentInParent.enemyName != name)
						{
							componentInParent.enemyName = name;
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

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

		internal static string Pick(Dictionary<string, string> t)
		{
			if (!t.TryGetValue(Code, out var value) || string.IsNullOrEmpty(value))
			{
				return t["en"];
			}
			return value;
		}
	}
	internal static class ModelLayout
	{
		public static readonly string[] Parts = new string[17]
		{
			"pelvis", "torso", "head", "jaw", "upperarm_l", "forearm_l", "hand_l", "upperarm_r", "forearm_r", "hand_r",
			"thigh_l", "shin_l", "meta_l", "thigh_r", "shin_r", "meta_r", "ice"
		};

		public static readonly string[] Parents = new string[17]
		{
			"", "pelvis", "torso", "head", "torso", "upperarm_l", "forearm_l", "torso", "upperarm_r", "forearm_r",
			"pelvis", "thigh_l", "shin_l", "pelvis", "thigh_r", "shin_r", ""
		};

		public static readonly Vector3[] Pivots = (Vector3[])(object)new Vector3[17]
		{
			new Vector3(0f, 1.1f, 0f),
			new Vector3(0f, 1.16f, 0f),
			new Vector3(0f, 1.98f, 0.06f),
			new Vector3(0f, 1.95f, 0.14f),
			new Vector3(-0.23f, 1.82f, 0f),
			new Vector3(-0.25f, 1.4f, 0f),
			new Vector3(-0.26f, 0.98f, 0f),
			new Vector3(0.23f, 1.82f, 0f),
			new Vector3(0.25f, 1.4f, 0f),
			new Vector3(0.26f, 0.98f, 0f),
			new Vector3(-0.12f, 1.07f, 0f),
			new Vector3(-0.13f, 0.68f, 0.1f),
			new Vector3(-0.13f, 0.33f, -0.13f),
			new Vector3(0.12f, 1.07f, 0f),
			new Vector3(0.13f, 0.68f, 0.1f),
			new Vector3(0.13f, 0.33f, -0.13f),
			new Vector3(0f, 0f, 0f)
		};

		public static readonly string[] Detached = new string[1] { "ice" };
	}
	internal static class Sounds
	{
		public static Sound Wind;

		public static Sound Step;

		public static Sound Growl;

		public static Sound Bite;

		public static Sound Freeze;

		public static Sound Crack;

		public static Sound Shatter;

		public static Sound Frost;

		public static Sound Hurt;

		public static Sound Death;

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

		internal const int M_BONE = 1;

		internal const int M_DARK = 2;

		internal const int M_EYE = 3;

		internal const int M_FUR = 4;

		internal const int M_ICE = 5;

		internal static Part IcePart;

		public static GameObject Build()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			Shell shell = Shell.Make("Wendigo");
			CollectSounds();
			shell.Parent.SpawnedTimeMin = 240f;
			shell.Parent.SpawnedTimeMax = 360f;
			shell.Parent.DespawnedTimeMin = 60f;
			shell.Parent.DespawnedTimeMax = 120f;
			shell.Enemy.Type = (EnemyType)3;
			shell.Health.health = Plugin.CfgHealth.Value;
			shell.Health.objectHurtStun = false;
			shell.Erb.grabStun = false;
			shell.Erb.positionSpeedIdle = 5f;
			shell.Erb.positionSpeedChase = 5f;
			shell.Erb.distanceWarpIdle = 1.5f;
			shell.Erb.distanceWarpChase = 1.5f;
			shell.Erb.rotationSpeedIdle = 0.6f;
			shell.Erb.rotationSpeedChase = 0.6f;
			shell.Body(0.26f, 0f, 1.85f, 1.05f);
			shell.ParticleColors(new Color(0.75f, 0.88f, 1f), new Color(0.35f, 0.3f, 0.28f));
			Dictionary<string, Part> parts = Kit.LoadMeshes(Resource.Embedded("Wendigo.wendigo.mesh"));
			Kit.Materials = (Material[])(object)new Material[6]
			{
				Kit.Mat("Skin", 0.4f, 0f, Color.black),
				Kit.Mat("Bone", 0.55f, 0f, Color.black),
				Kit.Mat("Dark", 0.5f, 0f, Color.black),
				Kit.Mat("Eye", 0.8f, 0f, new Color(2.4f, 3.4f, 4f)),
				Kit.Mat("Fur", 0.05f, 0f, Color.black),
				Kit.Mat("Ice", 0.95f, 0f, new Color(0.25f, 0.32f, 0.38f), 0.6f)
			};
			Transform transform = new GameObject("WendigoModel").transform;
			transform.SetParent(shell.Visuals, false);
			transform.localPosition = new Vector3(0f, -0.5f, 0f);
			Dictionary<string, Part> dictionary = new Dictionary<string, Part>();
			Dictionary<string, Transform> dictionary2 = Kit.Build(transform, parts, dictionary);
			IcePart = dictionary["ice"];
			shell.Health.meshParent = transform;
			if (Object.op_Implicit((Object)(object)shell.VisionT))
			{
				shell.VisionT.localPosition = new Vector3(0f, 1.45f, 0.2f);
				shell.VisionT.localRotation = Quaternion.identity;
			}
			GameObject val = new GameObject("EyeLight");
			val.transform.SetParent(dictionary2["head"], false);
			val.transform.localPosition = new Vector3(0f, 0.02f, 0.18f);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(0.6f, 0.85f, 1f);
			obj.range = 3.5f;
			obj.intensity = 1.2f;
			obj.shadows = (LightShadows)0;
			Snd.Source(transform, "Wendigo Wind", 2f, 16f);
			((Component)shell.Controller).gameObject.AddComponent<WendigoAI>();
			((Component)shell.Rigidbody).gameObject.AddComponent<HeavyImpact>();
			return shell.Prefab;
		}

		private static void CollectSounds()
		{
			try
			{
				Sounds.Wind = Snd.Make("Wind", 0.5f, 1f, 0f, "wind");
				Sounds.Step = Snd.Make("Step", 0.5f, 1f, 0.15f, "step_1", "step_2", "step_3");
				Sounds.Growl = Snd.Make("Growl", 0.8f, 1f, 0.1f, "growl_1", "growl_2");
				Sounds.Bite = Snd.Make("Bite", 1f, 1f, 0.08f, "bite");
				Sounds.Freeze = Snd.Make("Freeze", 0.9f, 1f, 0.05f, "freeze");
				Sounds.Crack = Snd.Make("Crack", 1f, 1f, 0.1f, "crack");
				Sounds.Shatter = Snd.Make("Shatter", 1f, 1f, 0.05f, "shatter");
				Sounds.Frost = Snd.Make("Frost", 0.6f, 0f, 0f, "frost");
				Sounds.Hurt = Snd.Make("Hurt", 0.9f, 1f, 0.1f, "hurt");
				Sounds.Death = Snd.Make("Death", 1f, 1f, 0f, "death");
				Sounds.Stun = Snd.Make("Stun", 0.9f, 1f, 0.05f, "stun");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not prepare sounds: " + ex.Message));
			}
		}
	}
	public class IceBlock : MonoBehaviour
	{
		internal WendigoAI ai;

		internal int victimId;

		private readonly Dictionary<Rigidbody, float> last = new Dictionary<Rigidbody, float>();

		private void OnTriggerEnter(Collider 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)
			if (!Object.op_Implicit((Object)(object)ai) || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			Rigidbody attachedRigidbody = c.attachedRigidbody;
			if (Object.op_Implicit((Object)(object)attachedRigidbody) && !attachedRigidbody.isKinematic && !((Object)(object)((Component)attachedRigidbody).GetComponent<PhysGrabObject>() == (Object)null) && !Object.op_Implicit((Object)(object)((Component)attachedRigidbody).GetComponent<PlayerAvatar>()) && !Object.op_Implicit((Object)(object)((Component)attachedRigidbody).GetComponentInParent<PlayerTumble>()))
			{
				Vector3 linearVelocity = attachedRigidbody.linearVelocity;
				if (!(((Vector3)(ref linearVelocity)).magnitude < Plugin.CfgIceHitSpeed.Value) && (!last.TryGetValue(attachedRigidbody, out var value) || !(Time.time - value < 0.4f)))
				{
					last[attachedRigidbody] = Time.time;
					ai.IceHit(victimId);
				}
			}
		}
	}
	public class WendigoAI : MonoBehaviour, IHeavyHit
	{
		public enum State
		{
			Spawn,
			Roam,
			Stalk,
			Bite,
			Stunned
		}

		private const int EV_GROWL = 1;

		private const int EV_BITE = 2;

		private const int EV_CRACK = 3;

		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 Light eyeLight;

		private Sound wind;

		private AudioSource windSrc;

		private int losMask;

		private bool ready;

		public State state;

		private bool stateImpulse = true;

		private float stateTimer;

		private float stateTime;

		private PlayerAvatar target;

		private readonly Dictionary<int, float> frozenUntil = new Dictionary<int, float>();

		private readonly Dictionary<int, int> iceHits = new Dictionary<int, int>();

		private float pathTimer;

		private float biteReady;

		private float roamTimer;

		private float growlTimer;

		private float pickTimer;

		private float grabTime;

		private bool bitDone;

		private Vector3 roamPoint;

		private readonly Dictionary<int, GameObject> ice = new Dictionary<int, GameObject>();

		private float t;

		private float walkPhase;

		private float bodySpeed;

		private float lastStepSin;

		private float headYaw;

		private float headPitch;

		private float jaw;

		private float eyeGlow = 1f;

		private Vector3 lastVisPos;

		internal static float SkipTeleportUntil;

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

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

		internal Vector3 Position
		{
			get
			{
				//IL_0024: 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)
				if (!Object.op_Implicit((Object)(object)erb))
				{
					return ((Component)this).transform.position;
				}
				return ((Component)erb).transform.position;
			}
		}

		internal Light EyeLight => eyeLight;

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

		private void Awake()
		{
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_0224: 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("WendigoModel") : 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;
					}
				}
				eyeLight = ((Component)model).GetComponentInChildren<Light>(true);
				Transform val2 = model.Find("Wendigo Wind");
				windSrc = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).GetComponent<AudioSource>() : null);
				wind = Snd.Loop(Sounds.Wind, windSrc, 0.5f);
			}
			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 val3 in componentsInChildren2)
			{
				num |= 1 << ((Component)val3).gameObject.layer;
			}
			losMask = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) & ~num & ~LayerMask.GetMask(new string[3] { "Player", "PhysGrabObject", "Enemy" });
			ready = Object.op_Implicit((Object)(object)model) && Object.op_Implicit((Object)(object)erb) && J.Count >= 16;
			if (!ready)
			{
				Plugin.Log.LogError((object)"WendigoAI: hierarchy incomplete, behaviour disabled.");
			}
			All.Add(this);
		}

		private void Start()
		{
			Snd.Route(windSrc);
		}

		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 OnDisable()
		{
			Frost.Release(this);
			foreach (KeyValuePair<int, GameObject> item in ice)
			{
				if (Object.op_Implicit((Object)(object)item.Value))
				{
					Object.Destroy((Object)(object)item.Value);
				}
			}
			ice.Clear();
			frozenUntil.Clear();
		}

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

		private void Update()
		{
			if (ready)
			{
				float deltaTime = Time.deltaTime;
				t += deltaTime;
				if (U.Master)
				{
					MasterLogic(deltaTime);
				}
				Frost.Tick(this, deltaTime);
				Snd.PlayLoop(wind, state != State.Spawn && !health.dead, 2f, 2f, (state == State.Stalk) ? 1f : 0.9f);
			}
		}

		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)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (!ready)
			{
				return;
			}
			visuals.position = ((Component)erb).transform.position;
			visuals.rotation = ((Component)erb).transform.rotation;
			Animate(Time.deltaTime);
			foreach (KeyValuePair<int, GameObject> item in ice)
			{
				PlayerAvatar val = U.Find(item.Key);
				if (Object.op_Implicit((Object)(object)item.Value) && Object.op_Implicit((Object)(object)val))
				{
					item.Value.transform.position = ((Component)val).transform.position;
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0070: 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_007b: 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_0096: 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)
			if (ready && U.Master)
			{
				Rigidbody rb = erb.rb;
				if (Object.op_Implicit((Object)(object)rb) && !rb.isKinematic && !enemy.IsStunned() && erb.physGrabObject.playerGrabbing.Count <= 0)
				{
					Vector3 val = Vector3.Cross(((Component)rb).transform.up, Vector3.up);
					Vector3 angularVelocity = rb.angularVelocity;
					rb.AddTorque(val * 60f - new Vector3(angularVelocity.x, 0f, angularVelocity.z) * 10f, (ForceMode)5);
				}
			}
		}

		private void MasterLogic(float dt)
		{
			//IL_025b: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			stateTime += dt;
			if (enemy.IsStunned() && state != State.Stunned)
			{
				SetState(State.Stunned);
			}
			FrozenTick();
			GrabTick(dt);
			switch (state)
			{
			case State.Spawn:
				if (stateImpulse)
				{
					stateImpulse = false;
					stateTimer = 2f;
				}
				Halt();
				if ((stateTimer -= dt) <= 0f)
				{
					SetState(State.Roam);
				}
				break;
			case State.Roam:
				if (stateImpulse)
				{
					stateImpulse = false;
					roamTimer = 0f;
					target = null;
					SyncState();
				}
				if ((pickTimer -= dt) <= 0f)
				{
					pickTimer = 0.5f;
					PlayerAvatar val = PickTarget();
					if (Object.op_Implicit((Object)(object)val))
					{
						target = val;
						SetState(State.Stalk);
						break;
					}
				}
				Roam(dt);
				break;
			case State.Stalk:
				if (stateImpulse)
				{
					stateImpulse = false;
					growlTimer = Random.Range(3f, 7f);
				}
				if ((pickTimer -= dt) <= 0f)
				{
					pickTimer = 0.5f;
					PlayerAvatar val3 = PickTarget();
					if (!Object.op_Implicit((Object)(object)val3))
					{
						SetState(State.Roam);
						break;
					}
					if ((Object)(object)val3 != (Object)(object)target)
					{
						target = val3;
						SyncState();
					}
				}
				if (!U.Valid(target))
				{
					SetState(State.Roam);
					break;
				}
				GoTo(((Component)target).transform.position, dt, Plugin.CfgSpeed.Value);
				FaceMove(dt);
				if ((growlTimer -= dt) <= 0f)
				{
					growlTimer = Random.Range(6f, 12f);
					Event(1, -1);
				}
				if (Time.time >= biteReady && InReach(target, 1.35f))
				{
					SetState(State.Bite);
				}
				break;
			case State.Bite:
				if (stateImpulse)
				{
					stateImpulse = false;
					bitDone = false;
				}
				Halt();
				if (U.Valid(target))
				{
					Face(((Component)target).transform.position - ((Component)erb).transform.position, dt, 14f);
				}
				if (!bitDone && stateTime >= 0.38f)
				{
					bitDone = true;
					biteReady = Time.time + 2.5f;
					if (U.Valid(target) && InReach(target, 1.9f))
					{
						U.Hurt(target, Plugin.CfgBite.Value, enemy);
						PlayerAvatar obj = target;
						Vector3 val2 = U.Flat(((Component)target).transform.position - ((Component)erb).transform.position);
						obj.ForceImpulse(((Vector3)(ref val2)).normalized * 3f + Vector3.up * 1f);
						Plugin.Log.LogInfo((object)$"[Wendigo] Bit {target.playerName} ({Plugin.CfgBite.Value}).");
						Event(2, U.Id(target));
						if (frozenUntil.ContainsKey(U.Id(target)))
						{
							Unfreeze(U.Id(target));
						}
					}
				}
				if (stateTime >= 0.95f)
				{
					SetState(State.Stalk);
				}
				break;
			case State.Stunned:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				Halt();
				if (!enemy.IsStunned())
				{
					SetState((!Object.op_Implicit((Object)(object)target)) ? State.Roam : State.Stalk);
				}
				break;
			}
		}

		private PlayerAvatar PickTarget()
		{
			//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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)erb).transform.position;
			PlayerAvatar val = null;
			float num = float.MaxValue;
			foreach (PlayerAvatar item in U.Players())
			{
				if (U.Valid(item) && frozenUntil.ContainsKey(U.Id(item)))
				{
					float num2 = Vector3.Distance(((Component)item).transform.position, position);
					if (num2 < 30f && num2 < num)
					{
						num = num2;
						val = item;
					}
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			num = Plugin.CfgSense.Value;
			foreach (PlayerAvatar item2 in U.Players())
			{
				if (U.Valid(item2))
				{
					float num3 = Vector3.Distance(((Component)item2).transform.position, position);
					if (num3 < num)
					{
						num = num3;
						val = item2;
					}
				}
			}
			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 Roam(float dt)
		{
			//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_0102: 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_00d2: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (!((roamTimer -= dt) <= 0f))
			{
				Vector3 val = U.Flat(roamPoint - ((Component)erb).transform.position);
				if (!(((Vector3)(ref val)).magnitude < 1.5f))
				{
					goto IL_0100;
				}
			}
			roamTimer = 25f;
			roamPoint = ((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)
					{
						roamPoint = ((Component)val2).transform.position;
						break;
					}
				}
			}
			goto IL_0100;
			IL_0100:
			GoTo(roamPoint, dt, Plugin.CfgSpeed.Value * 0.7f);
			FaceMove(dt);
		}

		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.4f;
				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, 6f, 0.5f);
		}

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

		private void FaceMove(float dt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Vector3 agentVelocity = enemy.NavMeshAgent.AgentVelocity;
			if (((Vector3)(ref agentVelocity)).sqrMagnitude > 0.04f)
			{
				Face(agentVelocity, dt, 5f);
			}
		}

		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));
			}
		}

		private void GrabTick(float dt)
		{
			if (erb.physGrabObject.playerGrabbing.Count == 0 || enemy.IsStunned())
			{
				grabTime = 0f;
			}
			else
			{
				if ((grabTime += dt) < 0.5f)
				{
					return;
				}
				grabTime = 0f;
				PlayerAvatar val = U.BreakGrabs(erb.physGrabObject);
				Event(1, -1);
				if (Object.op_Implicit((Object)(object)val) && state != State.Bite)
				{
					target = val;
					SyncState();
					if (state != State.Stalk)
					{
						SetState(State.Stalk);
					}
				}
			}
		}

		public void HeavyHit(PhysGrabObject by, float speed, Vector3 point)
		{
			if (enemy.HasStateStunned && !enemy.IsStunned() && state != State.Spawn && !(Plugin.CfgStunTime.Value <= 0f))
			{
				enemy.StateStunned.Set(Plugin.CfgStunTime.Value);
				Plugin.Log.LogInfo((object)$"[Wendigo] Stunned by {((Object)by).name} ({by.rb.mass:0.0} kg at {speed:0.0} m/s).");
			}
		}

		private void FrozenTick()
		{
			if (frozenUntil.Count == 0)
			{
				return;
			}
			List<int> list = null;
			foreach (KeyValuePair<int, float> item in frozenUntil)
			{
				if (Time.time > item.Value || !U.Valid(U.Find(item.Key)))
				{
					(list ?? (list = new List<int>())).Add(item.Key);
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (int item2 in list)
			{
				Unfreeze(item2);
			}
		}

		internal void ReportFrozen(PlayerAvatar me)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (U.MP)
			{
				photonView.RPC("WendigoFrozenRPC", (RpcTarget)2, new object[1] { U.Id(me) });
			}
			else
			{
				WendigoFrozenRPC(U.Id(me));
			}
		}

		[PunRPC]
		private void WendigoFrozenRPC(int viewId, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!U.Master)
			{
				return;
			}
			PlayerAvatar val = U.Find(viewId);
			if (U.Valid(val) && (!U.MP || (val.photonView.Owner != null && info.Sender != null && val.photonView.Owner.ActorNumber == info.Sender.ActorNumber)) && !frozenUntil.ContainsKey(viewId))
			{
				frozenUntil[viewId] = Time.time + Plugin.CfgFreezeTime.Value;
				iceHits[viewId] = 0;
				Plugin.Log.LogInfo((object)("[Wendigo] " + val.playerName + " is frozen."));
				if (U.MP)
				{
					photonView.RPC("WendigoIceRPC", (RpcTarget)0, new object[2] { viewId, true });
				}
				else
				{
					WendigoIceRPC(viewId, on: true);
				}
			}
		}

		internal void IceHit(int viewId)
		{
			if (frozenUntil.ContainsKey(viewId))
			{
				int value;
				int num = (iceHits.TryGetValue(viewId, out value) ? value : 0) + 1;
				iceHits[viewId] = num;
				Plugin.Log.LogInfo((object)$"[Wendigo] Ice hit {num}/{Plugin.CfgIceHits.Value}.");
				if (num >= Plugin.CfgIceHits.Value)
				{
					Unfreeze(viewId);
				}
				else
				{
					Event(3, viewId);
				}
			}
		}

		private void Unfreeze(int viewId)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			frozenUntil.Remove(viewId);
			iceHits.Remove(viewId);
			if (U.MP)
			{
				photonView.RPC("WendigoIceRPC", (RpcTarget)0, new object[2] { viewId, false });
			}
			else
			{
				WendigoIceRPC(viewId, on: false);
			}
		}

		[PunRPC]
		private void WendigoIceRPC(int viewId, bool on, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: 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_004e: 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_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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterOnlyRPC(info))
			{
				return;
			}
			PlayerAvatar val = U.Find(viewId);
			if (ice.TryGetValue(viewId, out var value) && Object.op_Implicit((Object)(object)value))
			{
				Object.Destroy((Object)(object)value);
			}
			ice.Remove(viewId);
			Vector3 val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).transform.position : ((Component)erb).transform.position);
			if (on)
			{
				Snd.Play(Sounds.Freeze, val2 + Vector3.up);
				if ((Object)(object)PrefabBuilder.IcePart.Mesh != (Object)null)
				{
					GameObject val3 = Kit.Prop("Wendigo Ice", PrefabBuilder.IcePart, val2, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), 1.15f);
					BoxCollider obj = val3.AddComponent<BoxCollider>();
					((Collider)obj).isTrigger = true;
					obj.size = new Vector3(0.95f, 1.9f, 0.95f);
					obj.center = new Vector3(0f, 0.95f, 0f);
					IceBlock iceBlock = val3.AddComponent<IceBlock>();
					iceBlock.ai = this;
					iceBlock.victimId = viewId;
					ice[viewId] = val3;
				}
				if (Object.op_Implicit((Object)(object)val) && val.isLocal)
				{
					Frost.FreezeLocal(Plugin.CfgFreezeTime.Value);
				}
			}
			else
			{
				Snd.Play(Sounds.Shatter, val2 + Vector3.up);
				if (Object.op_Implicit((Object)(object)val) && val.isLocal)
				{
					Frost.UnfreezeLocal();
				}
			}
		}

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

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

		[PunRPC]
		private void WendigoStateRPC(int s, int targetId, 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);
				if (s != (int)state)
				{
					ApplyState((State)s);
				}
			}
		}

		private void ApplyState(State s)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00c1: 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)$"[Wendigo] {state} -> {s}");
			}
			Vector3 pos = ((Component)erb).transform.position + Vector3.up * 1.2f;
			switch (s)
			{
			case State.Stunned:
				Snd.Play(Sounds.Stun, pos);
				break;
			case State.Bite:
				Snd.Play(Sounds.Growl, pos, 0.7f, 1.2f);
				break;
			case State.Stalk:
				if (state == State.Roam)
				{
					Snd.Play(Sounds.Growl, pos, 0.8f);
				}
				break;
			}
		}

		private void Event(int ev, int viewId)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (U.MP)
			{
				photonView.RPC("WendigoEventRPC", (RpcTarget)0, new object[2] { ev, viewId });
			}
			else
			{
				WendigoEventRPC(ev, viewId);
			}
		}

		[PunRPC]
		private void WendigoEventRPC(int ev, int viewId, 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0048: 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_00e3: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.MasterOnlyRPC(info))
			{
				return;
			}
			Vector3 val = ((Component)erb).transform.position + Vector3.up * 1.6f;
			switch (ev)
			{
			case 1:
				Snd.Play(Sounds.Growl, val, 0.9f);
				jaw = 1f;
				break;
			case 2:
			{
				Snd.Play(Sounds.Bite, val);
				jaw = 1f;
				PlayerAvatar val3 = U.Find(viewId);
				if (Object.op_Implicit((Object)(object)val3) && val3.isLocal)
				{
					U.Shake(((Component)val3).transform.position, 6f, 0.4f, 0f, 5f);
				}
				break;
			}
			case 3:
			{
				PlayerAvatar val2 = U.Find(viewId);
				Snd.Play(Sounds.Crack, (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).transform.position : val) + Vector3.up);
				if (ice.TryGetValue(viewId, out var value) && Object.op_Implicit((Object)(object)value))
				{
					Transform transform = value.transform;
					transform.localScale *= 0.94f;
				}
				break;
			}
			}
		}

		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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)erb))
			{
				lastVisPos = ((Component)erb).transform.position;
			}
			Frost.RefreshLights();
			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;
				Plugin.Log.LogInfo((object)("[Wendigo] 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)
			//IL_0015: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			Snd.Play(Sounds.Hurt, ((Component)erb).transform.position + Vector3.up * 1.4f, 0.9f);
		}

		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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_004e: 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)
			Vector3 position = ((Component)erb).transform.position;
			Snd.Play(Sounds.Death, position + Vector3.up);
			if (Object.op_Implicit((Object)(object)particles))
			{
				particles.position = position + Vector3.up * 0.8f;
				ParticleSystem[] componentsInChildren = ((Component)particles).GetComponentsInChildren<ParticleSystem>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].Play(true);
				}
			}
			if (!U.Master)
			{
				return;
			}
			foreach (int item in new List<int>(frozenUntil.Keys))
			{
				Unfreeze(item);
			}
			enemy.EnemyParent.Despawn();
		}

		internal bool SeesLocal(Vector3 cam, float range, out float dist)
		{
			//IL_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid