Decompiled source of TheSedimented v1.0.0

plugins/TheSedimented.dll

Decompiled 41 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Sedimented
{
	internal static class Blackout
	{
		public static bool Active;

		public static float Duration;

		private static SedimentedAI owner;

		private static bool inRound;

		private static Vector3 startPos;

		private static bool reported;

		private static float sinceStart;

		private static readonly List<(Light light, float intensity, bool enabled)> dimmed = new List<(Light, float, bool)>();

		private static readonly List<(PropLight pl, float original, bool wasOff)> props = new List<(PropLight, float, bool)>();

		private static readonly List<(PropLightEmission pe, Color original, bool wasOff)> emissions = new List<(PropLightEmission, Color, bool)>();

		private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor");

		private static Light[] allLights = (Light[])(object)new Light[0];

		private static float lightsScannedAt = -100f;

		private static Canvas canvas;

		private static RawImage shade;

		private static float shadeTarget;

		private static float flash;

		private static float flickerLeft;

		private static float flickerNext;

		private static bool caught;

		public static void Begin(SedimentedAI who, Vector3 at, float duration, bool playerInRound)
		{
			//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_0047: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			Duration = duration;
			PlayerAvatar instance = PlayerAvatar.instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				owner = who;
				inRound = playerInRound;
				startPos = ((Component)instance).transform.position;
				reported = false;
				sinceStart = 0f;
				if (Vector3.Distance(((Component)instance).transform.position, at) <= Plugin.Range.Value * 1.6f)
				{
					Active = true;
					DimLights(at);
					flickerLeft = 0.6f;
					flickerNext = 0f;
					EnsureCanvas();
					shadeTarget = Plugin.ShadeStrength.Value;
				}
			}
		}

		public static void End()
		{
			if (!Active && dimmed.Count == 0)
			{
				owner = null;
				inRound = false;
				return;
			}
			Active = false;
			inRound = false;
			owner = null;
			caught = false;
			RestoreLights();
			shadeTarget = 0f;
			FlashlightController instance = FlashlightController.Instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				instance.hideFlashlight = false;
			}
		}

		public static void CaughtOver()
		{
			caught = false;
		}

		public static void Flash(bool me)
		{
			if (!me)
			{
				flash = 1f;
			}
			else
			{
				caught = true;
			}
		}

		public static void Tick()
		{
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			if (Active && flickerLeft > 0f)
			{
				flickerLeft -= deltaTime;
				flickerNext -= deltaTime;
				if (flickerNext <= 0f)
				{
					flickerNext = Random.Range(0.05f, 0.14f);
					bool flag = Random.value < 0.5f;
					foreach (var item in dimmed)
					{
						if (Object.op_Implicit((Object)(object)item.light))
						{
							((Behaviour)item.light).enabled = flag && item.enabled;
						}
					}
					foreach (var prop in props)
					{
						if (Object.op_Implicit((Object)(object)prop.pl) && Object.op_Implicit((Object)(object)prop.pl.lightComponent))
						{
							prop.pl.lightComponent.intensity = (flag ? prop.original : 0f);
						}
					}
				}
				if (flickerLeft <= 0f)
				{
					foreach (var item2 in dimmed)
					{
						if (Object.op_Implicit((Object)(object)item2.light))
						{
							((Behaviour)item2.light).enabled = false;
						}
					}
					foreach (var prop2 in props)
					{
						if (Object.op_Implicit((Object)(object)prop2.pl) && Object.op_Implicit((Object)(object)prop2.pl.lightComponent))
						{
							prop2.pl.lightComponent.intensity = 0f;
						}
					}
				}
			}
			FlashlightController instance = FlashlightController.Instance;
			if (Object.op_Implicit((Object)(object)instance) && Active)
			{
				instance.hideFlashlight = flickerLeft <= 0f;
			}
			if (Active && Object.op_Implicit((Object)(object)LevelMusic.instance))
			{
				LevelMusic.instance.Interrupt(3f);
			}
			if (Object.op_Implicit((Object)(object)shade))
			{
				float a = ((Graphic)shade).color.a;
				float num = shadeTarget * ((Active && flickerLeft > 0f) ? 0.3f : 1f);
				a = ((num > a) ? num : Mathf.MoveTowards(a, num, deltaTime * 1.5f));
				if (flash > 0f)
				{
					flash = Mathf.MoveTowards(flash, 0f, deltaTime * 2.5f);
				}
				if (caught)
				{
					((Graphic)shade).color = new Color(0.7f, 0f, 0f, 0.5f);
					((Behaviour)shade).enabled = true;
					return;
				}
				((Graphic)shade).color = new Color(flash * 0.6f, 0f, 0f, Mathf.Clamp01(a + flash * 0.4f));
				((Behaviour)shade).enabled = ((Graphic)shade).color.a > 0.005f;
			}
			if (Active && inRound && !reported && !(flickerLeft > 0f))
			{
				sinceStart += deltaTime;
				PlayerAvatar instance2 = PlayerAvatar.instance;
				if (Object.op_Implicit((Object)(object)instance2) && !instance2.deadSet && !instance2.isTumbling && Object.op_Implicit((Object)(object)owner) && !(sinceStart < Plugin.SettleSeconds.Value) && (Mathf.Abs(SemiFunc.InputMovementX()) > 0.15f || Mathf.Abs(SemiFunc.InputMovementY()) > 0.15f || SemiFunc.InputDown((InputKey)1) || SemiFunc.InputDown((InputKey)14)))
				{
					reported = true;
					owner.ReportMoved();
				}
			}
		}

		private static void DimLights(Vector3 at)
		{
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			RestoreLights();
			float num = Plugin.Range.Value * Plugin.LightRadiusFactor.Value;
			LightManager instance = LightManager.instance;
			int num2 = 0;
			if (Object.op_Implicit((Object)(object)instance))
			{
				foreach (PropLight propLight in instance.propLights)
				{
					if (Object.op_Implicit((Object)(object)propLight) && Object.op_Implicit((Object)(object)propLight.lightComponent) && !(Vector3.Distance(((Component)propLight).transform.position, at) > num))
					{
						props.Add((propLight, propLight.originalIntensity, propLight.turnedOff));
						propLight.originalIntensity = 0f;
						propLight.lightComponent.intensity = 0f;
						propLight.turnedOff = true;
						if (propLight.hasHalo && Object.op_Implicit((Object)(object)propLight.halo))
						{
							propLight.halo.enabled = false;
						}
						num2++;
					}
				}
				foreach (PropLightEmission propEmission in instance.propEmissions)
				{
					if (Object.op_Implicit((Object)(object)propEmission) && Object.op_Implicit((Object)(object)propEmission.material) && !(Vector3.Distance(((Component)propEmission).transform.position, at) > num))
					{
						emissions.Add((propEmission, propEmission.originalEmission, propEmission.turnedOff));
						propEmission.originalEmission = Color.black;
						propEmission.material.SetColor(EmissionColorId, Color.black);
						propEmission.turnedOff = true;
					}
				}
			}
			if (Time.time - lightsScannedAt > 5f)
			{
				allLights = Object.FindObjectsByType<Light>((FindObjectsSortMode)0);
				lightsScannedAt = Time.time;
			}
			Light[] array = allLights;
			foreach (Light val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && ((Behaviour)val).enabled && (int)val.type != 1 && !Object.op_Implicit((Object)(object)((Component)val).GetComponent<PropLight>()) && !(Vector3.Distance(((Component)val).transform.position, at) > num) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<PlayerAvatar>()) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<FlashlightController>()) && (!Object.op_Implicit((Object)(object)owner) || !((Component)val).transform.IsChildOf(((Component)owner).transform.root)))
				{
					dimmed.Add((val, val.intensity, true));
				}
			}
			Plugin.Log.LogInfo((object)("blackout: " + num2 + " prop lights, " + emissions.Count + " emissive props, " + dimmed.Count + " other lights within " + num.ToString("0") + " m"));
		}

		private static void RestoreLights()
		{
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			foreach (var item in dimmed)
			{
				if (Object.op_Implicit((Object)(object)item.light))
				{
					((Behaviour)item.light).enabled = item.enabled;
					item.light.intensity = item.intensity;
				}
			}
			dimmed.Clear();
			foreach (var prop in props)
			{
				if (Object.op_Implicit((Object)(object)prop.pl))
				{
					prop.pl.originalIntensity = prop.original;
					prop.pl.turnedOff = prop.wasOff;
					if (Object.op_Implicit((Object)(object)prop.pl.lightComponent) && ((Component)prop.pl).gameObject.activeInHierarchy)
					{
						prop.pl.lightComponent.intensity = prop.original;
					}
					if (prop.pl.hasHalo && Object.op_Implicit((Object)(object)prop.pl.halo))
					{
						prop.pl.halo.enabled = !prop.wasOff;
					}
				}
			}
			props.Clear();
			foreach (var emission in emissions)
			{
				if (Object.op_Implicit((Object)(object)emission.pe) && Object.op_Implicit((Object)(object)emission.pe.material))
				{
					emission.pe.originalEmission = emission.original;
					emission.pe.turnedOff = emission.wasOff;
					emission.pe.material.SetColor(EmissionColorId, emission.original);
				}
			}
			emissions.Clear();
		}

		private static void EnsureCanvas()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00bc: 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)
			if (!Object.op_Implicit((Object)(object)canvas))
			{
				GameObject val = new GameObject("Sedimented Blackout Canvas");
				Object.DontDestroyOnLoad((Object)(object)val);
				canvas = val.AddComponent<Canvas>();
				canvas.renderMode = (RenderMode)0;
				canvas.sortingOrder = 5000;
				GameObject val2 = new GameObject("Shade");
				val2.transform.SetParent(val.transform, false);
				shade = val2.AddComponent<RawImage>();
				shade.texture = (Texture)(object)RadialTexture();
				((Graphic)shade).raycastTarget = false;
				((Graphic)shade).color = new Color(0f, 0f, 0f, 0f);
				RectTransform rectTransform = ((Graphic)shade).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = Vector2.one;
				rectTransform.offsetMin = Vector2.zero;
				rectTransform.offsetMax = Vector2.zero;
			}
		}

		private static Texture2D RadialTexture()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[65536];
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{
					float num = ((float)j + 0.5f) / 256f - 0.5f;
					float num2 = ((float)i + 0.5f) / 256f - 0.5f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2) / 0.5f;
					float num4 = Mathf.Lerp(0.72f, 1f, Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num3 - 0.15f) / 0.6f)));
					array[i * 256 + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)(num4 * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			return val;
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(EnemyDirector), "Awake")]
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void BuildBeforeDirector(EnemyDirector __instance)
		{
			try
			{
				SedimentedBuilder.BuildAndRegister(__instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("failed to build the Sedimented: " + ex));
			}
		}

		[HarmonyPatch(typeof(ItemToggle), "ToggleItemLogic")]
		[HarmonyPostfix]
		private static void ItemToggled(ItemToggle __instance, bool toggle, int player)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (toggle)
			{
				SedimentedAI.ReportUse(((Component)__instance).transform.position, player);
			}
		}

		[HarmonyPatch(typeof(ItemGun), "ShootRPC")]
		[HarmonyPostfix]
		private static void GunFired(ItemGun __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			SedimentedAI.ReportUse(((Component)__instance).transform.position, -1);
		}

		[HarmonyPatch(typeof(ItemMelee), "SwingHit")]
		[HarmonyPostfix]
		private static void MeleeSwung(ItemMelee __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			SedimentedAI.ReportUse(((Component)__instance).transform.position, -1);
		}

		[HarmonyPatch(typeof(ItemGrenade), "TickStartRPC")]
		[HarmonyPostfix]
		private static void GrenadeArmed(ItemGrenade __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			SedimentedAI.ReportUse(((Component)__instance).transform.position, -1);
		}

		[HarmonyPatch(typeof(EnemyDirector), "AmountSetup")]
		[HarmonyPostfix]
		private static void ForceSpawn(EnemyDirector __instance)
		{
			if (Plugin.AlwaysSpawn.Value && !((Object)(object)SedimentedBuilder.Setup == (Object)null))
			{
				List<EnemySetup> enemyList = __instance.enemyList;
				int enemyListIndex = __instance.enemyListIndex;
				if (enemyListIndex < enemyList.Count)
				{
					enemyList[enemyListIndex] = SedimentedBuilder.Setup;
					return;
				}
				enemyList.Add(SedimentedBuilder.Setup);
				__instance.totalAmount++;
			}
		}
	}
	[BepInPlugin("bigbootyteam.thesedimented", "TheSedimented", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "bigbootyteam.thesedimented";

		public const string Name = "TheSedimented";

		public const string Version = "1.0.0";

		public const float BodyHeight = 2.4f;

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static GameObject ModelPrefab;

		internal static Texture2D Atlas;

		internal static Texture2D NormalMap;

		internal static Texture2D SheenMask;

		internal static ConfigEntry<float> GoldSheen;

		internal static Shader GameShader;

		internal static ConfigEntry<int> Health;

		internal static ConfigEntry<int> Difficulty;

		internal static ConfigEntry<float> Rarity;

		internal static ConfigEntry<bool> AlwaysSpawn;

		internal static ConfigEntry<float> WalkSpeed;

		internal static ConfigEntry<float> ChaseSpeed;

		internal static ConfigEntry<int> TouchDamage;

		internal static ConfigEntry<bool> TeleportToPlayers;

		internal static ConfigEntry<float> TeleportAfter;

		internal static ConfigEntry<float> Range;

		internal static ConfigEntry<float> ShhMin;

		internal static ConfigEntry<float> ShhMax;

		internal static ConfigEntry<float> ShhGrace;

		internal static ConfigEntry<float> BlackoutMin;

		internal static ConfigEntry<float> BlackoutMax;

		internal static ConfigEntry<float> MoveThreshold;

		internal static ConfigEntry<bool> InstantKill;

		internal static ConfigEntry<int> CaughtDamage;

		internal static ConfigEntry<float> DetectedDelay;

		internal static ConfigEntry<float> SettleSeconds;

		internal static ConfigEntry<bool> FreezeOthers;

		internal static ConfigEntry<float> LightRadiusFactor;

		internal static ConfigEntry<float> ShadeStrength;

		internal static ConfigEntry<float> MusicVolume;

		internal static ConfigEntry<float> VoiceVolume;

		internal static ConfigEntry<KeyboardShortcut> PreviewKey;

		internal static ConfigEntry<float> SpawnDistance;

		private RenderTexture warmRt;

		private void Awake()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Health = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Health", 400, new ConfigDescription("Damage it takes to kill her.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 5000), Array.Empty<object>()));
			Difficulty = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Tier", 2, new ConfigDescription("Which enemy tier she spawns in (1 weakest, 3 strongest).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
			Rarity = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "SpawnRarity", 80f, new ConfigDescription("How likely she is to be picked in her tier (most vanilla enemies use 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
			AlwaysSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "AlwaysSpawn", false, "Every level has a Sedimented (for testing).");
			WalkSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "RoamSpeed", 1.4f, "Roaming speed.");
			ChaseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "HuntSpeed2", 1.4f, "Hunting speed. Slow on purpose: you can walk away from her, which is what makes the stop-still rounds the real threat.");
			TouchDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Movement", "TouchDamage", 35, "Damage when she reaches you during green light (0 = she only kills during blackouts).");
			GoldSheen = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "GoldSheen", 0.6f, "How much the gold patches catch the light (0 = matte like the rest, 1 = full sheen). Not a glow: nothing shows in the dark.");
			TeleportToPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "TeleportToPlayers", true, "Like Limbus: when nobody has been near her for a while she appears near a player, out of their sight.");
			TeleportAfter = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "TeleportAfterSeconds", 45f, "How long she must be alone before she teleports.");
			Range = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "Range", 15f, "Metres. If you can hear her music you are in range (about one and a half rooms).");
			ShhGrace = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "GraceSeconds", 4f, "Someone must have been in range this long before she can start a round.");
			ShhMin = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "ShhGapMin", 4f, "Shortest time between the end of one round and the next shh (seconds).");
			ShhMax = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "ShhGapMax2", 15f, "Longest time between rounds (seconds).");
			BlackoutMin = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "BlackoutMin", 4f, "Shortest blackout (seconds).");
			BlackoutMax = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "BlackoutMax", 6.5f, "Longest blackout (seconds).");
			MoveThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "MoveThreshold", 0.12f, "(unused since movement is read from your input, not your position)");
			InstantKill = ((BaseUnityPlugin)this).Config.Bind<bool>("Game", "InstantKill", true, "Moving during the blackout kills outright.");
			CaughtDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Game", "CaughtDamage", 100, "Damage instead, when InstantKill is off.");
			FreezeOthers = ((BaseUnityPlugin)this).Config.Bind<bool>("Game", "FreezeOtherEnemies", true, "The blackout also freezes every other enemy within her range, so standing still is genuinely safe.");
			SettleSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "SettleSeconds", 0.4f, "Seconds after the lights go out during which moving is still allowed.");
			DetectedDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Game", "SpottedToDeath", 0.7f, "Seconds between being spotted and the death.");
			LightRadiusFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Blackout", "LightRadiusFactor", 1.2f, "Lights within Range x this go out.");
			ShadeStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Blackout", "ShadeStrength", 0.92f, "How dark the screen gets (0-1).");
			MusicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "MusicVolume", 0.8f, "Her theme while she hunts.");
			VoiceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "VoiceVolume", 1f, "The shh / detected / lights sounds.");
			PreviewKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Testing", "PreviewModelKey", new KeyboardShortcut((KeyCode)285, Array.Empty<KeyCode>()), "Spawns a static copy of her model in front of you (no AI). Shift removes them. Use ModTestKit's F6 to spawn the real enemy.");
			SpawnDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Testing", "PreviewDistance", 4f, "How far in front of you the preview appears.");
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "sedimented");
			if (!File.Exists(text))
			{
				Log.LogError((object)("asset bundle not found: " + text));
				return;
			}
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)("failed to load asset bundle " + text));
				return;
			}
			ModelPrefab = val.LoadAsset<GameObject>("Assets/Sedimented/Sedimented.prefab");
			Atlas = val.LoadAsset<Texture2D>("Assets/Sedimented/sedimented_atlas.png");
			NormalMap = val.LoadAsset<Texture2D>("Assets/Sedimented/sedimented_normal.png");
			SheenMask = val.LoadAsset<Texture2D>("Assets/Sedimented/sedimented_mask.png");
			if ((Object)(object)ModelPrefab == (Object)null || (Object)(object)Atlas == (Object)null)
			{
				Log.LogError((object)("prefab or atlas missing from bundle; assets: " + string.Join(", ", val.GetAllAssetNames())));
				return;
			}
			((MonoBehaviour)this).StartCoroutine(Sounds.LoadAll(directoryName));
			((MonoBehaviour)this).StartCoroutine(WarmAtlas());
			new Harmony("bigbootyteam.thesedimented").PatchAll(typeof(Patches));
			Log.LogInfo((object)"TheSedimented 1.0.0 loaded; she is registered when the enemy director wakes up.");
		}

		private IEnumerator WarmAtlas()
		{
			RenderTexture rt = RenderTexture.GetTemporary(64, 64, 0);
			for (int i = 0; i < 300; i++)
			{
				if (Object.op_Implicit((Object)(object)Atlas))
				{
					Graphics.Blit((Texture)(object)Atlas, rt);
				}
				yield return null;
			}
			RenderTexture.ReleaseTemporary(rt);
		}

		private void Update()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			Blackout.Tick();
			if (Object.op_Implicit((Object)(object)Atlas))
			{
				if (!Object.op_Implicit((Object)(object)warmRt))
				{
					warmRt = new RenderTexture(64, 64, 0);
				}
				Graphics.Blit((Texture)(object)Atlas, warmRt);
				if (Object.op_Implicit((Object)(object)NormalMap))
				{
					Graphics.Blit((Texture)(object)NormalMap, warmRt);
				}
				if (Object.op_Implicit((Object)(object)SheenMask))
				{
					Graphics.Blit((Texture)(object)SheenMask, warmRt);
				}
			}
			if ((Object)(object)ModelPrefab == (Object)null)
			{
				return;
			}
			KeyboardShortcut value = PreviewKey.Value;
			if (!((KeyboardShortcut)(ref value)).IsDown())
			{
				return;
			}
			if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
			{
				SedimentedIdle[] array = Object.FindObjectsByType<SedimentedIdle>((FindObjectsSortMode)0);
				foreach (SedimentedIdle sedimentedIdle in array)
				{
					if (!Object.op_Implicit((Object)(object)((Component)sedimentedIdle).GetComponentInParent<Enemy>()))
					{
						Object.Destroy((Object)(object)((Component)((Component)sedimentedIdle).transform.root).gameObject);
					}
				}
				return;
			}
			PlayerAvatar instance = PlayerAvatar.instance;
			if ((Object)(object)instance == (Object)null)
			{
				Log.LogWarning((object)"no player avatar yet; join a level first");
				return;
			}
			Vector3 forward = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : ((Component)instance).transform).forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			Vector3 val = ((Component)instance).transform.position + forward * SpawnDistance.Value;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 2f, Vector3.down, ref val2, 10f, LayerMask.GetMask(new string[1] { "Default" })))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			GameObject obj = Object.Instantiate<GameObject>(ModelPrefab, val, Quaternion.LookRotation(-forward, Vector3.up));
			((Object)obj).name = "The Sedimented (preview)";
			ApplyGameLook(obj);
			obj.AddComponent<SedimentedIdle>();
		}

		internal static void ApplyGameLook(GameObject go)
		{
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GameShader == (Object)null)
			{
				Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
				foreach (Shader val in array)
				{
					if (((Object)val).name.IndexOf("Fresnel", StringComparison.OrdinalIgnoreCase) >= 0 && ((Object)val).name.IndexOf("Opaque", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						GameShader = val;
						break;
					}
				}
				if ((Object)(object)GameShader == (Object)null)
				{
					Log.LogWarning((object)"game shader not found; keeping the bundled material");
					return;
				}
				StringBuilder stringBuilder = new StringBuilder();
				for (int j = 0; j < GameShader.GetPropertyCount(); j++)
				{
					stringBuilder.Append(GameShader.GetPropertyName(j)).Append(' ');
				}
				Log.LogInfo((object)("using shader \"" + ((Object)GameShader).name + "\": " + stringBuilder));
			}
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				Texture atlas = (Texture)(object)Atlas;
				Material val3 = new Material(GameShader)
				{
					name = "Sedimented (game)"
				};
				string[] array2 = new string[3] { "_BaseTexture", "_BaseMap", "_MainTex" };
				foreach (string text in array2)
				{
					if (val3.HasProperty(text))
					{
						val3.SetTexture(text, atlas);
						break;
					}
				}
				if (val3.HasProperty("_BaseColor"))
				{
					val3.SetColor("_BaseColor", Color.white);
				}
				if (val3.HasProperty("_EmissionColor"))
				{
					val3.SetColor("_EmissionColor", Color.black);
				}
				if (val3.HasProperty("_EmissionTexture"))
				{
					val3.SetTexture("_EmissionTexture", (Texture)(object)Texture2D.whiteTexture);
				}
				float num = ((GoldSheen != null) ? Mathf.Clamp01(GoldSheen.Value) : 0f);
				if (Object.op_Implicit((Object)(object)SheenMask) && num > 0f && val3.HasProperty("_SmoothnessTexture"))
				{
					val3.SetTexture("_SmoothnessTexture", (Texture)(object)SheenMask);
					if (val3.HasProperty("_MetallicTexture"))
					{
						val3.SetTexture("_MetallicTexture", (Texture)(object)SheenMask);
					}
					if (val3.HasProperty("_Smoothness"))
					{
						val3.SetFloat("_Smoothness", 0.25f + 0.55f * num);
					}
					if (val3.HasProperty("_Metallic"))
					{
						val3.SetFloat("_Metallic", 0.6f * num);
					}
				}
				else
				{
					if (val3.HasProperty("_Metallic"))
					{
						val3.SetFloat("_Metallic", 0f);
					}
					if (val3.HasProperty("_Smoothness"))
					{
						val3.SetFloat("_Smoothness", 0.25f);
					}
				}
				if (Object.op_Implicit((Object)(object)NormalMap) && val3.HasProperty("_NormalTexture"))
				{
					val3.SetTexture("_NormalTexture", (Texture)(object)NormalMap);
					if (val3.HasProperty("_NormalStrength"))
					{
						val3.SetFloat("_NormalStrength", 1f);
					}
				}
				else if (val3.HasProperty("_NormalStrength"))
				{
					val3.SetFloat("_NormalStrength", 0f);
				}
				if (val3.HasProperty("_TilingX"))
				{
					val3.SetFloat("_TilingX", 1f);
				}
				if (val3.HasProperty("_TilingY"))
				{
					val3.SetFloat("_TilingY", 1f);
				}
				if (val3.HasProperty("_OffsetX"))
				{
					val3.SetFloat("_OffsetX", 0f);
				}
				if (val3.HasProperty("_OffsetY"))
				{
					val3.SetFloat("_OffsetY", 0f);
				}
				val2.sharedMaterial = val3;
				Log.LogInfo((object)("material set: texture " + (((Object)(object)atlas != (Object)null) ? (((Object)atlas).name + " " + atlas.width + "x" + atlas.height) : "NULL") + ", fresnel colour " + (val3.HasProperty("_FresnelColor") ? ((object)val3.GetColor("_FresnelColor")/*cast due to .constrained prefix*/).ToString() : "n/a")));
			}
		}
	}
	public class SedimentedIdle : MonoBehaviour
	{
		private struct Key
		{
			public float t;

			public Vector3 chest;

			public Vector3 spine;

			public Vector3 hips;

			public Vector3 upper;

			public Vector3 lower;

			public Vector3 hand;

			public Vector3 head;
		}

		private Transform hips;

		private Transform spine;

		private Transform chest;

		private Transform head;

		private Transform bun;

		private Transform skirt1;

		private Transform skirt2;

		private Transform skirt3;

		private Transform upperR;

		private Transform lowerR;

		private Transform handR;

		private Transform fan;

		private Transform upperL;

		private Transform lowerL;

		private Transform rib1;

		private Transform rib2;

		private float t;

		public bool frozen;

		public float walk;

		public float attackTime = -1f;

		public bool stunned;

		private float slump;

		private bool wasStunned;

		private float recover;

		private const float RecoverSeconds = 1.4f;

		public const float SwipeLength = 1.3f;

		private static readonly Key[] Swipe = new Key[6]
		{
			new Key
			{
				t = 0f
			},
			new Key
			{
				t = 0.42f,
				chest = new Vector3(-12f, 28f, 0f),
				spine = new Vector3(-4f, 10f, 0f),
				hips = new Vector3(0f, 6f, 0f),
				upper = new Vector3(40f, 0f, 75f),
				lower = new Vector3(-20f, 0f, 0f),
				hand = new Vector3(-20f, 0f, 0f),
				head = new Vector3(-5f, -20f, 0f)
			},
			new Key
			{
				t = 0.58f,
				chest = new Vector3(28f, -8f, 0f),
				spine = new Vector3(10f, -4f, 0f),
				hips = new Vector3(4f, -4f, 0f),
				upper = new Vector3(-25f, 0f, 20f),
				lower = new Vector3(120f, 0f, 0f),
				hand = new Vector3(10f, 0f, 0f),
				head = new Vector3(15f, 5f, 0f)
			},
			new Key
			{
				t = 0.74f,
				chest = new Vector3(38f, -36f, 0f),
				spine = new Vector3(14f, -12f, 0f),
				hips = new Vector3(6f, -8f, 0f),
				upper = new Vector3(-62f, 0f, -42f),
				lower = new Vector3(150f, 0f, 0f),
				hand = new Vector3(25f, 0f, 0f),
				head = new Vector3(20f, 15f, 0f)
			},
			new Key
			{
				t = 0.92f,
				chest = new Vector3(22f, -30f, 0f),
				spine = new Vector3(8f, -10f, 0f),
				hips = new Vector3(3f, -6f, 0f),
				upper = new Vector3(-40f, 0f, -30f),
				lower = new Vector3(110f, 0f, 0f),
				hand = new Vector3(10f, 0f, 0f),
				head = new Vector3(10f, 10f, 0f)
			},
			new Key
			{
				t = 1.3f
			}
		};

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

		private static Vector3 Sample(float t, Func<Key, Vector3> pick)
		{
			//IL_00a0: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Swipe.Length - 1; i++)
			{
				if (!(t > Swipe[i + 1].t))
				{
					float num = Smooth((t - Swipe[i].t) / Mathf.Max(0.0001f, Swipe[i + 1].t - Swipe[i].t));
					return Vector3.Lerp(pick(Swipe[i]), pick(Swipe[i + 1]), num);
				}
			}
			return Vector3.zero;
		}

		private static void Blend(Transform b, Vector3 idle, Vector3 pose, float w)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)b != (Object)null)
			{
				b.localRotation = Quaternion.Slerp(Quaternion.Euler(idle), Quaternion.Euler(pose), w);
			}
		}

		private void Start()
		{
			hips = Find("Hips");
			spine = Find("Spine");
			chest = Find("Chest");
			head = Find("Head");
			bun = Find("HairBun");
			skirt1 = Find("Skirt_1");
			skirt2 = Find("Skirt_2");
			skirt3 = Find("Skirt_3");
			upperR = Find("UpperArm_R");
			lowerR = Find("LowerArm_R");
			handR = Find("Hand_R");
			fan = Find("Fan");
			upperL = Find("UpperArm_L");
			lowerL = Find("LowerArm_L");
			rib1 = Find("Streamer_1");
			rib2 = Find("Streamer_2");
			t = Random.Range(0f, 10f);
		}

		private Transform Find(string n)
		{
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name == n)
				{
					return val;
				}
			}
			Plugin.Log.LogWarning((object)("bone not found: " + n));
			return null;
		}

		private static void Rot(Transform b, float x, float y, float z)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)b != (Object)null)
			{
				b.localRotation = Quaternion.Euler(x, y, z);
			}
		}

		private void Update()
		{
			//IL_00b9: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0714: Unknown result type (might be due to invalid IL or missing references)
			//IL_0726: Unknown result type (might be due to invalid IL or missing references)
			//IL_0738: Unknown result type (might be due to invalid IL or missing references)
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			if (frozen)
			{
				return;
			}
			t += Time.deltaTime * (1f + walk * 1.5f);
			float num = Mathf.Sin(t * 1.1f) * (1f + walk * 1.2f);
			float num2 = Mathf.Sin(t * 1.7f);
			float num3 = attackTime;
			float w = 0f;
			if (num3 >= 0f && num3 <= 1.3f)
			{
				w = Smooth(num3 / 0.12f) * Smooth((1.3f - num3) / 0.3f);
			}
			Blend(hips, new Vector3(0f, 0f, num * 2.5f), Sample(num3, (Key k) => k.hips), w);
			Rot(skirt1, 0f, 0f, (0f - num) * 1.5f);
			Rot(skirt2, 0f, 0f, (0f - Mathf.Sin(t * 1.1f - 0.5f)) * 1.5f);
			Rot(skirt3, 0f, 0f, (0f - Mathf.Sin(t * 1.1f - 1f)) * 1f);
			Blend(spine, new Vector3(num2 * 1f, 0f, (0f - num) * 1f), Sample(num3, (Key k) => k.spine), w);
			Blend(chest, new Vector3(num2 * 1.5f, 0f, 0f), Sample(num3, (Key k) => k.chest), w);
			Blend(head, new Vector3(Mathf.Sin(t * 0.7f) * 3f, Mathf.Sin(t * 0.45f) * 10f, (0f - num) * 2f), Sample(num3, (Key k) => k.head), w);
			Rot(bun, 0f, 0f, Mathf.Sin(t * 1.1f - 0.6f) * 3f);
			float num4 = Mathf.Sin(t * 4.5f) * 6f;
			Blend(upperR, new Vector3(Mathf.Sin(t * 0.9f) * 3f, 0f, Mathf.Sin(t * 0.6f) * 3f), Sample(num3, (Key k) => k.upper), w);
			Blend(lowerR, new Vector3(0f, 0f, Mathf.Sin(t * 0.9f + 1f) * 4f), Sample(num3, (Key k) => k.lower), w);
			Blend(handR, new Vector3(num4, 0f, num4 * 0.5f), Sample(num3, (Key k) => k.hand), w);
			Rot(fan, 0f, Mathf.Sin(t * 4.5f + 0.4f) * 5f, 0f);
			Rot(rib1, Mathf.Sin(t * 2.3f) * 6f, 0f, Mathf.Sin(t * 1.9f) * 5f);
			Rot(rib2, Mathf.Sin(t * 2.3f - 0.7f) * 8f, 0f, Mathf.Sin(t * 1.9f - 0.6f) * 7f);
			Rot(upperL, 0f, 0f, num2 * 1.5f);
			Rot(lowerL, Mathf.Sin(t * 0.8f) * 2f, 0f, 0f);
			if (stunned && !wasStunned)
			{
				Plugin.Log.LogInfo((object)("stun: slump begins (slump " + slump.ToString("0.00") + ")"));
			}
			if (!stunned && wasStunned)
			{
				recover = 0f;
				Plugin.Log.LogInfo((object)("stun: over, standing up from slump " + slump.ToString("0.00")));
			}
			wasStunned = stunned;
			if (stunned)
			{
				slump = Mathf.MoveTowards(slump, 1f, Time.deltaTime * 2.5f);
			}
			else if (slump > 0f)
			{
				recover += Time.deltaTime;
				slump = Mathf.Min(slump, 1f - Smooth(recover / 1.4f));
				if (slump <= 0.001f)
				{
					slump = 0f;
					Plugin.Log.LogInfo((object)("stun: upright after " + recover.ToString("0.00") + " s"));
				}
			}
			if (slump > 0.001f)
			{
				float w2 = Smooth(slump);
				Over(hips, new Vector3(6f, 0f, 8f), w2);
				Over(spine, new Vector3(28f, 0f, -6f), w2);
				Over(chest, new Vector3(30f, 0f, 0f), w2);
				Over(head, new Vector3(40f, -15f, 10f), w2);
				Over(upperR, new Vector3(-20f, 0f, -70f), w2);
				Over(lowerR, new Vector3(140f, 0f, 0f), w2);
				Over(handR, new Vector3(30f, 0f, 0f), w2);
				Over(upperL, new Vector3(0f, 0f, 10f), w2);
				Over(skirt1, Vector3.zero, w2);
				Over(skirt2, Vector3.zero, w2);
				Over(skirt3, Vector3.zero, w2);
			}
		}

		private static void Over(Transform b, Vector3 pose, float w)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)b != (Object)null)
			{
				b.localRotation = Quaternion.Slerp(b.localRotation, Quaternion.Euler(pose), w);
			}
		}
	}
	public class SedimentedAI : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Roam,
			Chase,
			Attack,
			Shh,
			Blackout,
			Resume,
			Stun,
			Despawn,
			Dead,
			Investigate,
			Leave
		}

		public Transform model;

		public AudioSource music;

		public AudioSource voice;

		public SedimentedIdle idle;

		private Enemy enemy;

		private PhotonView photonView;

		private EnemyHealth health;

		private State state;

		private bool impulse = true;

		private float stateTimer;

		private float shhTimer;

		private float inRangeFor;

		private Vector3 destination;

		private PlayerAvatar target;

		private float lostTimer;

		private Vector3 lastSeen;

		private bool searching;

		private float hitCooldown;

		private float musicFade;

		private readonly HashSet<int> roundPlayers = new HashSet<int>();

		private readonly HashSet<int> killed = new HashSet<int>();

		private Vector3 lastPos;

		private float walkPhase;

		private Quaternion facing = Quaternion.identity;

		private Transform headBone;

		private float attackClock;

		private float unreachableFor;

		private bool probing;

		private float blackoutClock;

		private Vector3 noiseAt;

		private float hurtFlash;

		private float syncTimer;

		private float quietFor;

		private float teleportCooldown;

		private float lookAround;

		private Quaternion lookBase;

		private int sentTargetId = -2;

		private float leaveFor;

		private Material[] skinMats;

		private bool hurtFlashWas;

		private PlayerAvatar caughtPlayer;

		private float caughtLockLeft;

		private bool facingSet;

		private const float AttackRange = 2.3f;

		private static readonly List<SedimentedAI> All = new List<SedimentedAI>();

		private const float LookRoundTime = 2.6f;

		private static readonly RaycastHit[] sightHits = (RaycastHit[])(object)new RaycastHit[32];

		private void Awake()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			enemy = ((Component)this).GetComponent<Enemy>();
			photonView = ((Component)this).GetComponent<PhotonView>();
			health = ((Component)this).GetComponent<EnemyHealth>();
			EnemyStateSpawn component = ((Component)this).GetComponent<EnemyStateSpawn>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.OnSpawn.AddListener(new UnityAction(OnSpawn));
			}
			if (Object.op_Implicit((Object)(object)health))
			{
				health.onDeath.AddListener(new UnityAction(OnDeath));
				health.onHurt.AddListener(new UnityAction(OnHurt));
			}
			EnemyVision vision = ((Component)this).GetComponent<EnemyVision>();
			if (Object.op_Implicit((Object)(object)vision))
			{
				vision.onVisionTriggered.AddListener((UnityAction)delegate
				{
					OnSeen(vision.onVisionTriggeredPlayer);
				});
			}
			EnemyStateInvestigate inv = ((Component)this).GetComponent<EnemyStateInvestigate>();
			if (Object.op_Implicit((Object)(object)inv))
			{
				inv.onInvestigateTriggered.AddListener((UnityAction)delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					OnNoise(inv.onInvestigateTriggeredPosition);
				});
			}
			if (Object.op_Implicit((Object)(object)enemy.Rigidbody))
			{
				EnemyRigidbody erb = enemy.Rigidbody;
				erb.onTouchPlayer.AddListener((UnityAction)delegate
				{
					OnTouched(erb.onTouchPlayerAvatar);
				});
				erb.onTouchPlayerGrabbedObject.AddListener((UnityAction)delegate
				{
					OnTouched(erb.onTouchPlayerGrabbedObjectAvatar);
				});
				erb.onGrabbed.AddListener((UnityAction)delegate
				{
					OnTouched(erb.onGrabbedPlayerAvatar);
				});
			}
			if (Object.op_Implicit((Object)(object)model))
			{
				Transform[] componentsInChildren = ((Component)model).GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					if (((Object)val).name == "Head")
					{
						headBone = val;
					}
				}
			}
			if (Object.op_Implicit((Object)(object)headBone))
			{
				enemy.KillLookAtTransform = headBone;
			}
		}

		private void OnEnable()
		{
			if (!All.Contains(this))
			{
				All.Add(this);
			}
			if (Object.op_Implicit((Object)(object)photonView))
			{
				photonView.RefreshRpcMonoBehaviourCache();
			}
			state = State.Spawn;
			impulse = true;
			stateTimer = 0f;
			target = null;
			shhTimer = Random.Range(Plugin.ShhMin.Value, Plugin.ShhMax.Value);
			Blackout.End();
		}

		private void OnDisable()
		{
			All.Remove(this);
			if (Object.op_Implicit((Object)(object)music))
			{
				music.Stop();
			}
			if (state == State.Blackout)
			{
				Blackout.End();
			}
		}

		private void OnSpawn()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (!SemiFunc.EnemySpawn(enemy))
				{
					return;
				}
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
				target = null;
				state = State.Spawn;
				impulse = true;
				stateTimer = 0f;
			}
			((MonoBehaviour)this).StartCoroutine(SpawnDiagnostics());
		}

		private IEnumerator SpawnDiagnostics()
		{
			for (int i = 0; i < 3; i++)
			{
				yield return (object)new WaitForSeconds((i == 0) ? 0.5f : 3f);
				if (!Object.op_Implicit((Object)(object)model))
				{
					break;
				}
				SkinnedMeshRenderer componentInChildren = ((Component)model).GetComponentInChildren<SkinnedMeshRenderer>();
				string text = "";
				string[] array = new string[4] { "Hand_R", "Fan", "Hand_L", "Head" };
				Vector3 val2;
				foreach (string text2 in array)
				{
					Transform[] componentsInChildren = ((Component)model).GetComponentsInChildren<Transform>(true);
					foreach (Transform val in componentsInChildren)
					{
						if (((Object)val).name == text2)
						{
							string[] obj = new string[5] { text, text2, "=", null, null };
							val2 = val.position - model.position;
							obj[3] = ((Vector3)(ref val2)).ToString("0.00");
							obj[4] = " ";
							text = string.Concat(obj);
							break;
						}
					}
				}
				Texture2D atlas = Plugin.Atlas;
				string text3 = (Object.op_Implicit((Object)(object)atlas) ? ("atlas " + ((Texture)atlas).width + " mips=" + ((Texture)atlas).mipmapCount + " loadedMip=" + atlas.loadedMipmapLevel + " desiredMip=" + atlas.desiredMipmapLevel + " streaming=" + atlas.streamingMipmaps) : "atlas DEAD");
				text3 = text3 + " | streamingActive=" + QualitySettings.streamingMipmapsActive + " streamingCount=" + Texture.streamingTextureCount + " texMem=" + Texture.currentTextureMemory / 1048576 + "/" + Texture.totalTextureMemory / 1048576 + "MB";
				ManualLogSource log = Plugin.Log;
				string[] obj2 = new string[10]
				{
					"spawn+",
					(0.5f + 3f * (float)i).ToString(),
					"s: renderer ",
					null,
					null,
					null,
					null,
					null,
					null,
					null
				};
				object obj3;
				if (!Object.op_Implicit((Object)(object)componentInChildren))
				{
					obj3 = "none";
				}
				else
				{
					string[] obj4 = new string[9]
					{
						((Renderer)componentInChildren).enabled ? "on" : "OFF",
						" visible=",
						((Renderer)componentInChildren).isVisible.ToString(),
						" bounds=",
						null,
						null,
						null,
						null,
						null
					};
					Bounds bounds = ((Renderer)componentInChildren).bounds;
					val2 = ((Bounds)(ref bounds)).size;
					obj4[4] = ((Vector3)(ref val2)).ToString("0.0");
					obj4[5] = " mat=";
					obj4[6] = (Object.op_Implicit((Object)(object)((Renderer)componentInChildren).sharedMaterial) ? ((Object)((Renderer)componentInChildren).sharedMaterial.shader).name : "none");
					obj4[7] = " tex=";
					obj4[8] = ((Object.op_Implicit((Object)(object)((Renderer)componentInChildren).sharedMaterial) && ((Renderer)componentInChildren).sharedMaterial.HasProperty("_BaseTexture") && Object.op_Implicit((Object)(object)((Renderer)componentInChildren).sharedMaterial.GetTexture("_BaseTexture"))) ? "ok" : "NONE");
					obj3 = string.Concat(obj4);
				}
				obj2[3] = (string)obj3;
				obj2[4] = " scale=";
				val2 = model.lossyScale;
				obj2[5] = ((Vector3)(ref val2)).ToString("0.00");
				obj2[6] = " ";
				obj2[7] = text;
				obj2[8] = "| ";
				obj2[9] = text3;
				log.LogInfo((object)string.Concat(obj2));
			}
		}

		private void OnHurt()
		{
			hurtFlash = 1f;
			if (Object.op_Implicit((Object)(object)voice) && Object.op_Implicit((Object)(object)Sounds.Hurt))
			{
				voice.PlayOneShot(Sounds.Hurt, Plugin.VoiceVolume.Value);
			}
			if (CanBeWoken() && SemiFunc.IsMasterClientOrSingleplayer())
			{
				target = Nearest(Plugin.Range.Value * 2f);
				if (Object.op_Implicit((Object)(object)target))
				{
					Set(State.Chase);
				}
			}
		}

		private bool CanBeWoken()
		{
			if (state == State.Roam || state == State.Investigate || state == State.Leave)
			{
				return true;
			}
			if (state == State.Despawn && Object.op_Implicit((Object)(object)enemy.EnemyParent))
			{
				return !enemy.EnemyParent.forceLeave;
			}
			return false;
		}

		private void OnTouched(PlayerAvatar p)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer() && Alive(p) && (CanBeWoken() || (state == State.Chase && (Object)(object)target != (Object)(object)p)))
			{
				target = p;
				lastSeen = ((Component)p).transform.position;
				searching = false;
				lostTimer = 0f;
				if (state != State.Chase)
				{
					Set(State.Chase);
				}
			}
		}

		internal static void ReportUse(Vector3 at, int playerViewId)
		{
			//IL_0059: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			PlayerAvatar val = null;
			if (playerViewId >= 0)
			{
				foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
				{
					if (item.photonView.ViewID == playerViewId)
					{
						val = item;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SemiFunc.PlayerGetNearestPlayerAvatarWithinRange(2.5f, at, false, default(LayerMask));
			}
			foreach (SedimentedAI item2 in All)
			{
				if (Object.op_Implicit((Object)(object)item2) && ((Behaviour)item2).isActiveAndEnabled && item2.state != State.Dead && item2.state != State.Despawn && item2.state == State.Blackout && item2.blackoutClock > Plugin.SettleSeconds.Value && Alive(val) && item2.roundPlayers.Contains(val.photonView.ViewID))
				{
					item2.Caught(val.photonView.ViewID);
				}
			}
		}

		private void OnNoise(Vector3 at)
		{
			//IL_001c: 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)
			if (SemiFunc.IsMasterClientOrSingleplayer() && (state == State.Roam || state == State.Investigate))
			{
				noiseAt = at;
				if (state == State.Investigate)
				{
					impulse = true;
				}
				else
				{
					Set(State.Investigate);
				}
			}
		}

		private void OnDeath()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (state == State.Blackout)
			{
				BlackoutEnd();
			}
			Set(State.Dead);
			if (Object.op_Implicit((Object)(object)music))
			{
				music.Stop();
			}
			if (Object.op_Implicit((Object)(object)voice) && Object.op_Implicit((Object)(object)Sounds.Death))
			{
				voice.PlayOneShot(Sounds.Death, Plugin.VoiceVolume.Value);
			}
			if (Object.op_Implicit((Object)(object)GameDirector.instance) && Object.op_Implicit((Object)(object)enemy.CenterTransform))
			{
				GameDirector.instance.CameraShake.ShakeDistance(5f, 3f, 10f, enemy.CenterTransform.position, 0.5f);
				GameDirector.instance.CameraImpact.ShakeDistance(5f, 3f, 10f, enemy.CenterTransform.position, 0.05f);
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				enemy.EnemyParent.Despawn();
			}
		}

		private void OnSeen(PlayerAvatar p)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer() && Alive(p) && (CanBeWoken() || (state == State.Chase && !Object.op_Implicit((Object)(object)target))))
			{
				target = p;
				lastSeen = ((Component)p).transform.position;
				searching = false;
				lostTimer = 0f;
				Set(State.Chase);
			}
		}

		private void Update()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				HostLogic();
			}
			MusicLogic();
			WalkLogic();
			CaughtLockLogic();
		}

		private void HostLogic()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Invalid comparison between Unknown and I4
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f93: Invalid comparison between Unknown and I4
			//IL_0ceb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e09: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_1017: Unknown result type (might be due to invalid IL or missing references)
			//IL_101c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e64: 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_1044: Unknown result type (might be due to invalid IL or missing references)
			//IL_104a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_106a: Unknown result type (might be due to invalid IL or missing references)
			//IL_106f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0822: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_08db: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0941: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Unknown result type (might be due to invalid IL or missing references)
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			if (state == State.Dead)
			{
				return;
			}
			if (enemy.IsStunned() && state != State.Blackout)
			{
				Set(State.Stun);
			}
			else if ((int)enemy.CurrentState == 11 && state != State.Blackout && !Object.op_Implicit((Object)(object)target))
			{
				Set(State.Despawn);
			}
			if (Object.op_Implicit((Object)(object)target) && state != State.Despawn)
			{
				EnemyParent enemyParent = enemy.EnemyParent;
				if (enemyParent.SpawnedTimer < 30f)
				{
					enemyParent.SpawnedTimer = 30f;
				}
				if ((int)enemy.CurrentState == 11 && !enemyParent.forceLeave)
				{
					enemy.CurrentState = (EnemyState)2;
				}
			}
			float value = Plugin.Range.Value;
			PlayerAvatar val = Nearest(value);
			if (SemiFunc.IsMultiplayer() && (syncTimer -= Time.deltaTime) <= 0f)
			{
				syncTimer = 2f;
				photonView.RPC("Sedimented_StateRPC", (RpcTarget)1, new object[1] { (int)state });
				sentTargetId = -2;
			}
			int num = (Object.op_Implicit((Object)(object)target) ? target.photonView.ViewID : (-1));
			if (SemiFunc.IsMultiplayer() && num != sentTargetId)
			{
				sentTargetId = num;
				photonView.RPC("Sedimented_TargetRPC", (RpcTarget)1, new object[1] { num });
			}
			quietFor = (Object.op_Implicit((Object)(object)val) ? 0f : (quietFor + Time.deltaTime));
			teleportCooldown -= Time.deltaTime;
			if (Plugin.TeleportToPlayers.Value && state == State.Roam && quietFor > Plugin.TeleportAfter.Value && teleportCooldown <= 0f && TryTeleportNearSomeone())
			{
				teleportCooldown = 30f;
				quietFor = 0f;
				inRangeFor = 0f;
				impulse = true;
			}
			if ((state == State.Roam || state == State.Chase || state == State.Investigate) && enemy.Rigidbody.notMovingTimer > 5f && ((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).magnitude > 0.2f)
			{
				enemy.Rigidbody.Teleport();
				enemy.Rigidbody.notMovingTimer = 0f;
				Plugin.Log.LogInfo((object)"unstuck: body snapped back onto the path");
			}
			inRangeFor = (Object.op_Implicit((Object)(object)val) ? (inRangeFor + Time.deltaTime) : 0f);
			bool flag = Object.op_Implicit((Object)(object)val) && AnyoneSeesHer(value);
			if ((state == State.Roam || state == State.Chase || state == State.Attack) && inRangeFor >= Plugin.ShhGrace.Value && flag)
			{
				shhTimer -= Time.deltaTime;
			}
			if ((state == State.Roam || state == State.Chase) && shhTimer <= 0f && flag)
			{
				Set(State.Shh);
				return;
			}
			switch (state)
			{
			case State.Spawn:
				if (Impulse())
				{
					stateTimer = 1.5f;
				}
				if (!SemiFunc.EnemySpawnIdlePause() && (stateTimer -= Time.deltaTime) <= 0f)
				{
					Set((!SemiFunc.EnemyForceLeave(enemy)) ? State.Roam : State.Leave);
				}
				break;
			case State.Roam:
				if (lookAround > 0f)
				{
					enemy.NavMeshAgent.Stop(0.3f);
					impulse = true;
					break;
				}
				if (SemiFunc.EnemyForceLeave(enemy))
				{
					Set(State.Leave);
					break;
				}
				if (Impulse())
				{
					stateTimer = 14f;
					if (!PickRoamPoint())
					{
						stateTimer = 2f;
					}
				}
				enemy.NavMeshAgent.OverrideAgent(Plugin.WalkSpeed.Value, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
				if (destination != Vector3.zero)
				{
					enemy.NavMeshAgent.SetDestination(destination);
				}
				if (enemy.Rigidbody.notMovingTimer > 1f)
				{
					stateTimer -= Time.deltaTime * 3f;
				}
				if ((stateTimer -= Time.deltaTime) <= 0f || Vector3.Distance(((Component)this).transform.position, destination) < 1.5f)
				{
					impulse = true;
				}
				break;
			case State.Chase:
			{
				if (Impulse())
				{
					lostTimer = 0f;
					searching = false;
					if (Object.op_Implicit((Object)(object)target) && (lastSeen == Vector3.zero || CanSee(target)))
					{
						lastSeen = ((Component)target).transform.position;
					}
				}
				if (!Alive(target))
				{
					target = null;
					Set(State.Roam);
					break;
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position);
				if (CanSee(target))
				{
					lastSeen = ((Component)target).transform.position;
					lostTimer = 0f;
					searching = false;
					unreachableFor = (enemy.NavMeshAgent.CanReach(((Component)target).transform.position, 2.5f) ? 0f : (unreachableFor + Time.deltaTime));
					if (unreachableFor > 6f)
					{
						unreachableFor = 0f;
						target = null;
						Set(State.Roam);
						break;
					}
					hitCooldown -= Time.deltaTime;
					if (num2 < 2.3f)
					{
						enemy.NavMeshAgent.Stop(0.3f);
						if (hitCooldown <= 0f && Plugin.TouchDamage.Value > 0)
						{
							Set(State.Attack);
						}
					}
					else
					{
						enemy.NavMeshAgent.OverrideAgent(Plugin.ChaseSpeed.Value, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
						enemy.NavMeshAgent.SetDestination(((Component)target).transform.position);
					}
					break;
				}
				lostTimer += Time.deltaTime;
				bool flag2 = Vector3.Distance(((Component)this).transform.position, lastSeen) < 1.5f;
				if (flag2 && (target.isCrouching || target.isCrawling) && num2 < 2.7f && hitCooldown <= 0f)
				{
					probing = true;
					Set(State.Attack);
					break;
				}
				if (flag2 && !searching)
				{
					searching = true;
					stateTimer = 4f;
				}
				if (searching && (stateTimer -= Time.deltaTime) <= 0f)
				{
					GiveUp();
					break;
				}
				if (lostTimer > 12f)
				{
					GiveUp();
					break;
				}
				if (searching)
				{
					enemy.NavMeshAgent.Stop(0.3f);
					break;
				}
				enemy.NavMeshAgent.OverrideAgent(Plugin.ChaseSpeed.Value, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
				enemy.NavMeshAgent.SetDestination(lastSeen);
				break;
			}
			case State.Attack:
				if (Impulse())
				{
					stateTimer = 1.3f;
					hitCooldown = 2.2f;
					enemy.NavMeshAgent.Stop(1.3f);
				}
				enemy.NavMeshAgent.Stop(0.3f);
				if (stateTimer > 0.6f && (stateTimer -= Time.deltaTime) <= 0.6f)
				{
					PlayerAvatar val5 = null;
					foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
					{
						if (Alive(item) && Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position) < 2.9f && (!Object.op_Implicit((Object)(object)val5) || (Object)(object)item == (Object)(object)target))
						{
							val5 = item;
						}
					}
					if (Object.op_Implicit((Object)(object)val5))
					{
						val5.playerHealth.HurtOther(Plugin.TouchDamage.Value, ((Component)this).transform.position, false, SemiFunc.EnemyGetIndex(enemy), false);
						target = val5;
						lastSeen = ((Component)val5).transform.position;
						searching = false;
						lostTimer = 0f;
					}
					else if (probing)
					{
						target = null;
					}
					probing = false;
				}
				else
				{
					stateTimer -= Time.deltaTime;
				}
				if (stateTimer <= 0f)
				{
					Set((!Alive(target)) ? State.Roam : State.Chase);
				}
				break;
			case State.Shh:
				if (Impulse())
				{
					stateTimer = 0.6f;
					enemy.NavMeshAgent.Stop(2f);
					roundPlayers.Clear();
					killed.Clear();
					foreach (PlayerAvatar item2 in SemiFunc.PlayerGetList())
					{
						if (Alive(item2) && Vector3.Distance(((Component)item2).transform.position, ((Component)this).transform.position) <= value)
						{
							roundPlayers.Add(item2.photonView.ViewID);
						}
					}
					float num3 = Random.Range(Plugin.BlackoutMin.Value, Plugin.BlackoutMax.Value);
					int[] array = new List<int>(roundPlayers).ToArray();
					FreezeOthers(num3 + stateTimer + 1f);
					ShhRPC(((Component)this).transform.position, num3, array);
					if (SemiFunc.IsMultiplayer())
					{
						photonView.RPC("Sedimented_ShhRPC", (RpcTarget)1, new object[3]
						{
							((Component)this).transform.position,
							num3,
							array
						});
					}
				}
				enemy.NavMeshAgent.Stop(0.5f);
				if ((stateTimer -= Time.deltaTime) <= 0f)
				{
					Set(State.Blackout);
				}
				break;
			case State.Blackout:
				if (Impulse())
				{
					stateTimer = Blackout.Duration;
					blackoutClock = 0f;
				}
				blackoutClock += Time.deltaTime;
				enemy.NavMeshAgent.Stop(0.5f);
				if ((stateTimer -= Time.deltaTime) <= 0f)
				{
					BlackoutEnd();
					Set(State.Resume);
				}
				break;
			case State.Resume:
				if (Impulse())
				{
					stateTimer = 1f;
					shhTimer = Random.Range(Plugin.ShhMin.Value, Plugin.ShhMax.Value);
				}
				enemy.NavMeshAgent.Stop(0.3f);
				if ((stateTimer -= Time.deltaTime) <= 0f)
				{
					Set((!Object.op_Implicit((Object)(object)target) || !(lostTimer < 12f)) ? State.Roam : State.Chase);
				}
				break;
			case State.Stun:
				if (Impulse() && Object.op_Implicit((Object)(object)voice) && Object.op_Implicit((Object)(object)Sounds.Stun))
				{
					voice.PlayOneShot(Sounds.Stun, Plugin.VoiceVolume.Value);
				}
				enemy.NavMeshAgent.Stop(0.3f);
				if (!enemy.IsStunned())
				{
					Set((!Object.op_Implicit((Object)(object)target)) ? State.Roam : State.Chase);
				}
				break;
			case State.Investigate:
				if (Impulse())
				{
					stateTimer = 12f;
					NavMeshHit val4 = default(NavMeshHit);
					if (!NavMesh.SamplePosition(noiseAt, ref val4, 3f, -1))
					{
						Set(State.Roam);
						break;
					}
					destination = ((NavMeshHit)(ref val4)).position;
				}
				if (SemiFunc.EnemyForceLeave(enemy))
				{
					Set(State.Leave);
					break;
				}
				enemy.NavMeshAgent.OverrideAgent(Plugin.ChaseSpeed.Value, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
				enemy.NavMeshAgent.SetDestination(destination);
				if (Vector3.Distance(((Component)this).transform.position, destination) < 1.6f)
				{
					enemy.NavMeshAgent.Stop(0.3f);
					stateTimer = Mathf.Min(stateTimer, 3f);
				}
				if ((stateTimer -= Time.deltaTime) <= 0f)
				{
					Set(State.Roam);
				}
				break;
			case State.Leave:
				if (Impulse())
				{
					stateTimer = 5f;
					leaveFor = 0f;
					LevelPoint val2 = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 30f, 50f, false);
					if (!Object.op_Implicit((Object)(object)val2))
					{
						val2 = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f);
					}
					NavMeshHit val3 = default(NavMeshHit);
					if (!Object.op_Implicit((Object)(object)val2) || !NavMesh.SamplePosition(((Component)val2).transform.position + Random.insideUnitSphere * 3f, ref val3, 5f, -1))
					{
						Set(State.Roam);
						break;
					}
					destination = ((NavMeshHit)(ref val3)).position;
					SemiFunc.EnemyLeaveStart(enemy);
				}
				leaveFor += Time.deltaTime;
				enemy.NavMeshAgent.OverrideAgent(Plugin.WalkSpeed.Value, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
				enemy.NavMeshAgent.SetDestination(destination);
				if (enemy.Rigidbody.notMovingTimer > 2f)
				{
					stateTimer -= Time.deltaTime;
				}
				if (Vector3.Distance(((Component)this).transform.position, destination) < 1f || stateTimer <= 0f || leaveFor > 45f)
				{
					Set(State.Roam);
				}
				break;
			case State.Despawn:
				if (Impulse())
				{
					stateTimer = 0f;
					if (!PickRoamPoint())
					{
						destination = ((Component)this).transform.position;
					}
				}
				if ((int)enemy.CurrentState != 11)
				{
					Set(State.Roam);
					break;
				}
				stateTimer += Time.deltaTime;
				if (stateTimer > 1.5f && (!AnyoneSeesHer(60f) || stateTimer > 25f))
				{
					enemy.EnemyParent.Despawn();
					break;
				}
				enemy.NavMeshAgent.OverrideAgent(Plugin.WalkSpeed.Value, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
				if (destination != Vector3.zero)
				{
					enemy.NavMeshAgent.SetDestination(destination);
				}
				if (Vector3.Distance(((Component)this).transform.position, destination) < 1.5f && !PickRoamPoint())
				{
					destination = ((Component)this).transform.position;
				}
				break;
			case State.Dead:
				break;
			}
		}

		private void FreezeOthers(float seconds)
		{
			//IL_0086: 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 (!Plugin.FreezeOthers.Value || !Object.op_Implicit((Object)(object)EnemyDirector.instance))
			{
				return;
			}
			float num = Plugin.Range.Value * Plugin.LightRadiusFactor.Value;
			int num2 = 0;
			foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
			{
				if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.Enemy) && !((Object)(object)item.Enemy == (Object)(object)enemy) && item.Spawned && !(Vector3.Distance(((Component)item.Enemy).transform.position, ((Component)this).transform.position) > num))
				{
					item.Enemy.Freeze(seconds);
					num2++;
				}
			}
			if (num2 > 0)
			{
				Plugin.Log.LogInfo((object)("blackout froze " + num2 + " other enemies"));
			}
		}

		private void BlackoutEnd()
		{
			LightsRPC();
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("Sedimented_LightsRPC", (RpcTarget)1, Array.Empty<object>());
			}
		}

		private void LightsRPC()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Blackout.End();
			if (Object.op_Implicit((Object)(object)voice) && Object.op_Implicit((Object)(object)Sounds.Clap))
			{
				((Component)voice).transform.localPosition = new Vector3(0f, 1.6f, 0f);
				voice.PlayOneShot(Sounds.Clap, Plugin.VoiceVolume.Value);
			}
		}

		private Vector3 LookPoint()
		{
			//IL_0033: 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_0018: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)headBone))
			{
				return ((Component)this).transform.position + Vector3.up * 2.3f;
			}
			return headBone.position;
		}

		private void CaughtLockLogic()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)caughtPlayer))
			{
				return;
			}
			caughtLockLeft -= Time.deltaTime;
			if (caughtLockLeft <= 0f || caughtPlayer.deadSet)
			{
				if (caughtPlayer.isLocal)
				{
					Blackout.CaughtOver();
				}
				caughtPlayer = null;
				return;
			}
			Vector3 val = LookPoint();
			SemiFunc.PlayerEyesOverride(caughtPlayer, val, 0.1f, ((Component)this).gameObject);
			caughtPlayer.OverridePupilSize(2f, 5, 5f, 0.5f, 5f, 0.5f, 0.1f);
			if (caughtPlayer.isLocal)
			{
				if (Object.op_Implicit((Object)(object)CameraAim.Instance))
				{
					CameraAim.Instance.AimTargetSoftSet(val, 0.2f, 3f, 15f, ((Component)this).gameObject, 100);
				}
				if (Object.op_Implicit((Object)(object)PostProcessing.Instance))
				{
					PostProcessing.Instance.VignetteOverride(new Color(0.8f, 0f, 0f), 0.6f, 1f, 20f, 2f, 0.5f, ((Component)this).gameObject, 999);
				}
				if (Object.op_Implicit((Object)(object)PostProcessing.Instance))
				{
					PostProcessing.Instance.SaturationOverride(-30f, 20f, 2f, 0.5f, ((Component)this).gameObject, 999);
				}
				if (Object.op_Implicit((Object)(object)CameraZoom.Instance))
				{
					CameraZoom.Instance.OverrideZoomSet(40f, 0.2f, 1.5f, 1.5f, ((Component)this).gameObject, 50);
				}
			}
		}

		private void MusicLogic()
		{
			if (!Object.op_Implicit((Object)(object)music))
			{
				return;
			}
			float num = ((state == State.Roam || state == State.Chase || state == State.Attack || state == State.Resume || state == State.Leave) ? (Plugin.MusicVolume.Value * 0.8f) : 0f);
			bool flag = state == State.Shh || state == State.Blackout;
			musicFade = (flag ? 0f : Mathf.MoveTowards(musicFade, num, Time.deltaTime * 0.8f));
			if (musicFade > 0.001f)
			{
				if (!music.isPlaying && Object.op_Implicit((Object)(object)Sounds.Music))
				{
					music.clip = Sounds.Music;
					music.Play();
				}
				music.volume = musicFade;
			}
			else if (music.isPlaying)
			{
				music.Stop();
			}
		}

		private void LateUpdate()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)model) && Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.Rigidbody))
			{
				Vector3 val = Vector3.zero;
				float num = 5f;
				if (Object.op_Implicit((Object)(object)caughtPlayer))
				{
					val = ((Component)caughtPlayer).transform.position - ((Component)this).transform.position;
					num = 14f;
				}
				else if ((state == State.Attack || state == State.Shh || state == State.Blackout || (state == State.Chase && ((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).magnitude < 0.3f)) && Object.op_Implicit((Object)(object)target))
				{
					val = ((Component)target).transform.position - ((Component)this).transform.position;
				}
				else if (lookAround > 0f)
				{
					lookAround -= Time.deltaTime;
					float num2 = Mathf.Sin((2.6f - lookAround) * 2.4f) * 65f;
					val = Quaternion.Euler(0f, num2, 0f) * (lookBase * Vector3.forward);
					num = 4f;
				}
				else if ((Object)(object)enemy.NavMeshAgent != (Object)null && ((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).magnitude > 0.15f)
				{
					val = enemy.NavMeshAgent.AgentVelocity;
				}
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
				{
					Quaternion val2 = Quaternion.LookRotation(val);
					facing = (facingSet ? Quaternion.Slerp(facing, val2, Time.deltaTime * num) : val2);
					facingSet = true;
				}
				if (facingSet)
				{
					model.rotation = facing;
				}
				Transform transform = ((Component)enemy.Rigidbody).transform;
				model.position = transform.position + new Vector3(0f, -1.2f, 0f);
				RaycastHit val3 = default(RaycastHit);
				NavMeshHit val4 = default(NavMeshHit);
				if (Physics.Raycast(transform.position + Vector3.up * 0.5f, Vector3.down, ref val3, 4f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					Vector3 position = model.position;
					position.y = Mathf.Max(((RaycastHit)(ref val3)).point.y + 0.01f, Mathf.Lerp(position.y, ((RaycastHit)(ref val3)).point.y + 0.01f, 0.5f));
					model.position = position;
				}
				else if (NavMesh.SamplePosition(transform.position, ref val4, 3f, -1))
				{
					Vector3 position2 = model.position;
					position2.y = ((NavMeshHit)(ref val4)).position.y;
					model.position = position2;
				}
			}
		}

		private void WalkLogic()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)idle))
			{
				return;
			}
			Vector3 position = ((Component)this).transform.position;
			Vector3 val = position - lastPos;
			float num = ((Vector3)(ref val)).magnitude / Mathf.Max(Time.deltaTime, 0.0001f);
			lastPos = position;
			idle.frozen = state == State.Shh || state == State.Blackout || state == State.Dead;
			idle.stunned = state == State.Stun || (Object.op_Implicit((Object)(object)enemy) && enemy.IsStunned());
			if (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.Rigidbody) && Object.op_Implicit((Object)(object)enemy.Rigidbody.rb))
			{
				Rigidbody rb = enemy.Rigidbody.rb;
				if ((rb.constraints & 0x10) == 0)
				{
					rb.constraints = (RigidbodyConstraints)(rb.constraints | 0x50);
				}
				if (Mathf.Abs(((Component)rb).transform.eulerAngles.x) > 1f || Mathf.Abs(((Component)rb).transform.eulerAngles.z) > 1f)
				{
					((Component)rb).transform.rotation = Quaternion.Euler(0f, ((Component)rb).transform.eulerAngles.y, 0f);
				}
			}
			if (skinMats == null && Object.op_Implicit((Object)(object)model))
			{
				SkinnedMeshRenderer componentInChildren = ((Component)model).GetComponentInChildren<SkinnedMeshRenderer>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					skinMats = ((Renderer)componentInChildren).materials;
				}
			}
			if (skinMats != null && (hurtFlash > 0f || hurtFlashWas))
			{
				hurtFlash = Mathf.Max(0f, hurtFlash - Time.deltaTime * 4f);
				Color val2 = new Color(0.9f, 0.1f, 0.1f) * (hurtFlash * 0.9f);
				Material[] array = skinMats;
				foreach (Material val3 in array)
				{
					if (Object.op_Implicit((Object)(object)val3) && val3.HasProperty("_EmissionColor"))
					{
						val3.SetColor("_EmissionColor", val2);
					}
				}
				hurtFlashWas = hurtFlash > 0f;
			}
			attackClock = ((state == State.Attack) ? (attackClock + Time.deltaTime) : 0f);
			idle.attackTime = ((state == State.Attack) ? attackClock : (-1f));
			idle.walk = Mathf.Clamp01(num / 2.5f);
		}

		private bool Impulse()
		{
			if (!impulse)
			{
				return false;
			}
			impulse = false;
			return true;
		}

		private void GiveUp()
		{
			target = null;
			Set(State.Roam);
			LookRPC();
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("Sedimented_LookRPC", (RpcTarget)1, Array.Empty<object>());
			}
		}

		private void LookRPC()
		{
			//IL_0022: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			lookAround = 2.6f;
			lookBase = (facingSet ? facing : model.rotation);
		}

		private static bool Alive(PlayerAvatar p)
		{
			if (Object.op_Implicit((Object)(object)p) && !p.deadSet)
			{
				return !p.isDisabled;
			}
			return false;
		}

		private PlayerAvatar Nearest(float range)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar result = null;
			float num = range;
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (Alive(item))
				{
					float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)this).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = item;
					}
				}
			}
			return result;
		}

		private bool TryTeleportNearSomeone()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (Alive(item))
				{
					list.Add(item);
				}
			}
			if (list.Count == 0)
			{
				return false;
			}
			PlayerAvatar val = list[Random.Range(0, list.Count)];
			NavMeshHit val3 = default(NavMeshHit);
			for (int i = 0; i < 12; i++)
			{
				LevelPoint val2 = SemiFunc.LevelPointGet(((Component)val).transform.position, 10f, 16f);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					break;
				}
				Vector3 position = ((Component)val2).transform.position;
				if (!NavMesh.SamplePosition(position, ref val3, 2f, -1))
				{
					continue;
				}
				position = ((NavMeshHit)(ref val3)).position;
				bool flag = false;
				foreach (PlayerAvatar item2 in list)
				{
					if (SeesFrom(position + Vector3.up * 2.3f, item2, 60f, enemy.VisionMask))
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					enemy.EnemyTeleported(position);
					if (Object.op_Implicit((Object)(object)voice) && Object.op_Implicit((Object)(object)Sounds.Teleport))
					{
						voice.PlayOneShot(Sounds.Teleport, Plugin.VoiceVolume.Value);
					}
					Plugin.Log.LogInfo((object)("teleported near " + ((Object)val).name));
					return true;
				}
			}
			return false;
		}

		private bool AnyoneSeesHer(float range)
		{
			//IL_0023: 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)
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (Alive(item) && Vector3.Distance(((Component)item).transform.position, ((Component)this).transform.position) <= range && CanSee(item))
				{
					return true;
				}
			}
			return false;
		}

		internal static bool SeesFrom(Vector3 eye, PlayerAvatar p, float maxDistance, LayerMask mask)
		{
			//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_003e: 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_005a: 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_0055: 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_0078: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)p))
			{
				return false;
			}
			Vector3 val = ((Object.op_Implicit((Object)(object)p.PlayerVisionTarget) && Object.op_Implicit((Object)(object)p.PlayerVisionTarget.VisionTransform)) ? p.PlayerVisionTarget.VisionTransform.position : (((Component)p).transform.position + Vector3.up * 1.2f)) - eye;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > maxDistance || magnitude < 0.01f)
			{
				return false;
			}
			int num = Physics.RaycastNonAlloc(eye, val / magnitude, sightHits, magnitude + 0.05f, LayerMask.op_Implicit(mask), (QueryTriggerInteraction)1);
			float num2 = float.MaxValue;
			bool result = true;
			for (int i = 0; i < num; i++)
			{
				Transform transform = ((RaycastHit)(ref sightHits[i])).transform;
				if (Object.op_Implicit((Object)(object)transform) && !((Component)transform).CompareTag("Enemy") && !Object.op_Implicit((Object)(object)((Component)transform).GetComponentInParent<EnemyRigidbody>()))
				{
					bool flag = ((Component)transform).CompareTag("Player") || (Object)(object)((Component)transform).GetComponentInParent<PlayerAvatar>() == (Object)(object)p || Object.op_Implicit((Object)(object)((Component)transform).GetComponentInParent<PlayerTumble>());
					if (((RaycastHit)(ref sightHits[i])).distance < num2)
					{
						num2 = ((RaycastHit)(ref sightHits[i])).distance;
						result = flag;
					}
				}
			}
			return result;
		}

		private bool CanSee(PlayerAvatar p)
		{
			//IL_0034: 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_0018: 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_0027: 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)
			return SeesFrom(Object.op_Implicit((Object)(object)headBone) ? headBone.position : (((Component)this).transform.position + Vector3.up * 2.3f), p, Plugin.Range.Value * 1.6f, enemy.VisionMask);
		}

		private bool PickRoamPoint()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 20f) ?? SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
			NavMeshHit val2 = default(NavMeshHit);
			if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 2f, ref val2, 5f, -1))
			{
				destination = ((NavMeshHit)(ref val2)).position;
				return true;
			}
			destination = Vector3.zero;
			return false;
		}

		private void Set(State s)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && s != state)
			{
				state = s;
				impulse = true;
				stateTimer = 0f;
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("Sedimented_StateRPC", (RpcTarget)1, new object[1] { (int)s });
				}
			}
		}

		internal void ReportMoved()
		{
			int viewID = PlayerAvatar.instance.photonView.ViewID;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				Caught(viewID);
				return;
			}
			photonView.RPC("Sedimented_MovedRPC", (RpcTarget)2, new object[1] { viewID });
		}

		private void Caught(int viewId)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if ((state != State.Blackout && state != State.Shh) || !roundPlayers.Contains(viewId) || killed.Contains(viewId))
			{
				return;
			}
			killed.Add(viewId);
			PlayerAvatar val = null;
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (item.photonView.ViewID == viewId)
				{
					val = item;
				}
			}
			if (Alive(val))
			{
				Vector3 position = ((Component)val).transform.position;
				DetectedRPC(position, viewId);
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("Sedimented_DetectedRPC", (RpcTarget)1, new object[2] { position, viewId });
				}
				((MonoBehaviour)this).StartCoroutine(KillAfter(val, position, Plugin.DetectedDelay.Value));
				Plugin.Log.LogInfo((object)("caught " + ((Object)val).name + " moving during the blackout"));
			}
		}

		private IEnumerator KillAfter(PlayerAvatar victim, Vector3 pos, float delay)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(delay);
			if (Alive(victim))
			{
				victim.playerHealth.HurtOther(Plugin.InstantKill.Value ? 9999 : Plugin.CaughtDamage.Value, pos, false, SemiFunc.EnemyGetIndex(enemy), false);
			}
		}

		[PunRPC]
		public void Sedimented_StateRPC(int s, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(info))
			{
				state = (State)s;
				impulse = true;
			}
		}

		[PunRPC]
		public void Sedimented_ShhRPC(Vector3 at, float duration, int[] players, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(info))
			{
				ShhRPC(at, duration,