Decompiled source of MegaNoodleMobPack v1.2.1

BepInEx/plugins/RFGames-MobPack/RFGames.MobPack.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
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 GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MobPack.Core;
using MobPack.Mobs;
using RFGames.MobPack.NetcodePatcher;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RFGames.MobPack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("MobPack")]
[assembly: AssemblyTitle("RFGames.MobPack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 MobPack
{
	[BepInPlugin("rfgames.mobpack", "Mega Noodle Mob Pack", "1.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static float MasterVolume = 1f;

		internal static bool HighQualityMaterials = true;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			InitNetcodePatcher();
			MasterVolume = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<float>("General", "Volume", 1f, "Volume multiplier for every MobPack sound (0-2).").Value, 0f, 2f);
			HighQualityMaterials = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HighQualityMaterials", true, "Use normal + mask maps on the mobs (borrows a game material that already has those features). Set false if a mob ever looks invisible or wrong: colour + detail textures only.").Value;
			MobSpawns.TestSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "SpawnOnLanding", false, "TESTING: on every landing, spawn one of each enabled mob right away (indoor ones at vents, the Bellwether outside) and boost their spawn weights. Leave false for normal play.").Value;
			MobSpawns.SetTestList(((BaseUnityPlugin)this).Config.Bind<string>("Testing", "SpawnOnLandingMobs", "", "Which mobs SpawnOnLanding applies to (spawned on landing + boosted weights): comma-separated names, e.g. Unlit,Hush,Wearer,Crawlspace,WeepingShepherd,LightsOut. Names: MimicLocker (includes its decoy lockers), Tallyman, PipeEel, Bellwether, Unlit, Hush, Wearer, Crawlspace, WeepingShepherd, LightsOut (spaces/case ignored). Empty = all mobs. Mobs not listed spawn normally by Rarity.").Value);
			try
			{
				MobModels.Load();
				MobAudio.Load();
			}
			catch (Exception ex)
			{
				Log.LogError((object)("MobPack: failed to load embedded models/audio, no mobs registered: " + ex));
				return;
			}
			Reg("Mimic Locker", delegate
			{
				MimicLockerAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Tallyman", delegate
			{
				TallymanAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Pipe Eel", delegate
			{
				PipeEelAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Bellwether", delegate
			{
				BellwetherAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Unlit", delegate
			{
				UnlitAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Hush", delegate
			{
				HushAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Wearer", delegate
			{
				WearerAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Crawlspace", delegate
			{
				CrawlspaceAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Weeping Shepherd", delegate
			{
				ShepherdAI.Register(((BaseUnityPlugin)this).Config);
			});
			Reg("Lights Out", delegate
			{
				LightsOutAI.Register(((BaseUnityPlugin)this).Config);
			});
			MobCleanup.Init();
			MobSpawns.Init();
			Log.LogInfo((object)string.Format("{0} {1} loaded: {2} mob(s) enabled.", "Mega Noodle Mob Pack", "1.2.1", MobSpawns.Entries.Count));
			static void Reg(string name, Action a)
			{
				try
				{
					a();
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"MobPack: {name} failed to register: {arg}");
				}
			}
		}

		private static void InitNetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "rfgames.mobpack";

		public const string PLUGIN_NAME = "Mega Noodle Mob Pack";

		public const string PLUGIN_VERSION = "1.2.1";
	}
}
namespace MobPack.Mobs
{
	internal static class BellwetherSettings
	{
		internal static float Scale = 1.6f;

		internal static float ShipKeepAway = 28f;

		internal static float RingMin = 25f;

		internal static float RingMax = 45f;

		internal static float PullRadius = 90f;

		internal static float LureSeconds = 12f;

		internal static float ContactCooldown = 2f;

		internal static float Speed = 1.6f;

		internal static int ContactDamage = 10;

		internal static int HP = 20;

		internal static bool OverrideChasing = false;

		internal static bool LureEnemies = true;
	}
	public class BellwetherAI : MobAI
	{
		private int iBody;

		private int iNeck;

		private int iHead;

		private int iBell;

		private int iClapper;

		private int iFL;

		private int iFR;

		private int iBL;

		private int iBR;

		private int iFLL;

		private int iFRL;

		private int iBLL;

		private int iBRL;

		private Transform bellMouth;

		private float ringTimer;

		private float walkPhase;

		private float walkAmt;

		private float swing;

		private float swingVel;

		private float contactCd;

		private float groanTimer = 20f;

		private float nodeTimer;

		private float stepSide;

		private float deadT;

		private float ringHold;

		private Vector3 lastPos;

		private Coroutine lure;

		internal static void Register(ConfigFile cfg)
		{
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			if (cfg.Bind<bool>("Bellwether", "Enabled", true, "Add the Bellwether (outdoor): a huge slow ram that rings a bell, pulling nearby enemies toward it.").Value)
			{
				int value = cfg.Bind<int>("Bellwether", "Rarity", 20, "Outdoor spawn weight on each allowed moon. Higher = more common (vanilla outdoor weights are roughly 10-80). 0 = never spawns.").Value;
				string value2 = cfg.Bind<string>("Bellwether", "Moons", "All", "Moons it spawns on: All, or comma-separated planet-name fragments. Prefix ! to exclude. Always outdoors.").Value;
				int maxCount = Mathf.Max(1, cfg.Bind<int>("Bellwether", "MaxCount", 1, "Most Bellwethers alive at once.").Value);
				BellwetherSettings.RingMin = Mathf.Clamp(cfg.Bind<float>("Bellwether", "RingIntervalMin", 25f, "Shortest gap between bell rings (seconds).").Value, 5f, 600f);
				BellwetherSettings.RingMax = Mathf.Clamp(cfg.Bind<float>("Bellwether", "RingIntervalMax", 45f, "Longest gap between bell rings (seconds).").Value, BellwetherSettings.RingMin, 900f);
				BellwetherSettings.LureEnemies = cfg.Bind<bool>("Bellwether", "LureEnemies", true, "Each ring pulls nearby outdoor enemies toward the Bellwether. false = it just rings (and makes noise).").Value;
				BellwetherSettings.PullRadius = Mathf.Clamp(cfg.Bind<float>("Bellwether", "PullRadius", 90f, "Enemies within this many metres are pulled toward it.").Value, 5f, 400f);
				BellwetherSettings.LureSeconds = Mathf.Clamp(cfg.Bind<float>("Bellwether", "LureSeconds", 12f, "How long each ring keeps pulling enemies.").Value, 1f, 120f);
				BellwetherSettings.OverrideChasing = cfg.Bind<bool>("Bellwether", "OverrideChasing", false, "Also pull enemies that are already chasing a player (can save, or doom, someone).").Value;
				BellwetherSettings.ContactDamage = Mathf.Max(0, cfg.Bind<int>("Bellwether", "ContactDamage", 10, "Damage while standing under/against it (once per ContactCooldown). Player health is 100. 0 = harmless.").Value);
				BellwetherSettings.ContactCooldown = Mathf.Clamp(cfg.Bind<float>("Bellwether", "ContactCooldown", 2f, "Seconds between contact damage ticks.").Value, 0.2f, 30f);
				BellwetherSettings.Speed = Mathf.Clamp(cfg.Bind<float>("Bellwether", "Speed", 1.6f, "Walking speed (player walk is ~4.6).").Value, 0.2f, 8f);
				BellwetherSettings.HP = Mathf.Max(1, cfg.Bind<int>("Bellwether", "HP", 20, "Shovel hits to kill it.").Value);
				float num = (BellwetherSettings.Scale = Mathf.Clamp(cfg.Bind<float>("Bellwether", "Scale", 1.6f, "Size multiplier. 1.0 = the 1.0.0 size (~6.4 m tall); 1.6 = ~10.3 m. Its collider, contact-damage area, scan node and bell sound scale with it.").Value, 0.5f, 3f));
				BellwetherSettings.ShipKeepAway = Mathf.Clamp(cfg.Bind<float>("Bellwether", "ShipKeepAway", 28f, "It never wanders closer than this many metres to the ship (so it doesn't walk through it). Scaled with Scale/1.6.").Value * (num / 1.6f), 8f, 120f);
				EnemyType type;
				TerminalNode node;
				TerminalKeyword kw;
				BellwetherAI bellwetherAI = MobFactory.Build<BellwetherAI>(new MobSpec
				{
					id = "Bellwether",
					enemyName = "Bellwether",
					model = "Bellwether",
					keyword = "bellwether",
					outside = true,
					hp = BellwetherSettings.HP,
					maxCount = maxCount,
					power = 1f,
					agentRadius = Mathf.Min(1.3f * num, 2.4f),
					agentHeight = 6f * num,
					speed = BellwetherSettings.Speed,
					angular = 45f,
					accel = 3f,
					hitCenter = new Vector3(0f, 3.4f, 0f) * num,
					hitSize = new Vector3(2.3f, 6.8f, 3.8f) * num,
					scanPos = new Vector3(0f, 5.6f, 0.5f) * num,
					scanHeader = "Bellwether",
					scanSub = "Don't stand under it.",
					audioMax = Mathf.Min(220f * Mathf.Sqrt(num), 400f),
					voiceMax = 90f * Mathf.Sqrt(num),
					bestiary = "BELLWETHER\n\nSigurd's danger level: 15% (by itself)\n\nScientific name: Ovis campanifera gigas\n\nA placid grazing animal the size of a house, carried on four absurdly long legs, with a great iron bell hanging from its neck. Nobody knows whether the bell grows there or whether someone put it on one.\n\nEvery half-minute or so it stops and rings. Everything else that lives outside hears it and comes. The Bellwether itself is almost harmless (just don't stand under it), but the company it keeps is not. Use the ringing to know where the herd is gathering - or stay well away."
				}, out type, out node, out kw);
				type.isOutsideEnemy = true;
				bellwetherAI.rig.model.localScale = Vector3.one * num;
				Enemies.RegisterEnemy(type, value, (LevelTypes)1, (SpawnType)2, node, kw);
				MobSpawns.Entries.Add(new MobSpawns.Entry
				{
					type = type,
					rarity = Mathf.Max(0, value),
					moons = value2,
					outside = true
				});
				Plugin.Log.LogInfo((object)$"Bellwether registered (scale {num}, weight {value}, moons '{value2}', ring {BellwetherSettings.RingMin}-{BellwetherSettings.RingMax}s, pull {BellwetherSettings.PullRadius}m).");
			}
		}

		protected override void OnMobStart()
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			iBody = rig.PartIndex("Body");
			iNeck = rig.PartIndex("Neck");
			iHead = rig.PartIndex("Head");
			iBell = rig.PartIndex("Bell");
			iClapper = rig.PartIndex("Clapper");
			iFL = rig.PartIndex("LegFL");
			iFR = rig.PartIndex("LegFR");
			iBL = rig.PartIndex("LegBL");
			iBR = rig.PartIndex("LegBR");
			iFLL = rig.PartIndex("LegFLLower");
			iFRL = rig.PartIndex("LegFRLower");
			iBLL = rig.PartIndex("LegBLLower");
			iBRL = rig.PartIndex("LegBRLower");
			bellMouth = rig.Anchor("BellMouth");
			((EnemyAI)this).enemyHP = BellwetherSettings.HP;
			lastPos = ((Component)this).transform.position;
			ringTimer = Random.Range(8f, BellwetherSettings.RingMin);
			if (Object.op_Implicit((Object)(object)((EnemyAI)this).agent))
			{
				((EnemyAI)this).agent.speed = BellwetherSettings.Speed;
			}
			if (Object.op_Implicit((Object)(object)((EnemyAI)this).creatureSFX))
			{
				((EnemyAI)this).creatureSFX.priority = 64;
			}
		}

		public override void DoAIInterval()
		{
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: 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_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (((EnemyAI)this).isEnemyDead || removing || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			float aIIntervalTime = ((EnemyAI)this).AIIntervalTime;
			if (((EnemyAI)this).stunNormalizedTimer > 0f)
			{
				if (Object.op_Implicit((Object)(object)((EnemyAI)this).agent))
				{
					((EnemyAI)this).agent.speed = 0f;
				}
				return;
			}
			ringTimer -= aIIntervalTime;
			if (((EnemyAI)this).currentBehaviourStateIndex == 1)
			{
				ringHold -= aIIntervalTime;
				if (ringHold <= 0f)
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
					if (Object.op_Implicit((Object)(object)((EnemyAI)this).agent))
					{
						((EnemyAI)this).agent.speed = BellwetherSettings.Speed;
					}
				}
				return;
			}
			if (ringTimer <= 0f)
			{
				ringTimer = Random.Range(BellwetherSettings.RingMin, BellwetherSettings.RingMax);
				ringHold = 3.5f;
				((EnemyAI)this).SwitchToBehaviourState(1);
				if (Object.op_Implicit((Object)(object)((EnemyAI)this).agent))
				{
					((EnemyAI)this).agent.speed = 0f;
					if (((EnemyAI)this).agent.isOnNavMesh)
					{
						((EnemyAI)this).agent.ResetPath();
					}
				}
				RingClientRpc();
				Vector3 val = (Object.op_Implicit((Object)(object)bellMouth) ? bellMouth.position : (((Component)this).transform.position + Vector3.up * 4f));
				try
				{
					RoundManager.Instance.PlayAudibleNoise(val, Mathf.Min(BellwetherSettings.PullRadius, 60f * BellwetherSettings.Scale), 1f, 0, false, 7771);
				}
				catch
				{
				}
				if (BellwetherSettings.LureEnemies)
				{
					if (lure != null)
					{
						((MonoBehaviour)this).StopCoroutine(lure);
					}
					lure = ((MonoBehaviour)this).StartCoroutine(Lure());
				}
				return;
			}
			groanTimer -= aIIntervalTime;
			if (groanTimer <= 0f)
			{
				groanTimer = Random.Range(18f, 40f);
				GroanClientRpc();
			}
			if (Object.op_Implicit((Object)(object)((EnemyAI)this).agent))
			{
				((EnemyAI)this).agent.speed = BellwetherSettings.Speed;
			}
			Vector3 ship = ShipPos();
			float keep = BellwetherSettings.ShipKeepAway;
			if (FlatDist(((Component)this).transform.position, ship) < keep)
			{
				Vector3 val2 = ((Component)this).transform.position - ship;
				val2.y = 0f;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
				{
					val2 = Vector3.forward;
				}
				NavMeshHit val3 = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)this).transform.position + ((Vector3)(ref val2)).normalized * (keep + 12f - FlatDist(((Component)this).transform.position, ship)), ref val3, 12f, -1))
				{
					((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val3)).position, true);
					nodeTimer = 8f;
					return;
				}
			}
			nodeTimer -= aIIntervalTime;
			if (!(nodeTimer <= 0f) && (!Object.op_Implicit((Object)(object)((EnemyAI)this).agent) || !((EnemyAI)this).agent.isOnNavMesh || ((EnemyAI)this).agent.pathPending || !(((EnemyAI)this).agent.remainingDistance < 2f)))
			{
				return;
			}
			nodeTimer = Random.Range(25f, 45f);
			GameObject[] array = ((((EnemyAI)this).allAINodes != null && ((EnemyAI)this).allAINodes.Length != 0) ? ((EnemyAI)this).allAINodes : GameObject.FindGameObjectsWithTag("OutsideAINode"));
			if (array != null && array.Length != 0)
			{
				List<GameObject> list = array.Where((GameObject n) => (Object)(object)n != (Object)null && FlatDist(n.transform.position, ship) > keep + 4f).ToList();
				List<GameObject> list2 = list.Where(delegate(GameObject n)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_004d: Unknown result type (might be due to invalid IL or missing references)
					float num = Vector3.Distance(n.transform.position, ((Component)this).transform.position);
					return num > 8f && num < 70f && !PathPassesShip(((Component)this).transform.position, n.transform.position, ship, keep * 0.75f);
				}).ToList();
				GameObject val4 = ((list2.Count > 0) ? list2[Random.Range(0, list2.Count)] : ((list.Count > 0) ? list[Random.Range(0, list.Count)] : null));
				if ((Object)(object)val4 != (Object)null)
				{
					((EnemyAI)this).SetDestinationToPosition(val4.transform.position, true);
				}
			}
		}

		private static Vector3 ShipPos()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return new Vector3(9999f, 0f, 9999f);
			}
			if ((Object)(object)instance.shipBounds != (Object)null)
			{
				Bounds bounds = instance.shipBounds.bounds;
				return ((Bounds)(ref bounds)).center;
			}
			if (!((Object)(object)instance.elevatorTransform != (Object)null))
			{
				return new Vector3(9999f, 0f, 9999f);
			}
			return instance.elevatorTransform.position;
		}

		private static float FlatDist(Vector3 a, Vector3 b)
		{
			//IL_0018: 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)
			a.y = 0f;
			b.y = 0f;
			return Vector3.Distance(a, b);
		}

		private static bool PathPassesShip(Vector3 a, Vector3 b, Vector3 ship, float r)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003d: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0065: Unknown result type (might be due to invalid IL or missing references)
			a.y = (b.y = (ship.y = 0f));
			Vector3 val = b - a;
			float num = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? Mathf.Clamp01(Vector3.Dot(ship - a, val) / ((Vector3)(ref val)).sqrMagnitude) : 0f);
			return Vector3.Distance(a + val * num, ship) < r;
		}

		private IEnumerator Lure()
		{
			float until = Time.time + BellwetherSettings.LureSeconds;
			bool logged = false;
			NavMeshHit val2 = default(NavMeshHit);
			while (Time.time < until && !((EnemyAI)this).isEnemyDead && !removing)
			{
				int num = 0;
				List<EnemyAI> list = (((Object)(object)RoundManager.Instance != (Object)null) ? RoundManager.Instance.SpawnedEnemies : null);
				if (list != null)
				{
					foreach (EnemyAI item in list.ToList())
					{
						if ((Object)(object)item == (Object)null || (Object)(object)item == (Object)(object)this || item is BellwetherAI || item.isEnemyDead || !((NetworkBehaviour)item).IsOwner || !item.isOutside || (Object)(object)item.agent == (Object)null || !((Behaviour)item.agent).enabled || !item.agent.isOnNavMesh || item.inSpecialAnimation || Vector3.Distance(((Component)item).transform.position, ((Component)this).transform.position) > BellwetherSettings.PullRadius || (!BellwetherSettings.OverrideChasing && item.movingTowardsTargetPlayer && (Object)(object)item.targetPlayer != (Object)null))
						{
							continue;
						}
						try
						{
							if (item.currentSearch != null && item.currentSearch.inProgress)
							{
								item.StopSearch(item.currentSearch, true);
							}
							if (BellwetherSettings.OverrideChasing)
							{
								item.movingTowardsTargetPlayer = false;
							}
							Vector3 val = ((Component)this).transform.position + Quaternion.Euler(0f, (float)(item.thisEnemyIndex * 47 % 360), 0f) * Vector3.forward * 6f;
							if (NavMesh.SamplePosition(val, ref val2, 6f, item.agent.areaMask))
							{
								val = ((NavMeshHit)(ref val2)).position;
							}
							item.SetDestinationToPosition(val, false);
							num++;
						}
						catch
						{
						}
					}
				}
				if (!logged)
				{
					logged = true;
					Plugin.Log.LogInfo((object)$"[MobPack] Bellwether rang: pulling {num} enemies for {BellwetherSettings.LureSeconds}s.");
				}
				yield return (object)new WaitForSeconds(0.5f);
			}
			lure = null;
		}

		[ClientRpc]
		private void RingClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3659756068u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3659756068u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					float scale = BellwetherSettings.Scale;
					swingVel += 260f;
					Play("bell_ring", Mathf.Min(1.3f * Mathf.Sqrt(scale), 2f), Random.Range(0.97f, 1.03f) / Mathf.Pow(scale, 0.3f));
					MobAI.Shake(((Component)this).transform.position, 8f * scale, 30f * scale);
				}
			}
		}

		[ClientRpc]
		private void GroanClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3019314371u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3019314371u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Play("bell_groan", 1f, Random.Range(0.85f, 1.05f), voice: true);
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_004a: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!((EnemyAI)this).isEnemyDead && !(contactCd > 0f) && BellwetherSettings.ContactDamage > 0)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (!((Object)(object)val == (Object)null))
				{
					contactCd = BellwetherSettings.ContactCooldown;
					Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
					val2.y = 0f;
					val.DamagePlayer(BellwetherSettings.ContactDamage, true, true, (CauseOfDeath)8, 0, false, ((Vector3)(ref val2)).normalized * 6f);
					val.externalForceAutoFade += ((Vector3)(ref val2)).normalized * 6f;
					Play("bell_step", 1f, 0.8f);
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (((EnemyAI)this).isEnemyDead)
			{
				return;
			}
			Play("bell_hurt", 1f, Random.Range(0.9f, 1.1f), voice: true);
			swingVel += 60f;
			if (((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).enemyHP = ((EnemyAI)this).enemyHP - force;
				if (((EnemyAI)this).enemyHP <= 0)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			if (lure != null)
			{
				((MonoBehaviour)this).StopCoroutine(lure);
				lure = null;
			}
			base.KillEnemy(destroy);
			Play("bell_hurt", 1.3f, 0.6f / Mathf.Pow(BellwetherSettings.Scale, 0.2f), voice: true);
			Play("bell_small", 1f, 0.8f);
			if (Object.op_Implicit((Object)(object)scan))
			{
				scan.subText = "Dead.";
			}
		}

		protected override void MobUpdate(float dt)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: 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)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: 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_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			if (contactCd > 0f)
			{
				contactCd -= dt;
			}
			swingVel += ((0f - swing) * 9f - swingVel * 0.9f) * dt;
			swing += swingVel * dt;
			swing = Mathf.Clamp(swing, -45f, 45f);
			rig.Pose(iBell, new Vector3(swing, 0f, swing * 0.15f));
			rig.Pose(iClapper, new Vector3((0f - swing) * 0.6f, 0f, 0f));
			if (((EnemyAI)this).isEnemyDead)
			{
				deadT = Mathf.MoveTowards(deadT, 1f, dt * 0.5f);
				float num = deadT * deadT * (3f - 2f * deadT);
				rig.Pose(iBody, new Vector3(0f, 0f, 18f * num), new Vector3(0f, -3.9f * num, 0f));
				(int, int, float)[] array = new(int, int, float)[4]
				{
					(iFL, iFLL, -1f),
					(iFR, iFRL, 1f),
					(iBL, iBLL, -1f),
					(iBR, iBRL, 1f)
				};
				for (int i = 0; i < array.Length; i++)
				{
					var (i2, i3, num2) = array[i];
					rig.Pose(i2, new Vector3(-60f * num, 0f, num2 * 35f * num), new Vector3(0f, -3.6f * num, 0f));
					rig.Pose(i3, new Vector3(120f * num, 0f, 0f));
				}
				rig.Pose(iNeck, new Vector3(30f * num, 0f, 0f));
				rig.Pose(iHead, new Vector3(20f * num, 0f, 15f * num));
				return;
			}
			Vector3 val = ((Component)this).transform.position - lastPos;
			lastPos = ((Component)this).transform.position;
			float num3;
			if (!(dt > 0f))
			{
				num3 = 0f;
			}
			else
			{
				Vector3 val2 = new Vector3(val.x, 0f, val.z);
				num3 = ((Vector3)(ref val2)).magnitude / dt;
			}
			float num4 = num3;
			walkAmt = Mathf.MoveTowards(walkAmt, (num4 > 0.15f) ? 1f : 0f, dt * 1.5f);
			walkPhase += dt * Mathf.Clamp(num4, 0f, 5f) * 0.45f / BellwetherSettings.Scale;
			float num5 = Mathf.Sin(walkPhase * MathF.PI) * walkAmt;
			float num6 = Mathf.Cos(walkPhase * MathF.PI) * walkAmt;
			if (walkAmt > 0.4f && Mathf.Sign(num5) != stepSide)
			{
				stepSide = Mathf.Sign(num5);
				Play("bell_step", Mathf.Min(0.9f * Mathf.Sqrt(BellwetherSettings.Scale), 1.4f), Random.Range(0.85f, 1.05f) / Mathf.Pow(BellwetherSettings.Scale, 0.3f));
				MobAI.Shake(((Component)this).transform.position, 0f, 14f * BellwetherSettings.Scale);
				swingVel += 10f * stepSide;
			}
			rig.Pose(iFL, new Vector3(-16f * num5, 0f, 0f));
			rig.Pose(iBR, new Vector3(-16f * num5, 0f, 0f));
			rig.Pose(iFR, new Vector3(16f * num5, 0f, 0f));
			rig.Pose(iBL, new Vector3(16f * num5, 0f, 0f));
			rig.Pose(iFLL, new Vector3(Mathf.Max(0f, num6) * 22f, 0f, 0f));
			rig.Pose(iBRL, new Vector3(Mathf.Max(0f, num6) * 22f, 0f, 0f));
			rig.Pose(iFRL, new Vector3(Mathf.Max(0f, 0f - num6) * 22f, 0f, 0f));
			rig.Pose(iBLL, new Vector3(Mathf.Max(0f, 0f - num6) * 22f, 0f, 0f));
			rig.Pose(iBody, new Vector3(0f, 0f, num5 * 2.5f), new Vector3(0f, Mathf.Abs(num6) * 0.12f - 0.06f * walkAmt + Mathf.Sin(Time.time * 0.9f) * 0.03f * (1f - walkAmt), 0f));
			bool flag = ((EnemyAI)this).currentBehaviourStateIndex == 1;
			float num7 = Mathf.Sin(Time.time * 0.35f) * (1f - walkAmt);
			rig.Pose(iNeck, new Vector3((flag ? (-12f) : (6f * num7)) + 2f * num6, 0f, 0f));
			rig.Pose(iHead, new Vector3(flag ? (-14f) : (4f * num7), Mathf.Sin(Time.time * 0.21f) * 10f, 0f));
			if (flag && ((NetworkBehaviour)this).IsOwner)
			{
				Transform transform = ((Component)this).transform;
				transform.rotation *= Quaternion.Euler(0f, 6f * dt, 0f);
			}
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3659756068u, new RpcReceiveHandler(__rpc_handler_3659756068), "RingClientRpc");
			((NetworkBehaviour)this).__registerRpc(3019314371u, new RpcReceiveHandler(__rpc_handler_3019314371), "GroanClientRpc");
			base.__initializeRpcs();
		}

		private static void __rpc_handler_3659756068(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BellwetherAI)(object)target).RingClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3019314371(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BellwetherAI)(object)target).GroanClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "BellwetherAI";
		}
	}
	internal static class CrawlSettings
	{
		internal static float GrabRange = 2.6f;

		internal static float DragSeconds = 2f;

		internal static float MaxHold = 7f;

		internal static float Cooldown = 18f;

		internal static float DamagePerSecond = 10f;

		internal static int StrugglePresses = 14;

		internal static int HP = 3;

		internal static bool UnderDoors = true;
	}
	public class CrawlspaceAI : MobAI
	{
		private int iArm;

		private int iFore;

		private int iHand;

		private int iThumb;

		private int[] iFing;

		private Transform grip;

		private Transform hitbox;

		private Transform scanT;

		private float reachLen = 2.4f;

		private float stateT;

		private float cd;

		private float scratchCd;

		private float struggleTip;

		private float dmgAcc;

		private float holdT;

		private float ext;

		private float swayT;

		private int presses;

		private int targetId = -1;

		private Vector3 grabStart;

		private Vector3 dragEnd;

		private int lastState = -1;

		internal static void Register(ConfigFile cfg)
		{
			//IL_0276: 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_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			if (cfg.Bind<bool>("Crawlspace", "Enabled", true, "Add Crawlspace (indoor): hands from the walls and under doors that grab your ankle and drag you.").Value)
			{
				int value = cfg.Bind<int>("Crawlspace", "Rarity", 30, "Indoor spawn weight on each allowed moon. 0 = never spawns.").Value;
				string value2 = cfg.Bind<string>("Crawlspace", "Moons", "All", "Moons it spawns on: All, or comma-separated planet-name fragments. Prefix ! to exclude. Never the Company.").Value;
				int maxCount = Mathf.Max(1, cfg.Bind<int>("Crawlspace", "MaxCount", 2, "Most Crawlspace hands at once.").Value);
				CrawlSettings.GrabRange = Mathf.Clamp(cfg.Bind<float>("Crawlspace", "GrabRange", 2.6f, "How far from the wall the hand can grab (metres).").Value, 1f, 4f);
				CrawlSettings.DragSeconds = Mathf.Clamp(cfg.Bind<float>("Crawlspace", "DragSeconds", 2f, "Time to drag a grabbed player to the wall.").Value, 0.3f, 8f);
				CrawlSettings.DamagePerSecond = Mathf.Clamp(cfg.Bind<float>("Crawlspace", "DamagePerSecond", 10f, "Damage per second while held. Player health is 100.").Value, 0f, 100f);
				CrawlSettings.MaxHold = Mathf.Clamp(cfg.Bind<float>("Crawlspace", "MaxHoldSeconds", 7f, "It lets go by itself after this long (with the default damage a full-health player survives a hold).").Value, 1f, 60f);
				CrawlSettings.StrugglePresses = Mathf.Max(0, cfg.Bind<int>("Crawlspace", "StrugglePresses", 14, "Presses of Jump to struggle free. 0 = struggling disabled (only a teammate can free you).").Value);
				CrawlSettings.Cooldown = Mathf.Clamp(cfg.Bind<float>("Crawlspace", "Cooldown", 18f, "Seconds between grabs.").Value, 2f, 300f);
				CrawlSettings.UnderDoors = cfg.Bind<bool>("Crawlspace", "UnderDoors", true, "Also reach out from under doors.").Value;
				CrawlSettings.HP = Mathf.Max(1, cfg.Bind<int>("Crawlspace", "HP", 3, "Hits to kill the hand (any hit frees a grabbed player).").Value);
				MobFactory.Build<CrawlspaceAI>(new MobSpec
				{
					id = "Crawlspace",
					enemyName = "Crawlspace",
					model = "CrawlHand",
					keyword = "crawlspace",
					outside = false,
					hp = CrawlSettings.HP,
					maxCount = maxCount,
					power = 1f,
					agentRadius = 0.2f,
					agentHeight = 0.5f,
					speed = 0f,
					angular = 0f,
					accel = 8f,
					hitCenter = Vector3.zero,
					hitSize = new Vector3(0.7f, 0.6f, 0.7f),
					scanPos = Vector3.zero,
					scanHeader = "Crawlspace",
					scanSub = "Hit it to let go!",
					audioMax = 25f,
					voiceMax = 20f,
					bestiary = "CRAWLSPACE\n\nSigurd's danger level: 45%\n\nScientific name: Manus parietalis\n\nSomething lives inside the walls of the facilities. We have only ever seen its hands: pale, with fingers far too long.\n\nYou will hear it first - scratching, very close, low down. Move away from the wall. If it gets your ankle it will drag you into the corner and hold you there. Struggle (mash jump), or have a teammate hit the hand."
				}, out var type, out var node, out var kw);
				Enemies.RegisterEnemy(type, value, (LevelTypes)1, (SpawnType)0, node, kw);
				MobSpawns.Entries.Add(new MobSpawns.Entry
				{
					type = type,
					rarity = Mathf.Max(0, value),
					moons = value2,
					outside = false
				});
				Plugin.Log.LogInfo((object)$"Crawlspace registered (weight {value}, moons '{value2}', grab {CrawlSettings.GrabRange}m, struggle {CrawlSettings.StrugglePresses}).");
			}
		}

		protected override void OnMobStart()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			iArm = rig.PartIndex("Arm");
			iFore = rig.PartIndex("Fore");
			iHand = rig.PartIndex("Hand");
			iThumb = rig.PartIndex("Thumb");
			iFing = (from i in Enumerable.Range(0, 4)
				select rig.PartIndex("Finger" + i)).ToArray();
			grip = rig.Anchor("Grip");
			hitbox = ((Component)this).transform.Find("Hitbox");
			scanT = (((Object)(object)scan != (Object)null) ? ((Component)scan).transform : null);
			if ((Object)(object)grip != (Object)null)
			{
				reachLen = Mathf.Max(1f, rig.model.InverseTransformPoint(grip.position).z);
			}
			((EnemyAI)this).enemyHP = CrawlSettings.HP;
			cd = Random.Range(4f, 10f);
			DetachAgent();
			rig.SetVisible(on: false);
		}

		public override void DoAIInterval()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_023a: 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_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: 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_0289: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			DetachAgent();
			if (((EnemyAI)this).isEnemyDead || removing || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			float aIIntervalTime = ((EnemyAI)this).AIIntervalTime;
			stateT += aIIntervalTime;
			if (cd > 0f)
			{
				cd -= aIIntervalTime;
			}
			int currentBehaviourStateIndex = ((EnemyAI)this).currentBehaviourStateIndex;
			PlayerControllerB val = Horror.ById(targetId);
			switch (currentBehaviourStateIndex)
			{
			case 0:
			{
				if (cd > 0f)
				{
					break;
				}
				PlayerControllerB val2 = Horror.Nearest(((Component)this).transform.position, 200f, (PlayerControllerB x) => x.isInsideFactory && !MobCleanup.Mobs.OfType<CrawlspaceAI>().Any((CrawlspaceAI o) => (Object)(object)o != (Object)(object)this && o.targetId == Horror.IdOf(x)));
				Vector3 spot;
				float yaw;
				if ((Object)(object)val2 == (Object)null)
				{
					cd = 3f;
				}
				else if (FindSpot(val2, out spot, out yaw))
				{
					targetId = Horror.IdOf(val2);
					((Component)this).transform.position = spot;
					((Component)this).transform.rotation = Quaternion.Euler(0f, yaw, 0f);
					MoveClientRpc(spot, yaw, targetId);
					((EnemyAI)this).SwitchToBehaviourState(1);
					stateT = 0f;
				}
				else
				{
					cd = 2f;
				}
				break;
			}
			case 1:
			{
				if ((Object)(object)val == (Object)null || !Horror.Alive(val) || !val.isInsideFactory)
				{
					ResetHand(4f);
					break;
				}
				float num = FlatDist(((Component)val).transform.position, ((Component)this).transform.position);
				if (stateT > 2.5f && num < CrawlSettings.GrabRange + 0.3f && Mathf.Abs(((Component)val).transform.position.y - ((Component)this).transform.position.y) < 1.3f && (Object)(object)val.inAnimationWithEnemy == (Object)null && !val.inSpecialInteractAnimation)
				{
					((EnemyAI)this).SwitchToBehaviourState(2);
					stateT = 0f;
					ReachClientRpc();
				}
				else if (stateT > 12f || num > 14f)
				{
					ResetHand(5f);
				}
				break;
			}
			case 2:
				if (!(stateT < 0.35f))
				{
					if ((Object)(object)val != (Object)null && Horror.Alive(val) && FlatDist(((Component)val).transform.position, ((Component)this).transform.position) < CrawlSettings.GrabRange + 0.5f && (Object)(object)val.inAnimationWithEnemy == (Object)null)
					{
						((EnemyAI)this).SwitchToBehaviourState(3);
						stateT = 0f;
						GrabClientRpc(targetId, ((Component)val).transform.position);
					}
					else
					{
						MissClientRpc();
						ResetHand(6f);
					}
				}
				break;
			case 3:
				if ((Object)(object)val == (Object)null || !Horror.Alive(val) || stateT > CrawlSettings.MaxHold + CrawlSettings.DragSeconds || Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) > 6f)
				{
					ReleaseClientRpc();
					ResetHand(CrawlSettings.Cooldown);
				}
				break;
			}
		}

		private void ResetHand(float cooldown)
		{
			cd = cooldown;
			targetId = -1;
			((EnemyAI)this).SwitchToBehaviourState(0);
			stateT = 0f;
			HideClientRpc();
		}

		private static float FlatDist(Vector3 a, Vector3 b)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			a.y = (b.y = 0f);
			return Vector3.Distance(a, b);
		}

		private bool FindSpot(PlayerControllerB p, out Vector3 spot, out float yaw)
		{
			//IL_000e: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_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_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: 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_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: 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_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			spot = default(Vector3);
			yaw = 0f;
			Vector3 val = ((Component)p).transform.position + Vector3.up * 0.2f;
			Quaternion val5;
			if (CrawlSettings.UnderDoors && Random.value < 0.4f)
			{
				DoorLock val2 = (from dl in Object.FindObjectsOfType<DoorLock>()
					where (Object)(object)dl != (Object)null && Vector3.Distance(((Component)dl).transform.position, ((Component)p).transform.position) < 7f
					orderby Vector3.Distance(((Component)dl).transform.position, ((Component)p).transform.position)
					select dl).FirstOrDefault();
				RaycastHit val3 = default(RaycastHit);
				if ((Object)(object)val2 != (Object)null && Physics.Raycast(((Component)val2).transform.position + Vector3.up * 1f, Vector3.down, ref val3, 3f, Horror.SightMask, (QueryTriggerInteraction)1))
				{
					Vector3 val4 = ((Component)p).transform.position - ((Component)val2).transform.position;
					val4.y = 0f;
					if (((Vector3)(ref val4)).sqrMagnitude > 0.25f)
					{
						spot = new Vector3(((Component)val2).transform.position.x, ((RaycastHit)(ref val3)).point.y + 0.06f, ((Component)val2).transform.position.z);
						val5 = Quaternion.LookRotation(val4);
						yaw = ((Quaternion)(ref val5)).eulerAngles.y;
						return true;
					}
				}
			}
			int num = Random.Range(0, 16);
			RaycastHit val7 = default(RaycastHit);
			RaycastHit val8 = default(RaycastHit);
			for (int num2 = 0; num2 < 16; num2++)
			{
				Vector3 val6 = Quaternion.Euler(0f, (float)(num + num2) * 22.5f, 0f) * Vector3.forward;
				if (Physics.Raycast(val, val6, ref val7, 4f, Horror.SightMask, (QueryTriggerInteraction)1) && !(((RaycastHit)(ref val7)).distance < 1.2f) && !(Mathf.Abs(((RaycastHit)(ref val7)).normal.y) > 0.3f))
				{
					Vector3 normal = ((RaycastHit)(ref val7)).normal;
					normal.y = 0f;
					((Vector3)(ref normal)).Normalize();
					if (Physics.Raycast(((RaycastHit)(ref val7)).point + normal * 0.3f + Vector3.up * 0.5f, Vector3.down, ref val8, 2f, Horror.SightMask, (QueryTriggerInteraction)1))
					{
						spot = new Vector3(((RaycastHit)(ref val7)).point.x, ((RaycastHit)(ref val8)).point.y + 0.12f, ((RaycastHit)(ref val7)).point.z) + normal * 0.02f;
						val5 = Quaternion.LookRotation(normal);
						yaw = ((Quaternion)(ref val5)).eulerAngles.y;
						return true;
					}
				}
			}
			return false;
		}

		[ClientRpc]
		private void MoveClientRpc(Vector3 at, float yaw, int target)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1380515435u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref at);
					((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref yaw, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val, target);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1380515435u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					((Component)this).transform.position = at;
					((Component)this).transform.rotation = Quaternion.Euler(0f, yaw, 0f);
					((EnemyAI)this).serverPosition = at;
					((EnemyAI)this).targetYRotation = yaw;
					targetId = target;
					ext = 0f;
					scratchCd = 0f;
					rig.SetVisible(on: true);
				}
			}
		}

		[ClientRpc]
		private void ReachClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1159591857u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1159591857u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Play("crawl_knock", 0.9f);
				}
			}
		}

		[ClientRpc]
		private void MissClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(4179797884u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 4179797884u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Play("crawl_scratch0", 0.8f, 1.3f);
				}
			}
		}

		[ClientRpc]
		private void HideClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2506998788u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2506998788u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				rig.SetVisible(on: false);
				if ((Object)(object)victim != (Object)null)
				{
					FreeVictimLocal();
				}
			}
		}

		[ClientRpc]
		private void GrabClientRpc(int id, Vector3 startPos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3485283754u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, id);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref startPos);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3485283754u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			PlayerControllerB val3 = Horror.ById(id);
			if ((Object)(object)val3 == (Object)null)
			{
				return;
			}
			targetId = id;
			grabStart = startPos;
			holdT = 0f;
			presses = 0;
			dmgAcc = 0f;
			struggleTip = 0f;
			Play("crawl_grab", 1.3f);
			Play("crawl_drag", 1f, 1f, voice: true);
			LockVictim(val3);
			Vector3 val4 = ((Component)this).transform.position + ((Component)this).transform.forward * 0.55f;
			val4.y = startPos.y;
			dragEnd = val4;
			NavMeshHit val5 = default(NavMeshHit);
			if (NavMesh.SamplePosition(startPos, ref val5, 1.5f, -1))
			{
				NavMeshHit val6 = default(NavMeshHit);
				NavMeshHit val7 = default(NavMeshHit);
				if (NavMesh.Raycast(((NavMeshHit)(ref val5)).position, val4, ref val6, -1))
				{
					dragEnd = ((NavMeshHit)(ref val6)).position;
				}
				else if (NavMesh.SamplePosition(val4, ref val7, 0.8f, -1))
				{
					dragEnd = ((NavMeshHit)(ref val7)).position;
				}
				else
				{
					dragEnd = startPos;
				}
			}
			else
			{
				dragEnd = startPos;
			}
			if (!MobAI.IsLocal(val3))
			{
				return;
			}
			MobAI.Shake(((Component)this).transform.position, 5f, 5f);
			try
			{
				HUDManager.Instance.DisplayTip("Something has your ankle!", (CrawlSettings.StrugglePresses > 0) ? "Mash [Jump] to struggle free, or get a teammate to hit it." : "Get a teammate to hit it!", true, false, "LC_Tip1");
			}
			catch
			{
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void StruggleFreeServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(834787675u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 834787675u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (((EnemyAI)this).currentBehaviourStateIndex == 3)
				{
					ReleaseClientRpc();
					ResetHand(CrawlSettings.Cooldown);
				}
			}
		}

		[ClientRpc]
		private void ReleaseClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1606869797u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1606869797u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				Play("crawl_release", 1.1f, Random.Range(0.95f, 1.1f), voice: true);
				PlayerControllerB val3 = victim;
				if ((Object)(object)val3 != (Object)null && MobAI.IsLocal(val3))
				{
					Horror.SafeRelease(val3, grabStart);
				}
				FreeVictimLocal();
				rig.SetVisible(on: false);
			}
		}

		protected override void OnVictimFreed(PlayerControllerB p)
		{
			if (MobAI.IsLocal(p))
			{
				p.disableMoveInput = false;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (((EnemyAI)this).isEnemyDead)
			{
				return;
			}
			Play("crawl_release", 0.8f, 1.3f, voice: true);
			if (((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).enemyHP = ((EnemyAI)this).enemyHP - force;
				if (((EnemyAI)this).currentBehaviourStateIndex == 3)
				{
					ReleaseClientRpc();
					ResetHand(CrawlSettings.Cooldown);
				}
				if (((EnemyAI)this).enemyHP <= 0)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)victim != (Object)null && MobAI.IsLocal(victim))
			{
				Horror.SafeRelease(victim, grabStart);
			}
			base.KillEnemy(destroy);
			Play("crawl_release", 1.2f, 0.7f, voice: true);
			rig.SetVisible(on: false);
			if (Object.op_Implicit((Object)(object)scan))
			{
				scan.subText = "Dead.";
			}
		}

		protected override void MobUpdate(float dt)
		{
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			if (((EnemyAI)this).isEnemyDead)
			{
				return;
			}
			int currentBehaviourStateIndex = ((EnemyAI)this).currentBehaviourStateIndex;
			if (currentBehaviourStateIndex != lastState)
			{
				lastState = currentBehaviourStateIndex;
			}
			_ = MobAI.LocalPlayer;
			if (currentBehaviourStateIndex == 1)
			{
				scratchCd -= dt;
				if (scratchCd <= 0f)
				{
					scratchCd = Random.Range(1.6f, 3.2f);
					Play("crawl_scratch" + Random.Range(0, 3), 1f, Random.Range(0.85f, 1.1f));
				}
			}
			float num = currentBehaviourStateIndex switch
			{
				3 => reachLen, 
				2 => reachLen, 
				1 => 0.35f, 
				_ => 0f, 
			};
			Vector3 val = Vector3.forward * reachLen;
			PlayerControllerB val2 = (((Object)(object)victim != (Object)null) ? victim : ((currentBehaviourStateIndex == 2) ? Horror.ById(targetId) : null));
			Vector3 force;
			if ((Object)(object)val2 != (Object)null && currentBehaviourStateIndex >= 2)
			{
				Vector3 val3 = ((Component)val2).transform.position + Vector3.up * 0.15f;
				val = ((Component)this).transform.InverseTransformPoint(val3);
				force = new Vector3(val.x, 0f, val.z);
				num = Mathf.Clamp(((Vector3)(ref force)).magnitude, 0.3f, reachLen);
			}
			ext = Mathf.MoveTowards(ext, num, dt * ((currentBehaviourStateIndex == 2) ? 14f : 3f));
			float num2 = Mathf.Clamp(Mathf.Atan2(val.x, Mathf.Max(0.05f, val.z)) * 57.29578f, -70f, 70f);
			rig.model.localRotation = Quaternion.Euler(0f, num2, 0f);
			rig.model.localPosition = rig.model.localRotation * new Vector3(0f, 0f, ext - reachLen);
			swayT += dt;
			float num3 = currentBehaviourStateIndex switch
			{
				1 => 25f + Mathf.Sin(swayT * 9f) * 25f, 
				3 => 65f, 
				_ => 10f + Mathf.Sin(swayT * 3f) * 6f, 
			};
			for (int i = 0; i < iFing.Length; i++)
			{
				rig.Pose(iFing[i], new Vector3(num3 + Mathf.Sin(swayT * 7f + (float)i) * ((currentBehaviourStateIndex == 1) ? 15f : 3f), 0f, 0f));
			}
			rig.Pose(iThumb, new Vector3(0f, (currentBehaviourStateIndex == 3) ? 55f : 15f, 0f));
			rig.Pose(iArm, new Vector3(Mathf.Sin(swayT * 1.3f) * 2f, 0f, 0f));
			rig.Pose(iFore, new Vector3(Mathf.Sin(swayT * 1.7f) * 3f, 0f, 0f));
			rig.Pose(iHand, new Vector3((currentBehaviourStateIndex == 1) ? (-15f) : (-5f), 0f, 0f));
			if (Object.op_Implicit((Object)(object)hitbox) && Object.op_Implicit((Object)(object)grip))
			{
				hitbox.position = grip.position;
			}
			if (Object.op_Implicit((Object)(object)scanT) && Object.op_Implicit((Object)(object)grip))
			{
				scanT.position = grip.position + Vector3.up * 0.3f;
			}
			if (currentBehaviourStateIndex != 3 || !((Object)(object)victim != (Object)null) || !MobAI.IsLocal(victim))
			{
				return;
			}
			holdT += dt;
			float num4 = Mathf.Clamp01(holdT / CrawlSettings.DragSeconds);
			num4 = num4 * num4 * (3f - 2f * num4);
			MobAI.PutLocal(victim, Vector3.Lerp(grabStart, dragEnd, num4));
			dmgAcc += CrawlSettings.DamagePerSecond * dt;
			if (dmgAcc >= 5f)
			{
				int num5 = (int)dmgAcc;
				dmgAcc -= num5;
				PlayerControllerB p = victim;
				force = default(Vector3);
				MobAI.HurtLocal(p, num5, canKill: true, (CauseOfDeath)8, force);
			}
			if (CrawlSettings.StrugglePresses <= 0)
			{
				return;
			}
			bool flag = false;
			try
			{
				InputAction val4 = (((Object)(object)IngamePlayerSettings.Instance != (Object)null && (Object)(object)IngamePlayerSettings.Instance.playerInput != (Object)null) ? IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false) : null);
				flag = ((val4 != null) ? val4.WasPressedThisFrame() : (Keyboard.current != null && ((ButtonControl)Keyboard.current.spaceKey).wasPressedThisFrame));
			}
			catch
			{
			}
			if (flag)
			{
				presses++;
				MobAI.Shake(((Component)this).transform.position, 0f, 5f);
				if (presses == CrawlSettings.StrugglePresses)
				{
					StruggleFreeServerRpc();
				}
			}
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1380515435u, new RpcReceiveHandler(__rpc_handler_1380515435), "MoveClientRpc");
			((NetworkBehaviour)this).__registerRpc(1159591857u, new RpcReceiveHandler(__rpc_handler_1159591857), "ReachClientRpc");
			((NetworkBehaviour)this).__registerRpc(4179797884u, new RpcReceiveHandler(__rpc_handler_4179797884), "MissClientRpc");
			((NetworkBehaviour)this).__registerRpc(2506998788u, new RpcReceiveHandler(__rpc_handler_2506998788), "HideClientRpc");
			((NetworkBehaviour)this).__registerRpc(3485283754u, new RpcReceiveHandler(__rpc_handler_3485283754), "GrabClientRpc");
			((NetworkBehaviour)this).__registerRpc(834787675u, new RpcReceiveHandler(__rpc_handler_834787675), "StruggleFreeServerRpc");
			((NetworkBehaviour)this).__registerRpc(1606869797u, new RpcReceiveHandler(__rpc_handler_1606869797), "ReleaseClientRpc");
			base.__initializeRpcs();
		}

		private static void __rpc_handler_1380515435(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 at = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref at);
				float yaw = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref yaw, default(ForPrimitives));
				int target2 = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref target2);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CrawlspaceAI)(object)target).MoveClientRpc(at, yaw, target2);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1159591857(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CrawlspaceAI)(object)target).ReachClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4179797884(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CrawlspaceAI)(object)target).MissClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2506998788(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CrawlspaceAI)(object)target).HideClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3485283754(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0052: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int id = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				Vector3 startPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref startPos);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CrawlspaceAI)(object)target).GrabClientRpc(id, startPos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_834787675(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CrawlspaceAI)(object)target).StruggleFreeServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1606869797(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CrawlspaceAI)(object)target).ReleaseClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CrawlspaceAI";
		}
	}
	internal static class DecoySettings
	{
		internal static bool Enabled = true;

		internal static float Chance = 0.75f;

		internal static float ScrapChance = 1f;

		internal static int Min = 1;

		internal static int Max = 3;

		internal static int ScrapMaxValue = 60;

		internal static string Moons = "All";
	}
	public class DecoyLocker : NetworkBehaviour
	{
		internal static readonly HashSet<DecoyLocker> All = new HashSet<DecoyLocker>();

		internal static GameObject Prefab;

		public MobRig rig;

		public InteractTrigger trigger;

		public ScanNodeProperties scan;

		public AudioSource sfx;

		private readonly NetworkVariable<bool> open = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private int iDoor = -1;

		private float door;

		private bool inited;

		private static string lastKey;

		internal static void Build()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = NetworkPrefabs.CreateNetworkPrefab("MobPack_DecoyLocker");
			if (val.activeInHierarchy)
			{
				val.transform.SetParent(MobFactory.Holder.transform, false);
			}
			MobRig mobRig = MobModels.Build(layer: val.layer = MobFactory.EnemiesLayer, mobName: "MimicLocker", parent: val.transform);
			LockerKit.BuildShell(val.transform, mobRig, out var val2, out var _, out var _);
			ScanNodeProperties val3 = MobFactory.MakeScan(val.transform, LockerKit.ScanPos, "Storage locker", "", 35);
			val3.nodeType = 0;
			AudioSource val4 = val.AddComponent<AudioSource>();
			val4.playOnAwake = false;
			val4.spatialBlend = 1f;
			val4.dopplerLevel = 0f;
			val4.rolloffMode = (AudioRolloffMode)1;
			val4.minDistance = 3f;
			val4.maxDistance = 30f;
			DecoyLocker decoyLocker = val.AddComponent<DecoyLocker>();
			decoyLocker.rig = mobRig;
			decoyLocker.trigger = val2;
			decoyLocker.scan = val3;
			decoyLocker.sfx = val4;
			Prefab = val;
		}

		private void Init()
		{
			if (inited)
			{
				return;
			}
			inited = true;
			MobCleanup.Normalize(((Component)this).gameObject);
			All.Add(this);
			try
			{
				rig.ApplyMaterials();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("MobPack decoy materials: " + ex));
			}
			LockerKit.ShowMouth(rig, on: false);
			rig.SetVisible(on: true);
			iDoor = rig.PartIndex("Door");
			if ((Object)(object)trigger != (Object)null)
			{
				MobFactory.FixIcon(trigger);
				((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)OnInteract);
				trigger.interactable = true;
			}
			try
			{
				PlayerControllerB localPlayer = MobAI.LocalPlayer;
				if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.itemAudio != (Object)null && (Object)(object)sfx != (Object)null)
				{
					sfx.outputAudioMixerGroup = localPlayer.itemAudio.outputAudioMixerGroup;
				}
			}
			catch
			{
			}
			door = (open.Value ? 108f : 0f);
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			Init();
		}

		private void Start()
		{
			Init();
		}

		private void OnInteract(PlayerControllerB p)
		{
			if ((Object)(object)p != (Object)null)
			{
				ToggleServerRpc();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ToggleServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3068968228u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 3068968228u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					open.Value = !open.Value;
					SoundClientRpc(open.Value);
				}
			}
		}

		[ClientRpc]
		private void SoundClientRpc(bool opened)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1053417736u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref opened, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1053417736u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				AudioClip val3 = MobAudio.Get(opened ? "locker_creak" : "locker_slam");
				if (!((Object)(object)val3 == (Object)null) && !((Object)(object)sfx == (Object)null))
				{
					sfx.pitch = (opened ? Random.Range(0.95f, 1.08f) : Random.Range(1.15f, 1.3f));
					sfx.PlayOneShot(val3, (opened ? 0.7f : 0.35f) * Plugin.MasterVolume);
				}
			}
		}

		private void Update()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (inited)
			{
				float num = (open.Value ? 108f : 0f);
				if (Mathf.Abs(door - num) > 0.01f)
				{
					door = Mathf.MoveTowards(door, num, (open.Value ? 240f : 300f) * Time.deltaTime);
					rig.Pose(iDoor, new Vector3(0f, 0f - door, 0f));
				}
				if ((Object)(object)trigger != (Object)null)
				{
					trigger.hoverTip = (open.Value ? "Close locker : [E]" : "Open locker : [E]");
				}
			}
		}

		internal void HideLocal()
		{
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].enabled = false;
			}
		}

		public override void OnDestroy()
		{
			All.Remove(this);
			((NetworkBehaviour)this).OnDestroy();
		}

		internal static void TrySpawnForLevel(RoundManager rm)
		{
			if (!DecoySettings.Enabled || (Object)(object)Prefab == (Object)null || (Object)(object)rm == (Object)null || !((NetworkBehaviour)rm).IsServer)
			{
				return;
			}
			SelectableLevel currentLevel = rm.currentLevel;
			if (!((Object)(object)currentLevel == (Object)null) && currentLevel.spawnEnemiesAndScrap && MobSpawns.MoonMatches(currentLevel, DecoySettings.Moons))
			{
				string text = currentLevel.levelID + ":" + StartOfRound.Instance.randomMapSeed;
				if (!(text == lastKey))
				{
					lastKey = text;
					((MonoBehaviour)rm).StartCoroutine(SpawnRoutine(rm));
				}
			}
		}

		private static IEnumerator SpawnRoutine(RoundManager rm)
		{
			yield return (object)new WaitForSeconds(1.5f);
			bool test = MobSpawns.TestDecoys;
			if (!test && Random.value > DecoySettings.Chance)
			{
				Plugin.Log.LogInfo((object)"[MobPack] no decoy lockers this round.");
				yield break;
			}
			int n = (test ? Mathf.Max(1, DecoySettings.Max) : Random.Range(DecoySettings.Min, DecoySettings.Max + 1));
			List<Vector3> nodes = LockerKit.InsideNodes();
			if (nodes.Count == 0)
			{
				yield break;
			}
			Vector3 entrance = (from t in Object.FindObjectsOfType<EntranceTeleport>()
				where t.entranceId == 0 && !t.isEntranceToBuilding
				select ((Component)t).transform.position).FirstOrDefault();
			List<Vector3> byEntrance = nodes.OrderBy((Vector3 p) => Vector3.Distance(p, entrance)).ToList();
			int placed = 0;
			List<DecoyLocker> spawned = new List<DecoyLocker>();
			for (int i = 0; i < n * 4; i++)
			{
				if (placed >= n)
				{
					break;
				}
				if (LockerKit.FindWallSpot(test ? byEntrance[Mathf.Min(byEntrance.Count - 1, 2 + i * 2)] : nodes[Random.Range(0, nodes.Count)], nodes, null, out var pos, out var yaw, test ? 18f : 30f))
				{
					try
					{
						GameObject obj = Object.Instantiate<GameObject>(Prefab, pos, Quaternion.Euler(0f, yaw, 0f));
						MobCleanup.Normalize(obj);
						obj.GetComponent<NetworkObject>().Spawn(true);
						DecoyLocker component = obj.GetComponent<DecoyLocker>();
						component.Init();
						placed++;
						spawned.Add(component);
						Plugin.Log.LogInfo((object)$"[MobPack] decoy locker {placed}/{n} at {pos}.");
					}
					catch (Exception ex)
					{
						Plugin.Log.LogError((object)("[MobPack] decoy spawn: " + ex));
					}
					yield return null;
				}
			}
			yield return (object)new WaitForSeconds(0.5f);
			foreach (DecoyLocker item in spawned)
			{
				if ((Object)(object)item != (Object)null && DecoySettings.ScrapChance > 0f && (DecoySettings.ScrapChance >= 1f || Random.value < DecoySettings.ScrapChance))
				{
					item.SpawnScrapInside(rm);
				}
			}
		}

		private void SpawnScrapInside(RoundManager rm)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0101: 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)
			try
			{
				List<SpawnableItemWithRarity> list = rm.currentLevel.spawnableScrap?.Where((SpawnableItemWithRarity s) => s != null && (Object)(object)s.spawnableItem != (Object)null && s.spawnableItem.isScrap && !s.spawnableItem.twoHanded && (Object)(object)s.spawnableItem.spawnPrefab != (Object)null && s.spawnableItem.maxValue <= 120).ToList();
				if (list != null && list.Count != 0)
				{
					Item spawnableItem = list[Random.Range(0, list.Count)].spawnableItem;
					int num = Mathf.Clamp((int)((float)Random.Range(spawnableItem.minValue, spawnableItem.maxValue + 1) * rm.scrapValueMultiplier), 2, DecoySettings.ScrapMaxValue);
					Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(0f, 0.45f, -0.08f));
					GameObject obj = Object.Instantiate<GameObject>(spawnableItem.spawnPrefab, val, Quaternion.Euler(spawnableItem.restingRotation), rm.spawnedScrapContainer);
					GrabbableObject component = obj.GetComponent<GrabbableObject>();
					component.fallTime = 0f;
					component.scrapValue = num;
					component.isInFactory = true;
					NetworkObject component2 = obj.GetComponent<NetworkObject>();
					component2.Spawn(false);
					rm.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(component2) }, new int[1] { num });
					Plugin.Log.LogInfo((object)$"[MobPack] decoy locker holds {spawnableItem.itemName} ({num}).");
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[MobPack] decoy scrap: " + ex.Message));
			}
		}

		protected override void __initializeVariables()
		{
			if (open == null)
			{
				throw new Exception("DecoyLocker.open cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)open).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)open, "open");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)open);
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3068968228u, new RpcReceiveHandler(__rpc_handler_3068968228), "ToggleServerRpc");
			((NetworkBehaviour)this).__registerRpc(1053417736u, new RpcRece