Decompiled source of Bride v1.0.0

Mariee.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Mariee
{
	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("Mariee." + 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("Mariee.atlas.png"), false);
			((Object)Atlas).name = "Mariee 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 = "Mariee " + 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 = "Mariee " + 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)"[Mariee] 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.mariee", "Mariee", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "maxime.repo.mariee";

		public const string NAME = "Mariee";

		public const string VERSION = "1.0.0";

		internal const int DefaultTier = 2;

		internal const KeyCode DefaultKey = (KeyCode)284;

		internal static ConfigEntry<int> CfgHealth;

		internal static ConfigEntry<int> CfgTouch;

		internal static ConfigEntry<float> CfgSpeed;

		internal static ConfigEntry<float> CfgRushSpeed;

		internal static ConfigEntry<float> CfgWailRange;

		internal static ConfigEntry<float> CfgWailTime;

		internal static ConfigEntry<float> CfgRushTime;

		internal static ConfigEntry<float> CfgWailCooldown;

		internal static ConfigEntry<float> CfgCeremony;

		internal static ConfigEntry<float> CfgRescue;

		internal static ConfigEntry<float> CfgPursuit;

		internal static ConfigEntry<float> CfgGiveUp;

		internal static ConfigEntry<float> CfgPurify;

		internal static ConfigEntry<float> CfgMarry;

		internal static ConfigEntry<float> CfgReturn;

		internal static ConfigEntry<float> CfgIdle;

		internal static ConfigEntry<float> CfgThrowSpeed;

		internal static ConfigEntry<float> CfgImmune;

		internal static ConfigEntry<float> CfgCatchDelay;

		internal static ConfigEntry<float> CfgPickup;

		internal static ConfigEntry<float> CfgThrowRange;

		internal static ConfigEntry<float> CfgStunTime;

		internal static ConfigEntry<float> CfgHeavyMass;

		internal static ConfigEntry<float> CfgHeavySpeed;

		internal static ConfigEntry<KeyCode> CfgThrowKey;

		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("MarieePrefabHolder");
					holder.SetActive(false);
					((Object)holder).hideFlags = (HideFlags)61;
					Object.DontDestroyOnLoad((Object)(object)holder);
				}
				return holder;
			}
		}

		private static void BindModConfig(ConfigFile c)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_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_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Expected O, but got Unknown
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Expected O, but got Unknown
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Expected O, but got Unknown
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Expected O, but got Unknown
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Expected O, but got Unknown
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Expected O, but got Unknown
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Expected O, but got Unknown
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Expected O, but got Unknown
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Expected O, but got Unknown
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Expected O, but got Unknown
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Expected O, but got Unknown
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Expected O, but got Unknown
			CfgHealth = c.Bind<int>("Bride", "Health", 200, new ConfigDescription("Hit points.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 3000), Array.Empty<object>()));
			CfgSpeed = c.Bind<float>("Bride", "Speed", 1.6f, new ConfigDescription("Speed of her pursuit (m/s). She always knows where the chosen one is.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 8f), Array.Empty<object>()));
			CfgWailRange = c.Bind<float>("Wail", "Range", 12f, new ConfigDescription("Within this range of the chosen one (in sight) she wails...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), Array.Empty<object>()));
			CfgWailTime = c.Bind<float>("Wail", "Duration", 2f, new ConfigDescription("...this long (s)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 10f), Array.Empty<object>()));
			CfgRushSpeed = c.Bind<float>("Wail", "RushSpeed", 3.5f, new ConfigDescription("...then rushes at this speed (m/s)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 12f), Array.Empty<object>()));
			CfgRushTime = c.Bind<float>("Wail", "RushTime", 4f, new ConfigDescription("...for this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), Array.Empty<object>()));
			CfgWailCooldown = c.Bind<float>("Wail", "Cooldown", 15f, new ConfigDescription("Seconds between two wails.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>()));
			CfgTouch = c.Bind<int>("Ceremony", "TouchDamage", 50, new ConfigDescription("Damage when she touches the chosen one...", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			CfgCeremony = c.Bind<float>("Ceremony", "HoldTime", 20f, new ConfigDescription("...who is then taken to her chapel and held at the altar this long (s)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>()));
			CfgRescue = c.Bind<float>("Ceremony", "RescueRange", 2f, new ConfigDescription("...unless a teammate comes within this range of them (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
			CfgReturn = c.Bind<float>("Ceremony", "VanishAfter", 90f, new ConfigDescription("After a ceremony she vanishes this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 600f), Array.Empty<object>()));
			CfgPursuit = c.Bind<float>("Pursuit", "GiveUpAfter", 120f, new ConfigDescription("After this long chasing (s)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 900f), Array.Empty<object>()));
			CfgGiveUp = c.Bind<float>("Pursuit", "GiveUpTime", 60f, new ConfigDescription("...she gives up and vanishes this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 600f), Array.Empty<object>()));
			CfgPurify = c.Bind<float>("Bouquet", "PurifyTime", 120f, new ConfigDescription("Bouquet brought into the truck or an extraction point: she vanishes this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 900f), Array.Empty<object>()));
			CfgMarry = c.Bind<float>("Bouquet", "MarryTime", 120f, new ConfigDescription("Bouquet thrown on another monster: she marries it, both vanish this long (s), once per level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 900f), Array.Empty<object>()));
			CfgIdle = c.Bind<float>("Bouquet", "IdleTime", 10f, new ConfigDescription("Nobody touches the bouquet this long: she takes it back and throws it again (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 120f), Array.Empty<object>()));
			CfgThrowKey = c.Bind<KeyCode>("Bouquet", "ThrowKey", (KeyCode)103, "Key to throw the bouquet (the chosen one).");
			CfgThrowSpeed = c.Bind<float>("Bouquet", "ThrowSpeed", 11f, new ConfigDescription("Speed of a player's throw (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 30f), Array.Empty<object>()));
			CfgImmune = c.Bind<float>("Bouquet", "ThrowerImmunity", 10f, new ConfigDescription("The thrower cannot be chosen again for this long (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>()));
			CfgCatchDelay = c.Bind<float>("Bouquet", "CatchDelay", 1f, new ConfigDescription("A new chosen one cannot throw it during this time, and she switches to them only after it (s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			CfgPickup = c.Bind<float>("Bouquet", "PickupRadius", 1f, new ConfigDescription("Walking this close to a bouquet on the floor touches it (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 3f), Array.Empty<object>()));
			CfgThrowRange = c.Bind<float>("Bouquet", "BrideThrowRange", 12f, new ConfigDescription("She throws the bouquet at a player in sight within this range (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 30f), Array.Empty<object>()));
			CfgStunTime = c.Bind<float>("Counterplay", "StunTime", 5f, new ConfigDescription("A heavy hit stuns her 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 her 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", 2, 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 Mariee 4 m in front of you (or spawns it).");
			CfgDebugSpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "SpawnKey", (KeyCode)284, "Debug spawn key.");
			BindModConfig(((BaseUnityPlugin)this).Config);
			Lang.Bind(((BaseUnityPlugin)this).Config);
			harmony = new Harmony("maxime.repo.mariee");
			harmony.PatchAll(typeof(Plugin).Assembly);
			try
			{
				Kit.Init();
				Prefab = PrefabBuilder.Build();
				Register();
				Log.LogInfo((object)"Mariee v1.0.0 loaded: enemy prefab built and registered with REPOLib.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to build/register the Mariee: " + 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 - Mariee";
			((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 = "Mariee 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 = "Mariee";
			((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)MarieeAI.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;
						MarieeAI.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}.", "Mariee", pos));
					}
				}
				catch (Exception ex)
				{
					handledLevel = instance;
					Log.LogError((object)("[Mariee] 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 Mariee.");
					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;
				}
				MarieeAI marieeAI = MarieeAI.Existing();
				if ((Object)(object)marieeAI != (Object)null)
				{
					marieeAI.DebugBring(val2);
					Log.LogInfo((object)string.Format("[Debug] {0} brought to {1}.", "Mariee", val2));
					return;
				}
				MarieeAI.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}.", "Mariee", 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", "Bride" },
			{ "fr", "Mariée" },
			{ "de", "Braut" },
			{ "es", "Novia" },
			{ "es-419", "Novia" },
			{ "it", "Sposa" },
			{ "pt", "Noiva" },
			{ "pt-BR", "Noiva" },
			{ "ru", "Невеста" },
			{ "uk", "Наречена" },
			{ "pl", "Panna Młoda" },
			{ "tr", "Gelin" },
			{ "ja", "花嫁" },
			{ "ko", "신부" },
			{ "zh-Hans", "新娘" },
			{ "zh-Hant", "新娘" },
			{ "ar", "العروس" },
			{ "da", "Brud" },
			{ "fi", "Morsian" },
			{ "sv", "Brud" },
			{ "th", "เจ\u0e49าสาว" }
		};

		internal const bool HasMessages = true;

		internal static readonly Dictionary<string, Dictionary<string, string>> Messages = new Dictionary<string, Dictionary<string, string>>
		{
			{
				"victim",
				new Dictionary<string, string>
				{
					{ "en", "The Bride took you to the altar... wait for your teammates!" },
					{ "fr", "La Mariée t'a emmené à l'autel... attends tes coéquipiers !" },
					{ "de", "Die Braut hat dich zum Altar gebracht... warte auf dein Team!" },
					{ "es", "La Novia te ha llevado al altar... ¡espera a tu equipo!" },
					{ "es-419", "La Novia te llevó al altar... ¡espera a tu equipo!" },
					{ "it", "La Sposa ti ha portato all'altare... aspetta i tuoi compagni!" },
					{ "pt", "A Noiva levou-te ao altar... espera pelos teus colegas!" },
					{ "pt-BR", "A Noiva te levou ao altar... espere seus companheiros!" },
					{ "ru", "Невеста унесла тебя к алтарю... жди товарищей!" },
					{ "uk", "Наречена забрала тебе до вівтаря... чекай на товаришів!" },
					{ "pl", "Panna Młoda zabrała cię do ołtarza... czekaj na drużynę!" },
					{ "tr", "Gelin seni sunağa götürdü... takım arkadaşlarını bekle!" },
					{ "ja", "花嫁に祭壇へ連れ去られた…仲間を待て!" },
					{ "ko", "신부가 너를 제단으로 데려갔다... 동료를 기다려!" },
					{ "zh-Hans", "新娘把你带到了祭坛……等待队友来救你!" },
					{ "zh-Hant", "新娘把你帶到了祭壇……等待隊友來救你!" },
					{ "ar", "أخذتك العروس إلى المذبح... انتظر رفاقك!" },
					{ "da", "Bruden har taget dig til alteret... vent på dine holdkammerater!" },
					{ "fi", "Morsian vei sinut alttarille... odota tiimitovereitasi!" },
					{ "sv", "Bruden har tagit dig till altaret... vänta på dina lagkamrater!" },
					{ "th", "เจ\u0e49าสาวพาค\u0e38ณไปท\u0e35\u0e48แท\u0e48นพ\u0e34ธ\u0e35... รอเพ\u0e37\u0e48อนร\u0e48วมท\u0e35ม!" }
				}
			},
			{
				"others",
				new Dictionary<string, string>
				{
					{ "en", "The Bride took {0} to the altar! Follow the organ." },
					{ "fr", "La Mariée a emmené {0} à l'autel ! Suivez l'orgue." },
					{ "de", "Die Braut hat {0} zum Altar gebracht! Folgt der Orgel." },
					{ "es", "¡La Novia ha llevado a {0} al altar! Seguid el órgano." },
					{ "es-419", "¡La Novia llevó a {0} al altar! Sigan el órgano." },
					{ "it", "La Sposa ha portato {0} all'altare! Seguite l'organo." },
					{ "pt", "A Noiva levou {0} ao altar! Sigam o órgão." },
					{ "pt-BR", "A Noiva levou {0} ao altar! Sigam o órgão." },
					{ "ru", "Невеста унесла {0} к алтарю! Идите на звук органа." },
					{ "uk", "Наречена забрала {0} до вівтаря! Йдіть на звук органа." },
					{ "pl", "Panna Młoda zabrała {0} do ołtarza! Idźcie za dźwiękiem organów." },
					{ "tr", "Gelin {0} adlı oyuncuyu sunağa götürdü! Orgun sesini takip edin." },
					{ "ja", "花嫁が{0}を祭壇へ連れ去った!オルガンの音をたどれ。" },
					{ "ko", "신부가 {0}을(를) 제단으로 데려갔다! 오르간 소리를 따라가." },
					{ "zh-Hans", "新娘把{0}带到了祭坛!循着管风琴声去找。" },
					{ "zh-Hant", "新娘把{0}帶到了祭壇!循著管風琴聲去找。" },
					{ "ar", "أخذت العروس {0} إلى المذبح! اتبعوا صوت الأرغن." },
					{ "da", "Bruden har taget {0} til alteret! Følg orglet." },
					{ "fi", "Morsian vei pelaajan {0} alttarille! Seuratkaa urkujen ääntä." },
					{ "sv", "Bruden har tagit {0} till altaret! Följ orgeln." },
					{ "th", "เจ\u0e49าสาวพา {0} ไปท\u0e35\u0e48แท\u0e48นพ\u0e34ธ\u0e35! ตามเส\u0e35ยงออร\u0e4cแกนไป" }
				}
			},
			{
				"chosen",
				new Dictionary<string, string>
				{
					{ "en", "You touched the bouquet... the Bride is coming for you. [{0}] to throw it" },
					{ "fr", "Tu as touché le bouquet... la Mariée vient pour toi. [{0}] pour le lancer" },
					{ "de", "Du hast den Brautstrauß berührt... die Braut kommt dich holen. [{0}] zum Werfen" },
					{ "es", "Has tocado el ramo... la Novia viene a por ti. [{0}] para lanzarlo" },
					{ "es-419", "Tocaste el ramo... la Novia viene por ti. [{0}] para lanzarlo" },
					{ "it", "Hai toccato il bouquet... la Sposa viene a prenderti. [{0}] per lanciarlo" },
					{ "pt", "Tocaste no ramo... a Noiva vem buscar-te. [{0}] para o atirar" },
					{ "pt-BR", "Você tocou no buquê... a Noiva está vindo atrás de você. [{0}] para jogá-lo" },
					{ "ru", "Ты коснулся букета... Невеста идёт за тобой. [{0}] — бросить" },
					{ "uk", "Ти торкнувся букета... Наречена йде по тебе. [{0}] — кинути" },
					{ "pl", "Dotknąłeś bukietu... Panna Młoda idzie po ciebie. [{0}] aby rzucić" },
					{ "tr", "Bukete dokundun... Gelin senin için geliyor. Atmak için [{0}]" },
					{ "ja", "ブーケに触れてしまった…花嫁が来る。[{0}]で投げる" },
					{ "ko", "부케를 만졌다... 신부가 너를 노린다. [{0}] 키로 던지기" },
					{ "zh-Hans", "你碰了捧花……新娘要来找你了。按 [{0}] 扔出去" },
					{ "zh-Hant", "你碰了捧花……新娘要來找你了。按 [{0}] 丟出去" },
					{ "ar", "لمست الباقة... العروس قادمة إليك. [{0}] لرميها" },
					{ "da", "Du rørte buketten... Bruden kommer efter dig. [{0}] for at kaste den" },
					{ "fi", "Kosketit kimppua... Morsian tulee hakemaan sinua. [{0}] heittää sen" },
					{ "sv", "Du rörde buketten... Bruden kommer efter dig. [{0}] för att kasta den" },
					{ "th", "ค\u0e38ณแตะช\u0e48อดอกไม\u0e49แล\u0e49ว... เจ\u0e49าสาวกำล\u0e31งมาหาค\u0e38ณ กด [{0}] เพ\u0e37\u0e48อโยน" }
				}
			},
			{
				"remind",
				new Dictionary<string, string>
				{
					{ "en", "The Bride is after you... [{0}] throw the bouquet, or bring it to the truck" },
					{ "fr", "La Mariée te poursuit... [{0}] lancer le bouquet, ou ramène-le au camion" },
					{ "de", "Die Braut ist hinter dir her... [{0}] Strauß werfen oder zum Truck bringen" },
					{ "es", "La Novia te persigue... [{0}] lanza el ramo o llévalo al camión" },
					{ "es-419", "La Novia te persigue... [{0}] lanza el ramo o llévalo al camión" },
					{ "it", "La Sposa ti insegue... [{0}] lancia il bouquet o portalo al camion" },
					{ "pt", "A Noiva persegue-te... [{0}] atira o ramo ou leva-o para o camião" },
					{ "pt-BR", "A Noiva está atrás de você... [{0}] jogue o buquê ou leve-o ao caminhão" },
					{ "ru", "Невеста преследует тебя... [{0}] — бросить букет, или отнеси его в грузовик" },
					{ "uk", "Наречена переслідує тебе... [{0}] — кинути букет, або віднеси його у вантажівку" },
					{ "pl", "Panna Młoda cię ściga... [{0}] rzuć bukiet albo zanieś go do ciężarówki" },
					{ "tr", "Gelin peşinde... buketi atmak için [{0}], ya da kamyona götür" },
					{ "ja", "花嫁に追われている…[{0}]でブーケを投げるか、トラックへ運べ" },
					{ "ko", "신부가 쫓아온다... [{0}] 키로 부케를 던지거나 트럭으로 가져가" },
					{ "zh-Hans", "新娘在追你……按 [{0}] 扔出捧花,或把它带回卡车" },
					{ "zh-Hant", "新娘在追你……按 [{0}] 丟出捧花,或把它帶回卡車" },
					{ "ar", "العروس تطاردك... [{0}] لرمي الباقة، أو خذها إلى الشاحنة" },
					{ "da", "Bruden jager dig... [{0}] kast buketten, eller bring den til lastbilen" },
					{ "fi", "Morsian jahtaa sinua... [{0}] heitä kimppu tai vie se kuorma-autoon" },
					{ "sv", "Bruden jagar dig... [{0}] kasta buketten, eller ta den till lastbilen" },
					{ "th", "เจ\u0e49าสาวไล\u0e48ตามค\u0e38ณ... กด [{0}] เพ\u0e37\u0e48อโยนช\u0e48อดอกไม\u0e49 หร\u0e37อนำไปท\u0e35\u0e48รถบรรท\u0e38ก" }
				}
			},
			{
				"purify",
				new Dictionary<string, string>
				{
					{ "en", "The bouquet is safe: the Bride fades away..." },
					{ "fr", "Le bouquet est à l'abri : la Mariée s'évanouit..." },
					{ "de", "Der Strauß ist in Sicherheit: die Braut verblasst..." },
					{ "es", "El ramo está a salvo: la Novia se desvanece..." },
					{ "es-419", "El ramo está a salvo: la Novia se desvanece..." },
					{ "it", "Il bouquet è al sicuro: la Sposa svanisce..." },
					{ "pt", "O ramo está a salvo: a Noiva desvanece-se..." },
					{ "pt-BR", "O buquê está seguro: a Noiva desaparece..." },
					{ "ru", "Букет в безопасности: Невеста исчезает..." },
					{ "uk", "Букет у безпеці: Наречена зникає..." },
					{ "pl", "Bukiet jest bezpieczny: Panna Młoda znika..." },
					{ "tr", "Buket güvende: Gelin kayboluyor..." },
					{ "ja", "ブーケは安全だ:花嫁は消えていく…" },
					{ "ko", "부케가 안전하다: 신부가 사라진다..." },
					{ "zh-Hans", "捧花安全了:新娘渐渐消失……" },
					{ "zh-Hant", "捧花安全了:新娘漸漸消失……" },
					{ "ar", "الباقة في أمان: العروس تتلاشى..." },
					{ "da", "Buketten er i sikkerhed: Bruden forsvinder..." },
					{ "fi", "Kimppu on turvassa: Morsian haihtuu..." },
					{ "sv", "Buketten är i säkerhet: Bruden bleknar bort..." },
					{ "th", "ช\u0e48อดอกไม\u0e49ปลอดภ\u0e31ยแล\u0e49ว: เจ\u0e49าสาวกำล\u0e31งจางหายไป..." }
				}
			},
			{
				"freed",
				new Dictionary<string, string>
				{
					{ "en", "{0} is free!" },
					{ "fr", "{0} est libéré !" },
					{ "de", "{0} ist frei!" },
					{ "es", "¡{0} está libre!" },
					{ "es-419", "¡{0} está libre!" },
					{ "it", "{0} è libero!" },
					{ "pt", "{0} está livre!" },
					{ "pt-BR", "{0} está livre!" },
					{ "ru", "{0} свободен!" },
					{ "uk", "{0} вільний!" },
					{ "pl", "{0} jest wolny!" },
					{ "tr", "{0} serbest!" },
					{ "ja", "{0}は解放された!" },
					{ "ko", "{0} 풀려났다!" },
					{ "zh-Hans", "{0} 获救了!" },
					{ "zh-Hant", "{0} 獲救了!" },
					{ "ar", "{0} حر!" },
					{ "da", "{0} er fri!" },
					{ "fi", "{0} on vapaa!" },
					{ "sv", "{0} är fri!" },
					{ "th", "{0} เป\u0e47นอ\u0e34สระแล\u0e49ว!" }
				}
			},
			{
				"marry",
				new Dictionary<string, string>
				{
					{ "en", "The Bride married {0}! They vanish for a while." },
					{ "fr", "La Mariée a épousé {0} ! Ils disparaissent pour un moment." },
					{ "de", "Die Braut hat {0} geheiratet! Beide verschwinden für eine Weile." },
					{ "es", "¡La Novia se ha casado con {0}! Desaparecen durante un rato." },
					{ "es-419", "¡La Novia se casó con {0}! Desaparecen por un rato." },
					{ "it", "La Sposa ha sposato {0}! Spariscono per un po'." },
					{ "pt", "A Noiva casou com {0}! Desaparecem durante algum tempo." },
					{ "pt-BR", "A Noiva se casou com {0}! Eles somem por um tempo." },
					{ "ru", "Невеста вышла замуж за {0}! Они ненадолго исчезают." },
					{ "uk", "Наречена вийшла заміж за {0}! Вони ненадовго зникають." },
					{ "pl", "Panna Młoda poślubiła {0}! Znikają na jakiś czas." },
					{ "tr", "Gelin {0} ile evlendi! Bir süreliğine ortadan kayboluyorlar." },
					{ "ja", "花嫁が{0}と結婚した!しばらく姿を消す。" },
					{ "ko", "신부가 {0}와(과) 결혼했다! 잠시 동안 사라진다." },
					{ "zh-Hans", "新娘和{0}结婚了!它们暂时消失了。" },
					{ "zh-Hant", "新娘和{0}結婚了!它們暫時消失了。" },
					{ "ar", "تزوجت العروس {0}! سيختفيان لبعض الوقت." },
					{ "da", "Bruden har giftet sig med {0}! De forsvinder et stykke tid." },
					{ "fi", "Morsian meni naimisiin: {0}! He katoavat hetkeksi." },
					{ "sv", "Bruden gifte sig med {0}! De försvinner en stund." },
					{ "th", "เจ\u0e49าสาวแต\u0e48งงานก\u0e31บ {0}! พวกเขาหายไปช\u0e31\u0e48วขณะ" }
				}
			}
		};

		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, its messages). 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 (MarieeAI item in MarieeAI.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 string M(string key, params object[] args)
		{
			try
			{
				return string.Format(Pick(Messages[key]), args);
			}
			catch (Exception)
			{
				return string.Format(Messages[key]["en"], args);
			}
		}
	}
	public class MarieeAI : MonoBehaviour, IHeavyHit
	{
		public enum State
		{
			Spawn,
			Seek,
			Throw,
			Pursue,
			Wail,
			Rush,
			Ceremony,
			Stunned,
			Leave
		}

		public enum Bq
		{
			Bride,
			Held,
			Flying,
			Lying,
			Gone
		}

		private const int EV_CHIME = 1;

		private const int EV_THROW = 2;

		private const int EV_PURIFY = 3;

		private const int EV_TOUCH = 5;

		private const int EV_MARRY = 6;

		private const int EV_RETRIEVE = 7;

		private const int EV_WAIL = 8;

		private const int EV_FREED = 9;

		private const int EV_GIVEUP = 10;

		private static readonly Vector3 G = new Vector3(0f, -9.81f, 0f);

		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 ghostLight;

		private Sound whisper;

		private AudioSource whisperSrc;

		private int losMask;

		private int worldMask;

		private bool ready;

		public State state;

		private bool stateImpulse = true;

		private float stateTimer;

		private float stateTime;

		private PlayerAvatar chosen;

		private PlayerAvatar victim;

		private Bq bq;

		private Vector3 bqPos;

		private Vector3 bqVel;

		private float bqLaunch;

		private float throwReadyAt;

		internal static bool CeremonyActive;

		private PlayerAvatar prevChosen;

		private PlayerAvatar throwTarget;

		private float catchTime = -99f;

		private float pursuitTime;

		private float wailReady;

		private float bqIdleSince;

		private float purifyTimer;

		private float pathTimer;

		private float grabTimer;

		private float pauseTimer;

		private float touchReady;

		private float teleportTry;

		private float leaveTime;

		private bool thrown;

		private bool victimPlaced;

		private Vector3 lastChosenPos;

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

		private static LevelGenerator marriedLevel;

		private static LevelGenerator chapelLevel;

		private static Vector3 chPos;

		private static Vector3 chFwd;

		private static float chLen;

		private static float chHalf;

		private static float chCeil;

		private GameObject bouquetGo;

		private GameObject bindGo;

		private Light bouquetLight;

		private float t;

		private float bodySpeed;

		private float sobTimer;

		private float reminderTimer;

		private Vector3 lastVisPos;

		private float headYaw;

		private float headPitch;

		private float sink;

		internal static float SkipTeleportUntil;

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

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

		internal static MarieeAI Existing()
		{
			All.RemoveAll((MarieeAI 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_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: 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("BrideModel") : 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;
					}
				}
				ghostLight = ((Component)model).GetComponentInChildren<Light>(true);
				Transform val2 = model.Find("Bride Whisper");
				whisperSrc = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).GetComponent<AudioSource>() : null);
				whisper = Snd.Loop(Sounds.Whisper, whisperSrc, 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;
			}
			int mask = LayerMask.GetMask(new string[7] { "Player", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "Enemy", "Ragdoll", "Triggers" });
			losMask = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) & ~num & ~LayerMask.GetMask(new string[3] { "Player", "PhysGrabObject", "Enemy" });
			worldMask = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) & ~num & ~mask;
			ready = Object.op_Implicit((Object)(object)model) && Object.op_Implicit((Object)(object)erb) && J.Count >= 10;
			if (!ready)
			{
				Plugin.Log.LogError((object)"MarieeAI: hierarchy incomplete, behaviour disabled.");
			}
			All.Add(this);
		}

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

		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;
			}
			sink = 0f;
		}

		private void OnDisable()
		{
			if (U.Master && Object.op_Implicit((Object)(object)victim))
			{
				ReleaseVictim();
			}
			CeremonyActive = false;
			victim = null;
			chosen = null;
			prevChosen = null;
			bq = Bq.Bride;
			if (Object.op_Implicit((Object)(object)bouquetGo))
			{
				bouquetGo.transform.SetParent((Transform)null, true);
				bouquetGo.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)bindGo))
			{
				bindGo.SetActive(false);
			}
		}

		private void OnDestroy()
		{
			All.Remove(this);
			if (Object.op_Implicit((Object)(object)bouquetGo))
			{
				Object.Destroy((Object)(object)bouquetGo);
			}
			if (Object.op_Implicit((Object)(object)bindGo))
			{
				Object.Destroy((Object)(object)bindGo);
			}
		}

		private void Update()
		{
			//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_00e0: 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)
			if (ready)
			{
				float deltaTime = Time.deltaTime;
				t += deltaTime;
				if (U.Master)
				{
					MasterLogic(deltaTime);
				}
				else
				{
					stateTime += deltaTime;
				}
				LocalChosen(deltaTime);
				Snd.PlayLoop(whisper, state != State.Leave && !health.dead, 2f, 1f, (state == State.Rush) ? 1.15f : 1f);
				if (state == State.Seek && (sobTimer -= deltaTime) <= 0f)
				{
					sobTimer = Random.Range(8f, 15f);
					Snd.Play(Sounds.Sob, ((Component)erb).transform.position + Vector3.up * 1.5f, 0.7f);
				}
			}
		}

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

		private void FixedUpdate()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006d: 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_007d: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			if (!ready || !U.Master)
			{
				return;
			}
			Rigidbody rb = erb.rb;
			if (Object.op_Implicit((Object)(object)rb) && !rb.isKinematic && !enemy.IsStunned())
			{
				Vector3 val = Vector3.Cross(((Component)rb).transform.up, Vector3.up);
				Vector3 angularVelocity = rb.angularVelocity;
				rb.AddTorque(val * 60f - new Vector3(angularVelocity.x, 0f, angularVelocity.z) * 10f, (ForceMode)5);
			}
			if (state == State.Ceremony && U.Valid(victim) && Object.op_Implicit((Object)(object)victim.tumble) && Object.op_Implicit((Object)(object)Chapel.Hold))
			{
				PlayerTumble tumble = victim.tumble;
				if (!tumble.isTumbling)
				{
					tumble.TumbleRequest(true, false);
				}
				tumble.TumbleOverrideTime(1f);
				victim.FallDamageResetSet(0.1f);
				if (victimPlaced && !(Vector3.Distance(((Component)tumble).transform.position, Chapel.Hold.position) > 4f))
				{
					tumble.physGrabObject.OverrideMass(1f, 0.1f);
					tumble.physGrabObject.OverrideAngularDrag(2f, 0.1f);
					tumble.physGrabObject.OverrideDrag(1f, 0.1f);
					tumble.OverrideEnemyHurt(0.1f);
					Vector3 val2 = SemiFunc.PhysFollowPosition(((Component)tumble).transform.position, Chapel.Hold.position, tumble.rb.linearVelocity, 10f);
					tumble.rb.AddForce(val2 * (10f * Time.fixedDeltaTime), (ForceMode)1);
				}
			}
		}

		private void MasterLogic(float dt)
		{
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			stateTime += dt;
			if (enemy.IsStunned() && state != State.Stunned && state != State.Ceremony && state != State.Leave)
			{
				SetState(State.Stunned);
			}
			if ((grabTimer -= dt) <= 0f)
			{
				grabTimer = 0.25f;
				U.BreakGrabs(erb.physGrabObject);
			}
			if ((pauseTimer -= dt) <= 0f)
			{
				pauseTimer = 1f;
				if (Object.op_Implicit((Object)(object)chosen) || bq != Bq.Bride || state == State.Ceremony)
				{
					enemy.EnemyParent.SpawnedTimerPause(3f);
				}
			}
			BouquetTick(dt);
			PlayerAvatar val = PursuitTarget();
			switch (state)
			{
			case State.Spawn:
				if (stateImpulse)
				{
					stateImpulse = false;
					stateTimer = 2f;
				}
				Halt();
				if ((stateTimer -= dt) <= 0f)
				{
					SetState(State.Seek);
				}
				break;
			case State.Seek:
			{
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				if (Object.op_Implicit((Object)(object)chosen))
				{
					SetState(State.Pursue);
					break;
				}
				float dist;
				PlayerAvatar val2 = Nearest(needSight: false, out dist);
				if (Object.op_Implicit((Object)(object)val2))
				{
					GoTo(((Component)val2).transform.position, dt, Plugin.CfgSpeed.Value);
					FaceMove(dt);
				}
				else
				{
					Halt();
				}
				if (bq == Bq.Bride && (Object)(object)(throwTarget = ThrowCandidate(null)) != (Object)null)
				{
					SetState(State.Throw);
				}
				break;
			}
			case State.Throw:
				if (stateImpulse)
				{
					stateImpulse = false;
					thrown = false;
				}
				Halt();
				if (U.Valid(throwTarget))
				{
					Face(((Component)throwTarget).transform.position - ((Component)erb).transform.position, dt, 10f);
				}
				if (!thrown && stateTime >= 0.45f)
				{
					thrown = true;
					if (bq == Bq.Bride && U.Valid(throwTarget))
					{
						BrideThrow(throwTarget);
					}
				}
				if (stateTime >= 0.9f)
				{
					SetState((!Object.op_Implicit((Object)(object)chosen)) ? State.Seek : State.Pursue);
				}
				break;
			case State.Pursue:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				if (!U.Valid(chosen))
				{
					chosen = null;
					SyncBouquet();
					SetState(State.Seek);
					break;
				}
				if ((pursuitTime += dt) > Plugin.CfgPursuit.Value)
				{
					Plugin.Log.LogInfo((object)"[Mariee] Gives up the chase.");
					Event(10, -1);
					Leave(Plugin.CfgGiveUp.Value);
					break;
				}
				GoTo(((Component)val).transform.position, dt, Plugin.CfgSpeed.Value);
				FaceMove(dt);
				if (bq == Bq.Bride && (Object)(object)(throwTarget = ThrowCandidate(chosen)) != (Object)null)
				{
					SetState(State.Throw);
				}
				else if (Time.time >= wailReady && (Object)(object)val == (Object)(object)chosen && Near(val, Plugin.CfgWailRange.Value) && Sees(val))
				{
					SetState(State.Wail);
				}
				else
				{
					TouchCheck(val);
				}
				break;
			case State.Wail:
				if (stateImpulse)
				{
					stateImpulse = false;
					Event(8, -1);
				}
				Halt();
				pursuitTime += dt;
				if (U.Valid(val))
				{
					Face(((Component)val).transform.position - ((Component)erb).transform.position, dt, 8f);
				}
				if (stateTime >= Plugin.CfgWailTime.Value)
				{
					SetState(State.Rush);
				}
				break;
			case State.Rush:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				pursuitTime += dt;
				if (!U.Valid(chosen))
				{
					wailReady = Time.time + Plugin.CfgWailCooldown.Value;
					SetState(State.Seek);
					break;
				}
				GoTo(((Component)val).transform.position, dt, Plugin.CfgRushSpeed.Value);
				Face(((Component)val).transform.position - ((Component)erb).transform.position, dt, 10f);
				TouchCheck(val);
				if (state == State.Rush && stateTime >= Plugin.CfgRushTime.Value)
				{
					wailReady = Time.time + Plugin.CfgWailCooldown.Value;
					SetState(State.Pursue);
				}
				break;
			case State.Ceremony:
				if (stateImpulse)
				{
					stateImpulse = false;
					victimPlaced = false;
					teleportTry = 0f;
				}
				CeremonyTick(dt);
				break;
			case State.Stunned:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				Halt();
				if (!enemy.IsStunned())
				{
					SetState((!Object.op_Implicit((Object)(object)chosen)) ? State.Seek : State.Pursue);
				}
				break;
			case State.Leave:
				if (stateImpulse)
				{
					stateImpulse = false;
				}
				Halt();
				if (stateTime >= 1.4f)
				{
					EnemyParent enemyParent = enemy.EnemyParent;
					enemyParent.Despawn();
					enemyParent.DespawnedTimer = Mathf.Max(1f, leaveTime);
					Plugin.Log.LogInfo((object)$"[Mariee] Vanished for {leaveTime:0} s.");
					stateImpulse = true;
					stateTime = 0f;
				}
				break;
			}
		}

		private PlayerAvatar PursuitTarget()
		{
			if (Time.time - catchTime < Plugin.CfgCatchDelay.Value && U.Valid(prevChosen))
			{
				return prevChosen;
			}
			return chosen;
		}

		private PlayerAvatar Nearest(bool needSight, out float dist)
		{
			//IL_002c: 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)
			PlayerAvatar result = null;
			dist = float.MaxValue;
			foreach (PlayerAvatar item in U.Players())
			{
				if (U.Valid(item))
				{
					float num = Vector3.Distance(((Component)item).transform.position, ((Component)erb).transform.position);
					if (num < dist && (!needSight || Sees(item)))
					{
						dist = num;
						result = item;
					}
				}
			}
			return result;
		}

		private PlayerAvatar ThrowCandidate(PlayerAvatar exclude)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar result = null;
			float num = Plugin.CfgThrowRange.Value;
			foreach (PlayerAvatar item in U.Players())
			{
				if (U.Valid(item) && !((Object)(object)item == (Object)(object)exclude) && !Immune(item))
				{
					float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)erb).transform.position);
					if (num2 < num && Sees(item))
					{
						num = num2;
						result = item;
					}
				}
			}
			return result;
		}

		private bool Immune(PlayerAvatar p)
		{
			if (immuneUntil.TryGetValue(U.Id(p), out var value))
			{
				return Time.time < value;
			}
			return false;
		}

		private bool Near(PlayerAvatar p, float r)
		{
			//IL_000e: 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 (U.Valid(p))
			{
				return Vector3.Distance(((Component)p).transform.position, ((Component)erb).transform.position) <= r;
			}
			return false;
		}

		private bool Sees(PlayerAvatar p)
		{
			//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_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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			return !U.Blocked(((Component)erb).transform.position + Vector3.up * 1.2f, U.Body(p) + Vector3.up * 0.4f, losMask);
		}

		private void TouchCheck(PlayerAvatar tgt)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)tgt != (Object)(object)chosen) && U.Valid(tgt) && !(Time.time < touchReady))
			{
				Vector3 val = ((Component)tgt).transform.position - ((Component)erb).transform.position;
				Vector3 val2 = U.Flat(val);
				if (((Vector3)(ref val2)).magnitude < 1.15f && Mathf.Abs(val.y + 0.5f) < 1.6f)
				{
					StartCeremony(tgt);
				}
			}
		}

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

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

		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 Leave(float time)
		{
			leaveTime = time;
			if (Object.op_Implicit((Object)(object)victim))
			{
				ReleaseVictim();
			}
			chosen = null;
			prevChosen = null;
			if (bq != Bq.Gone)
			{
				bq = Bq.Bride;
			}
			SyncBouquet();
			SetState(State.Leave);
		}

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

		private void BouquetTick(float dt)
		{
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_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