Decompiled source of BeaconAnglers v1.0.0

Anglerfish.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Dawn;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
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: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class AnglerfishAI : EnemyAI
{
	public const int ambushState = 16;

	public const int lungeState = 80;

	private const int maxPlayers = 64;

	private const int heardMessage = 270081;

	private const int noiseMessage = 270082;

	private const int touchedMessage = 270083;

	public static List<AnglerfishAI> allAnglers = new List<AnglerfishAI>();

	[Header("Body")]
	public Transform model;

	public Transform mouthGrip;

	public Transform mouthSocket;

	public Transform bodyAnchor;

	public Transform lureBase;

	public Transform glowBone;

	public Transform rootBone;

	public Light lampLight;

	public SkinnedMeshRenderer bodyRenderer;

	public int lureMaterialIndex;

	public BoxCollider scanNodeCollider;

	public ScanNodeProperties lureScrapNode;

	[Header("Particles")]
	public ParticleSystem dirtRumble;

	public ParticleSystem dirtErupt;

	public ParticleSystem dirtImpact;

	public ParticleSystem bloodSpurt;

	public ParticleSystem bloodGush;

	public ParticleSystem bloodDrip;

	[Header("Audio")]
	public AudioSource footstepAudio;

	public AudioClip[] footsteps;

	public AudioClip[] voiceClips;

	public AudioClip digSound;

	public AudioClip popOutSound;

	public AudioClip grugSound;

	public float voiceIntervalMin = 7f;

	public float voiceIntervalMax = 18f;

	[Header("Animation timing")]
	public float spawnDuration = 2.3333333f;

	public float burrowDuration = 3.3333333f;

	public float biteTime = 0.4f;

	public float ambushDuration = 11f / 15f;

	public float retreatDuration = 1.2f;

	public float leapStart = 2f / 15f;

	public float biteReach = 0.67f;

	public float eatReleaseTime = 29f / 30f;

	public float eatCatchTime = 1.3333334f;

	public float eatDuration = 2.1666667f;

	public float dragStart = 1f / 6f;

	public float dragEnd = 13f / 15f;

	public float jumpOutLandTime = 1.5f;

	public float recoilDuration = 1.2f;

	public float recoilStepEnd = 0.8f;

	public float turnDuration = 2f / 3f;

	public float turnSide = 1f;

	public float recoverDuration = 0.8f;

	public float recoverDragEnd = 2f / 3f;

	public float walkClipSpeed = 0.25f;

	public float runClipSpeed = 0.725f;

	public float[] walkContacts = new float[2]
	{
		1f / 24f,
		13f / 24f
	};

	public float[] walkBackContacts = new float[2] { 0.4375f, 0.9375f };

	public float[] recoilContacts = new float[2] { 0.43f, 0.85f };

	public float[] turnContacts = new float[2] { 0.05f, 0.65f };

	public float localLureBoost;

	private const float size = 13f;

	private float stateTime;

	private float prevStateTime = -1f;

	private float stateLength;

	private int lastSeenState = -1;

	private bool ambushRequested;

	private Vector3 lastPosition;

	private Random enemyRandom;

	private HDAdditionalLightData lampLightHD;

	private MaterialPropertyBlock block;

	private Color poleGlow = new Color(1f, 0.96f, 0.86f) * 68.6f;

	private float poleLightDimmer = 1f;

	private float poleVolumetricDimmer = 1f;

	private Coroutine killRoutine;

	private DeadBodyInfo carriedBody;

	private PlayerControllerB currentVictim;

	private float leapDistance;

	private float sink;

	private Quaternion groundTilt = Quaternion.identity;

	private float tiltWeight;

	private bool dripping;

	private float prevWalkPhase = -1f;

	private int prevGait;

	private List<int> recentSteps = new List<int>();

	private float nextVoice = -1f;

	private int lastVoice = -1;

	private bool wasLuring;

	private int lightings;

	private static string[] scrapNames = new string[9] { "Glowing artifact", "Strange artifact", "Unknown artifact", "Ancient artifact", "Radiant relic", "Ancient relic", "Glowing orb", "Shining relic", "THE HOLY BWAH" };

	private bool hasTrap;

	private bool wanderer;

	private bool leftTrap;

	private bool trapLightsOn;

	private Vector3 trapRoot;

	private Vector3 trapFacing;

	private float turnedAt;

	private float nextPickAt;

	private bool hasSpot;

	private Vector3 relocateSpot;

	private Vector3 lastSpot = Vector3.one * 1000000f;

	private float nextMoveAt = -1f;

	private float pendingNoise;

	private float nextNoiseReport;

	private float nextHeardReport;

	private float nextTouchReport;

	private float nextVoiceCheck;

	private float[] noise = new float[64];

	private float[] noiseAt = new float[64];

	private bool[] scaredBy = new bool[64];

	private float overwhelmCooldown;

	private int chaseTarget = -1;

	private int fleeTarget = -1;

	private Vector3 heardAt;

	private Vector3 fleeFrom;

	private float heardTime;

	private float threatNoiseTime;

	private bool fleeDestSet;

	private float backDither = 1f;

	private float nextBackSpeedChange;

	private float turnStartYaw;

	private float turnYaw;

	private float deathTime;

	private float rollSide = 1f;

	private bool diedBuried;

	private bool deathThud;

	private Vector3 deathOffset;

	public bool IsLuring()
	{
		if (!base.isEnemyDead && base.currentBehaviourStateIndex == 3)
		{
			return stateTime > 1f;
		}
		return false;
	}

	public Vector3 GetLurePoint()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		return ((Component)lampLight).transform.position;
	}

	private bool IsAtTrap()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		if (hasTrap)
		{
			return Vector3.Distance(LampTrap.Flat(((Component)this).transform.position), LampTrap.Flat(trapRoot)) < 4f;
		}
		return false;
	}

	private bool IsRelocating()
	{
		if (wanderer)
		{
			return true;
		}
		float num = (((Object)(object)TimeOfDay.Instance != (Object)null) ? (6f + TimeOfDay.Instance.normalizedTimeOfDay * (float)TimeOfDay.Instance.numberOfHours) : 0f);
		if (hasTrap && AnglerfishPlugin.RelocateEnabled.Value)
		{
			return num >= 18f;
		}
		return false;
	}

	public override void Start()
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_0065: 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_00c3: 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_00f6: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//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_0334: 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_0473: Unknown result type (might be due to invalid IL or missing references)
		//IL_0478: Unknown result type (might be due to invalid IL or missing references)
		//IL_0428: Unknown result type (might be due to invalid IL or missing references)
		//IL_042d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).Start();
		allAnglers.Add(this);
		base.enemyHP = Mathf.Max(1, AnglerfishPlugin.Health.Value);
		enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
		lampLightHD = ((Component)lampLight).GetComponent<HDAdditionalLightData>();
		block = new MaterialPropertyBlock();
		model.localScale = Vector3.one * 13f;
		string[] array = new string[5] { "Collision", "ScanNode", "MapDot", "CreatureSFX", "CreatureVoice" };
		foreach (string text in array)
		{
			Transform obj = ((Component)this).transform.Find(text);
			obj.localPosition *= 13f;
		}
		Transform obj2 = ((Component)this).transform.Find("MapDot");
		obj2.localScale *= Mathf.Max(1f, 6.5f);
		BoxCollider component = ((Component)((Component)this).transform.Find("Collision")).GetComponent<BoxCollider>();
		component.center *= 13f;
		component.size *= 13f;
		scanNodeCollider.size = Vector3.one * Mathf.Min(6.5f, 1f);
		ScanNodeProperties component2 = ((Component)scanNodeCollider).GetComponent<ScanNodeProperties>();
		component2.maxRange = 20;
		component2.minRange = 0;
		AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren<AudioSource>(true);
		foreach (AudioSource obj3 in componentsInChildren)
		{
			obj3.maxDistance *= Mathf.Max(1f, 6.5f);
		}
		Light obj4 = lampLight;
		obj4.range *= 13f;
		base.agent.radius = Mathf.Min(3.9f, 3f);
		base.agent.height = 5.85f;
		NavMeshAgent agent = base.agent;
		agent.acceleration *= Mathf.Max(1f, 3.25f);
		Material val = ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material m) => ((Object)m).name == "GuidancePolesMat"));
		if ((Object)(object)val != (Object)null && val.HasProperty("_EmissiveColor"))
		{
			poleGlow = val.GetColor("_EmissiveColor");
		}
		Light[] source = Object.FindObjectsOfType<Light>();
		Light val2 = ((IEnumerable<Light>)source).FirstOrDefault((Func<Light, bool>)((Light l) => (Object)(object)((Component)l).transform.parent != (Object)null && ((Object)((Component)l).transform.parent).name.StartsWith("GuidancePole")));
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = ((IEnumerable<Light>)source).FirstOrDefault((Func<Light, bool>)((Light l) => (Object)(object)((Component)l).transform.parent != (Object)null && ((Component)((Component)l).transform.parent).GetComponentsInChildren<MeshRenderer>(true).Any((MeshRenderer r) => (Object)(object)((Renderer)r).sharedMaterial != (Object)null && ((Object)((Renderer)r).sharedMaterial).name.StartsWith("GuidancePolesMat"))));
		}
		if ((Object)(object)val2 == (Object)null && (Object)(object)AnglerfishPlugin.fakePolePrefab != (Object)null)
		{
			val2 = AnglerfishPlugin.fakePolePrefab.GetComponentInChildren<Light>(true);
		}
		HDAdditionalLightData val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<HDAdditionalLightData>() : null);
		if ((Object)(object)val3 != (Object)null && (Object)(object)lampLightHD != (Object)null)
		{
			lampLight.color = val2.color;
			lampLight.colorTemperature = val2.colorTemperature;
			lampLight.useColorTemperature = val2.useColorTemperature;
			lampLightHD.SetIntensity(val3.intensity, val3.lightUnit);
			lampLightHD.SetRange(Mathf.Clamp(val3.range, 6f, 30f));
			lampLightHD.shapeRadius = val3.shapeRadius;
			lampLightHD.affectsVolumetric = val3.affectsVolumetric;
			lampLightHD.volumetricFadeDistance = val3.volumetricFadeDistance;
			lampLightHD.fadeDistance = val3.fadeDistance;
			poleLightDimmer = val3.lightDimmer;
			poleVolumetricDimmer = val3.volumetricDimmer;
		}
		LampTrap instance = LampTrap.Instance;
		if ((Object)(object)instance != (Object)null && instance.trapActive && !instance.claimed)
		{
			instance.claimed = true;
			hasTrap = true;
			trapFacing = instance.trapFacing;
			trapRoot = instance.trapBodyRoot;
		}
		else if ((Object)(object)instance != (Object)null && instance.wanderDay && !instance.claimed)
		{
			instance.claimed = true;
			wanderer = true;
		}
		lastPosition = ((Component)this).transform.position;
		base.agent.speed = 0f;
		base.currentBehaviourStateIndex = 0;
		base.currentBehaviourState = base.enemyBehaviourStates[0];
		EnterState(0);
	}

	private static void PlayParticle(ParticleSystem ps, Vector3 position, Quaternion rotation)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		((Component)ps).transform.SetPositionAndRotation(position, rotation);
		ps.Clear(true);
		ps.Play(true);
	}

	private bool PassedTime(float time)
	{
		if (prevStateTime < time)
		{
			return stateTime >= time;
		}
		return false;
	}

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

	public override void Update()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: 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)
		//IL_01a9: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0506: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: 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_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_069f: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_083f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0845: Unknown result type (might be due to invalid IL or missing references)
		//IL_084a: Unknown result type (might be due to invalid IL or missing references)
		//IL_084f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0854: Unknown result type (might be due to invalid IL or missing references)
		//IL_0869: Unknown result type (might be due to invalid IL or missing references)
		//IL_086e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0890: Unknown result type (might be due to invalid IL or missing references)
		//IL_0888: Unknown result type (might be due to invalid IL or missing references)
		//IL_0760: Unknown result type (might be due to invalid IL or missing references)
		//IL_076a: Unknown result type (might be due to invalid IL or missing references)
		//IL_076f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0780: Unknown result type (might be due to invalid IL or missing references)
		//IL_0785: Unknown result type (might be due to invalid IL or missing references)
		//IL_078a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0792: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0895: Unknown result type (might be due to invalid IL or missing references)
		//IL_089a: Unknown result type (might be due to invalid IL or missing references)
		//IL_089f: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0812: Unknown result type (might be due to invalid IL or missing references)
		//IL_081d: Unknown result type (might be due to invalid IL or missing references)
		//IL_098c: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a09: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a24: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a29: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a39: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b6e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b73: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cc5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cf6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0edd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f0e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f13: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f18: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f20: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f25: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f2a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f2e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f33: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f3b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f40: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f45: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f4c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f51: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f56: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f58: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f5f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f64: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f7b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f7d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f7f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f84: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f9a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f9c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f9e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fb7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fbf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fc4: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).Update();
		if (base.currentBehaviourStateIndex != lastSeenState)
		{
			EnterState(base.currentBehaviourStateIndex);
		}
		prevStateTime = stateTime;
		stateTime += Time.deltaTime;
		int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
		Vector3 position = ((Component)this).transform.position;
		Quaternion rotation = ((Component)this).transform.rotation;
		switch (currentBehaviourStateIndex)
		{
		case 0:
		case 4:
		case 12:
			if (PassedTime(0.01f))
			{
				PlayParticle(dirtRumble, position - ((Component)this).transform.forward * 3.9f, rotation);
			}
			if (PassedTime(0.8f))
			{
				PlayParticle(dirtErupt, position + ((Component)this).transform.forward * 0.65000004f, rotation);
			}
			if (PassedTime(1.53f))
			{
				PlayParticle(dirtImpact, position, rotation);
			}
			if (PassedTime(jumpOutLandTime))
			{
				Footstep(1.6f);
			}
			if (PassedTime(jumpOutLandTime + 0.07f))
			{
				Footstep(1.1f);
			}
			break;
		case 2:
			if (PassedTime(0.01f))
			{
				footstepAudio.pitch = 1f;
				footstepAudio.PlayOneShot(digSound);
				WalkieTalkie.TransmitOneShotAudio(footstepAudio, digSound, 0.6f);
			}
			if (PassedTime(0.33f) || PassedTime(1f))
			{
				PlayParticle(dirtRumble, position + ((Component)this).transform.forward * 3.25f, rotation);
			}
			if (PassedTime(1.9f))
			{
				PlayParticle(dirtImpact, position, rotation);
			}
			break;
		case 5:
			if (PassedTime(0.3f))
			{
				PlayParticle(dirtRumble, position, rotation);
			}
			if (PassedTime(0.75f))
			{
				PlayParticle(dirtImpact, position, rotation);
			}
			break;
		default:
		{
			if (currentBehaviourStateIndex < 16)
			{
				break;
			}
			float num = ambushDuration * 0.97f;
			bool flag = currentBehaviourStateIndex >= 80;
			if (flag && ((Object)(object)currentVictim == (Object)null || !currentVictim.isPlayerDead))
			{
				if (PassedTime(biteTime))
				{
					Footstep(1.6f);
				}
				break;
			}
			if (!flag && PassedTime(0.01f))
			{
				footstepAudio.pitch = 1f;
				footstepAudio.PlayOneShot(popOutSound);
				WalkieTalkie.TransmitOneShotAudio(footstepAudio, popOutSound, 0.6f);
			}
			if (!flag && PassedTime(leapStart))
			{
				PlayParticle(dirtErupt, position, rotation);
			}
			if (PassedTime(biteTime))
			{
				PlayParticle(dirtImpact, position + ((Component)this).transform.forward * (leapDistance + 2.86f), rotation);
				Footstep(1.6f);
				Bleed(big: false);
			}
			if (PassedTime(num + 1f / 6f) || PassedTime(num + 13f / 30f))
			{
				Bleed(big: false);
			}
			if (PassedTime(num + 11f / 15f))
			{
				Bleed(big: true);
			}
			if (PassedTime(num + eatCatchTime + 1f / 15f))
			{
				Bleed(big: true);
			}
			if (PassedTime(biteTime) || PassedTime(num + eatCatchTime + 1f / 15f))
			{
				SetDrip(on: true);
			}
			if (PassedTime(num + eatReleaseTime) || PassedTime(num + eatDuration - 0.3f))
			{
				SetDrip(on: false);
			}
			break;
		}
		}
		if (dripping && currentBehaviourStateIndex < 16)
		{
			SetDrip(on: false);
		}
		float num2 = Mathf.Clamp01(Vector3.Distance(glowBone.position, rootBone.position) / 1.3000001f);
		if (base.isEnemyDead)
		{
			num2 *= 1f - Mathf.Clamp01((Time.time - deathTime - 0.3f) / 2.5f);
		}
		num2 *= 1f + localLureBoost * (3.5f + 0.6f * Mathf.Sin(Time.time * 1.4f));
		((Behaviour)lampLight).enabled = num2 > 0.01f;
		if ((Object)(object)lampLightHD != (Object)null)
		{
			lampLightHD.lightDimmer = num2 * poleLightDimmer;
			lampLightHD.volumetricDimmer = num2 * poleVolumetricDimmer * (1f + 2f * localLureBoost);
		}
		((Renderer)bodyRenderer).GetPropertyBlock(block, lureMaterialIndex);
		block.SetColor("_EmissiveColor", poleGlow * num2);
		((Renderer)bodyRenderer).SetPropertyBlock(block, lureMaterialIndex);
		float num3 = 0f;
		if (currentBehaviourStateIndex >= 16)
		{
			num3 = Smooth((stateTime - leapStart) / (biteTime - leapStart));
		}
		else
		{
			switch (currentBehaviourStateIndex)
			{
			case 11:
				num3 = 1f - Smooth(stateTime / recoverDragEnd);
				break;
			case 5:
				num3 = 1f - Smooth((stateTime - dragStart) / (dragEnd - dragStart));
				if (IsAtTrap())
				{
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(trapFacing, Vector3.up), Time.deltaTime * 3f);
				}
				break;
			}
		}
		bool flag2 = currentBehaviourStateIndex == 3 || (currentBehaviourStateIndex == 2 && stateTime > burrowDuration * 0.55f) || (currentBehaviourStateIndex == 5 && stateTime > dragEnd);
		float num4 = 1f;
		sink = Mathf.MoveTowards(sink, flag2 ? num4 : 0f, Time.deltaTime * (flag2 ? (num4 / 1.2f) : (num4 / 0.1f)));
		tiltWeight = Mathf.MoveTowards(tiltWeight, flag2 ? 1f : 0f, Time.deltaTime * (flag2 ? (5f / 6f) : 10f));
		model.localPosition = Vector3.forward * (leapDistance * num3) + Vector3.down * sink;
		model.localRotation = Quaternion.Slerp(Quaternion.identity, groundTilt, tiltWeight);
		if (base.isEnemyDead)
		{
			float num5 = Time.time - deathTime;
			if (base.creatureAnimator.speed != 0f && num5 > (diedBuried ? 0.1f : 0.45f))
			{
				base.creatureAnimator.speed = 0f;
			}
			if (!diedBuried)
			{
				float num6 = Smooth((num5 - 0.35f) / 1.3f);
				Vector3 val = Vector3.up * 2.86f;
				Quaternion val2 = Quaternion.AngleAxis(165f * rollSide * num6, Vector3.forward);
				model.localRotation = val2;
				model.localPosition = deathOffset * (1f - num6) + val - val2 * val + Vector3.down * (0.52f * num6);
				if (!deathThud && num6 >= 0.97f)
				{
					deathThud = true;
					Footstep(1.6f);
					PlayParticle(dirtImpact, ((Component)this).transform.position, ((Component)this).transform.rotation);
				}
			}
			return;
		}
		float num7 = Mathf.Max(Time.deltaTime, 0.0001f);
		Vector3 val3 = LampTrap.Flat(((Component)this).transform.position - lastPosition);
		float num8 = ((Vector3)(ref val3)).magnitude / num7;
		lastPosition = ((Component)this).transform.position;
		if (currentBehaviourStateIndex == 6)
		{
			Quaternion val4 = Quaternion.LookRotation(IsAtTrap() ? trapFacing : ((Component)this).transform.forward, Vector3.up);
			((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val4, 45f * Time.deltaTime);
			if (Quaternion.Angle(((Component)this).transform.rotation, val4) > 3f)
			{
				num8 = Mathf.Max(num8, walkClipSpeed * 13f * 0.7f);
			}
		}
		bool flag3 = currentBehaviourStateIndex == 7 || currentBehaviourStateIndex == 10 || currentBehaviourStateIndex == 13 || currentBehaviourStateIndex == 14;
		bool flag4 = currentBehaviourStateIndex == 8 || currentBehaviourStateIndex == 9;
		base.creatureAnimator.SetBool("run", flag3);
		base.creatureAnimator.SetBool("backwards", flag4);
		if (((NetworkBehaviour)this).IsOwner)
		{
			switch (currentBehaviourStateIndex)
			{
			case 13:
			case 14:
				((Component)this).transform.rotation = Quaternion.Euler(0f, turnStartYaw + turnYaw * Smooth(stateTime / turnDuration), 0f);
				break;
			case 8:
			case 9:
			{
				Vector3 val5 = LampTrap.Flat(fleeFrom - ((Component)this).transform.position);
				if (((Vector3)(ref val5)).sqrMagnitude >= 0.01f)
				{
					float num9 = ((currentBehaviourStateIndex == 9) ? (15f * Mathf.Sin(Time.time * 1.3f)) : 0f);
					((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(((Vector3)(ref val5)).normalized, Vector3.up) * Quaternion.Euler(0f, num9, 0f), 90f * Time.deltaTime);
				}
				break;
			}
			}
		}
		base.creatureAnimator.SetFloat("speed", num8 / 13f, 0.15f, Time.deltaTime);
		base.creatureAnimator.SetFloat("walkSpeed", Mathf.Clamp(num8 / ((flag3 ? runClipSpeed : walkClipSpeed) * 13f), flag4 ? 0.12f : 0.3f, 4f), 0.15f, Time.deltaTime);
		AnimatorStateInfo currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0);
		bool flag5 = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("TurnFlee") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("TurnFleeMirror");
		float[] array = null;
		if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Walk") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Run"))
		{
			array = walkContacts;
		}
		else if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("WalkBack"))
		{
			array = walkBackContacts;
		}
		else if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Recoil"))
		{
			array = recoilContacts;
		}
		else if (flag5)
		{
			array = turnContacts;
		}
		if (array == null || prevGait != ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash)
		{
			goto IL_0b83;
		}
		if (base.creatureAnimator.IsInTransition(0))
		{
			AnimatorStateInfo nextAnimatorStateInfo = base.creatureAnimator.GetNextAnimatorStateInfo(0);
			if (((AnimatorStateInfo)(ref nextAnimatorStateInfo)).IsName("Idle"))
			{
				goto IL_0b83;
			}
		}
		float normalizedTime = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime;
		float weight = (flag5 ? 1.3f : (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Run") ? 1.15f : Mathf.Clamp(base.creatureAnimator.GetFloat("walkSpeed"), 0.6f, 1.3f)));
		if (prevWalkPhase >= 0f && normalizedTime > prevWalkPhase)
		{
			float[] array2 = array;
			foreach (float num10 in array2)
			{
				if (Mathf.Floor(normalizedTime - num10) > Mathf.Floor(prevWalkPhase - num10))
				{
					Footstep(weight);
				}
			}
		}
		prevWalkPhase = normalizedTime;
		goto IL_0c56;
		IL_0c56:
		if (Time.time >= nextVoiceCheck)
		{
			nextVoiceCheck = Time.time + 0.2f;
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController != (Object)null && !localPlayerController.isPlayerDead && LureHallucination.speaking && LureHallucination.speakingFor >= 0.35f)
			{
				float voiceLoudness = LureHallucination.voiceLoudness;
				if (Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position) <= 36f * Mathf.Max(voiceLoudness, flag4 ? 0.5f : 0.3f))
				{
					Hear(((Component)localPlayerController).transform.position, voiceLoudness, localPlayerController, voice: true, 0.2f);
					FlushNoise(localPlayerController);
				}
			}
		}
		if (voiceClips.Length != 0)
		{
			if (currentBehaviourStateIndex != 1)
			{
				nextVoice = Random.Range(2f, 6f);
			}
			else
			{
				if (nextVoice < 0f)
				{
					nextVoice = Random.Range(2f, 6f);
				}
				nextVoice -= Time.deltaTime;
				if (nextVoice <= 0f && !base.creatureVoice.isPlaying)
				{
					nextVoice = Random.Range(voiceIntervalMin, voiceIntervalMax);
					int num11;
					do
					{
						num11 = Random.Range(0, voiceClips.Length);
					}
					while (voiceClips.Length > 1 && num11 == lastVoice);
					lastVoice = num11;
					base.creatureVoice.pitch = Mathf.Clamp(0.97f, 0.85f, 1.1f) * Random.Range(0.9f, 1.06f);
					base.creatureVoice.clip = voiceClips[num11];
					base.creatureVoice.volume = Random.Range(0.92f, 1f);
					base.creatureVoice.Play();
					WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, voiceClips[num11], 0.6f);
				}
			}
		}
		if (currentBehaviourStateIndex != 3)
		{
			return;
		}
		if (!ambushRequested && stateTime >= 1f)
		{
			PlayerControllerB localPlayerController2 = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController2 != (Object)null && !localPlayerController2.isPlayerDead && localPlayerController2.isPlayerControlled && !localPlayerController2.isInHangarShipRoom && localPlayerController2.isInsideFactory != base.isOutside && (Object)(object)localPlayerController2.inAnimationWithEnemy == (Object)null && Mathf.Abs(((Component)localPlayerController2).transform.position.y - ((Component)this).transform.position.y) <= 7.8f)
			{
				Vector3 val6 = LampTrap.Flat(((Component)localPlayerController2).transform.position);
				val3 = LampTrap.Flat(((Component)this).transform.forward);
				Vector3 normalized = ((Vector3)(ref val3)).normalized;
				Vector3 val7 = LampTrap.Flat(((Component)this).transform.position) - normalized * 5.85f;
				Vector3 val8 = normalized * 11.7f;
				float num12 = ((((Vector3)(ref val8)).sqrMagnitude > 1E-06f) ? Mathf.Clamp01(Vector3.Dot(val6 - val7, val8) / ((Vector3)(ref val8)).sqrMagnitude) : 0f);
				float num13 = Vector3.Distance(val6, val7 + val8 * num12) - 3.25f;
				float num14 = Vector3.Distance(val6, LampTrap.Flat(lureBase.position));
				if (Mathf.Min(num13, num14) <= AnglerfishPlugin.AmbushRadius.Value)
				{
					ambushRequested = true;
					((EnemyAI)this).SwitchToBehaviourServerRpc(16 + (int)localPlayerController2.playerClientId);
				}
			}
		}
		if (IsAtTrap() && !trapLightsOn && stateTime > 2.5f && (Object)(object)LampTrap.Instance != (Object)null)
		{
			trapLightsOn = true;
			LampTrap.Instance.SetTrapLit(lit: true);
		}
		return;
		IL_0b83:
		prevGait = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash;
		prevWalkPhase = ((array == null) ? (-1f) : ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime);
		goto IL_0c56;
	}

	private void LateUpdate()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		if (dripping)
		{
			((Component)bloodDrip).transform.SetPositionAndRotation(mouthGrip.position, Quaternion.LookRotation(Vector3.down, ((Component)this).transform.forward));
		}
		bool flag = IsLuring();
		if (flag && !wasLuring)
		{
			Random random = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex * 7919 + lightings * 104729);
			lightings++;
			lureScrapNode.headerText = scrapNames[random.Next(scrapNames.Length)];
			lureScrapNode.scrapValue = random.Next(240, 481);
			lureScrapNode.subText = $"Value: ${lureScrapNode.scrapValue}";
		}
		wasLuring = flag;
		if (((Component)lureScrapNode).gameObject.activeSelf != flag)
		{
			((Component)lureScrapNode).gameObject.SetActive(flag);
		}
		if (flag)
		{
			((Component)lureScrapNode).transform.position = GetLurePoint() + Vector3.up * 0.25f;
		}
	}

	private void EnterState(int state)
	{
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		lastSeenState = state;
		stateTime = 0f;
		ambushRequested = false;
		if (((NetworkBehaviour)this).IsOwner)
		{
			base.agent.updateRotation = state != 8 && state != 9 && state != 13 && state != 14;
		}
		switch (state)
		{
		case 0:
			stateLength = spawnDuration;
			return;
		case 1:
			stateLength = ((hasTrap || wanderer) ? 150f : (15f + (float)enemyRandom.NextDouble() * 20f));
			return;
		case 2:
			stateLength = burrowDuration;
			if (IsAtTrap())
			{
				((Component)this).transform.rotation = Quaternion.LookRotation(trapFacing, Vector3.up);
			}
			MeasureGroundTilt();
			return;
		case 3:
			stateLength = (hasTrap ? float.MaxValue : (60f + (float)enemyRandom.NextDouble() * 60f));
			if (((NetworkBehaviour)this).IsOwner && IsRelocating() && (wanderer || nextMoveAt > 0f))
			{
				nextMoveAt = Time.time + Random.Range(45f, 90f);
			}
			return;
		case 4:
		case 12:
			stateLength = spawnDuration;
			if (trapLightsOn && (Object)(object)LampTrap.Instance != (Object)null)
			{
				trapLightsOn = false;
				LampTrap.Instance.SetTrapLit(lit: false);
			}
			return;
		case 5:
			stateLength = retreatDuration;
			MeasureGroundTilt();
			return;
		case 6:
			stateLength = 4.5f;
			turnedAt = 0f;
			return;
		case 7:
			stateLength = float.MaxValue;
			PlayVoice(voiceClips[Random.Range(0, voiceClips.Length)], 0.95f, 1.1f);
			return;
		case 8:
			stateLength = recoilDuration;
			PlayVoice(grugSound, 0.96f, 1.04f);
			return;
		case 9:
			stateLength = Random.Range(2.5f, 4f);
			return;
		case 10:
			stateLength = 20f;
			fleeDestSet = false;
			return;
		case 11:
			stateLength = recoverDuration;
			return;
		case 13:
		case 14:
			stateLength = turnDuration;
			return;
		}
		if (state < 16)
		{
			return;
		}
		bool flag = state >= 80;
		int num = state - (flag ? 80 : 16);
		if (num < StartOfRound.Instance.allPlayerScripts.Length)
		{
			if (killRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(killRoutine);
				DropCarriedBody();
			}
			if (flag)
			{
				PlayVoice(voiceClips[Random.Range(0, voiceClips.Length)], 0.95f, 1.1f);
			}
			killRoutine = ((MonoBehaviour)this).StartCoroutine(AmbushPlayer(StartOfRound.Instance.allPlayerScripts[num], flag));
		}
	}

	private void PlayVoice(AudioClip clip, float minPitch, float maxPitch)
	{
		base.creatureVoice.Stop();
		base.creatureVoice.pitch = Mathf.Clamp(0.97f, 0.85f, 1.1f) * Random.Range(minPitch, maxPitch);
		base.creatureVoice.clip = clip;
		base.creatureVoice.volume = 1f;
		base.creatureVoice.Play();
		WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, clip, 0.6f);
	}

	private void Footstep(float weight)
	{
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		int num;
		do
		{
			num = Random.Range(0, footsteps.Length);
		}
		while (footsteps.Length > 4 && recentSteps.Contains(num));
		recentSteps.Add(num);
		if (recentSteps.Count > Mathf.Min(4, footsteps.Length - 1))
		{
			recentSteps.RemoveAt(0);
		}
		footstepAudio.pitch = Mathf.Clamp(0.964f, 0.8f, 1.1f) * Random.Range(0.93f, 1.05f) / Mathf.Lerp(1f, 1.12f, weight - 1f);
		footstepAudio.PlayOneShot(footsteps[num], Mathf.Lerp(0.9f, 1.25f, weight - 1f) * Random.Range(0.9f, 1f));
		if (weight >= 1f)
		{
			WalkieTalkie.TransmitOneShotAudio(footstepAudio, footsteps[num], 0.6f);
		}
		PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
		if ((Object)(object)val != (Object)null && !val.isPlayerDead && !val.isInsideFactory && (Object)(object)HUDManager.Instance != (Object)null)
		{
			float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) / 13f;
			bool flag = weight > 1.2f;
			if (flag && num2 < 1.2f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num2 < (flag ? 2.5f : 1.3f))
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
		}
	}

	private void SetDrip(bool on)
	{
		dripping = on;
		if (on)
		{
			bloodDrip.Play(true);
		}
		else
		{
			bloodDrip.Stop(true, (ParticleSystemStopBehavior)1);
		}
	}

	private void Bleed(bool big)
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = (big ? (((Component)this).transform.forward + Vector3.up * 0.15f) : (((Component)this).transform.forward * 0.7f + Vector3.down * 0.55f + ((Component)this).transform.right * Random.Range(-0.35f, 0.35f)));
		PlayParticle(big ? bloodGush : bloodSpurt, mouthGrip.position, Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up));
		if ((Object)(object)currentVictim != (Object)null && (Object)(object)currentVictim.deadBody != (Object)null && ((Component)currentVictim.deadBody).gameObject.activeSelf)
		{
			currentVictim.DropBlood(Vector3.down, true, false);
		}
	}

	private void MeasureGroundTilt()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		groundTilt = Quaternion.identity;
		Vector3 val = (IsAtTrap() ? trapFacing : ((Component)this).transform.forward);
		LampTrap.BodyFits(((Component)this).transform.position, val, 13f, new HashSet<Collider>(((Component)this).GetComponentsInChildren<Collider>(true)), out var normal);
		Vector3 val2 = LampTrap.Flat(val);
		Vector3 val3 = Quaternion.Inverse(Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up)) * normal;
		float num = Vector3.Angle(Vector3.up, val3);
		if (num > 0.5f)
		{
			float num2 = Mathf.Min(num, 18f);
			val2 = Vector3.Cross(Vector3.up, val3);
			groundTilt = Quaternion.AngleAxis(num2, ((Vector3)(ref val2)).normalized);
		}
	}

	private IEnumerator AmbushPlayer(PlayerControllerB victim, bool surface)
	{
		Vector3 val = ((Component)victim).transform.position - ((Component)this).transform.position;
		val.y = 0f;
		if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
		{
			((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
		}
		currentVictim = victim;
		leapDistance = Mathf.Clamp(((Vector3)(ref val)).magnitude - biteReach * 13f, -3.9f, 10.400001f);
		if (((NetworkBehaviour)this).IsOwner)
		{
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
		}
		float startTime = Time.time;
		yield return (object)new WaitForSeconds(biteTime);
		Vector3 val2 = ((Component)this).transform.position + ((Component)this).transform.forward * (biteReach * 13f + leapDistance);
		Vector3 val3;
		int num;
		if (surface)
		{
			val3 = LampTrap.Flat(((Component)victim).transform.position - val2);
			num = ((((Vector3)(ref val3)).magnitude < 3.9f) ? 1 : 0);
		}
		else
		{
			num = 1;
		}
		bool flag = (byte)num != 0;
		if ((Object)(object)victim == (Object)(object)GameNetworkManager.Instance.localPlayerController && !victim.isPlayerDead && flag)
		{
			victim.enemyWaitingForBodyRagdoll = (EnemyAI)(object)this;
			PlayerControllerB obj = victim;
			Vector3 zero = Vector3.zero;
			val3 = default(Vector3);
			obj.KillPlayer(zero, true, (CauseOfDeath)6, 0, val3, false);
		}
		float waitStart = Time.time;
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)victim.deadBody != (Object)null || Time.time - waitStart > (surface ? 0.7f : 2f)));
		if (surface && (Object)(object)victim.deadBody == (Object)null)
		{
			currentVictim = null;
			killRoutine = null;
			if (((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(11);
			}
			yield break;
		}
		if ((Object)(object)victim.deadBody != (Object)null)
		{
			carriedBody = victim.deadBody;
			Rigidbody val4 = carriedBody.bodyParts[5];
			Vector3 position = val4.position;
			Vector3 position2 = val4.position;
			Rigidbody[] bodyParts = carriedBody.bodyParts;
			foreach (Rigidbody val5 in bodyParts)
			{
				if ((Object)(object)val5 != (Object)null)
				{
					if (val5.position.y > position.y)
					{
						position = val5.position;
					}
					if (val5.position.y < position2.y)
					{
						position2 = val5.position;
					}
				}
			}
			val3 = position - position2;
			Vector3 val6;
			if (!(((Vector3)(ref val3)).sqrMagnitude > 0.01f))
			{
				val6 = Vector3.up;
			}
			else
			{
				val3 = position - position2;
				val6 = ((Vector3)(ref val3)).normalized;
			}
			Vector3 val7 = val6;
			Vector3 val8 = Vector3.ProjectOnPlane(((Component)victim).transform.forward, val7);
			if (((Vector3)(ref val8)).sqrMagnitude < 0.0001f)
			{
				val8 = Vector3.ProjectOnPlane(((Component)this).transform.forward, val7);
			}
			((Vector3)(ref val8)).Normalize();
			mouthSocket.rotation = Quaternion.LookRotation(Vector3.up, ((Component)this).transform.right) * Quaternion.Inverse(Quaternion.LookRotation(((Component)val4).transform.InverseTransformDirection(val8), ((Component)val4).transform.InverseTransformDirection(val7)));
			carriedBody.attachedTo = mouthSocket;
			carriedBody.attachedLimb = val4;
			carriedBody.matchPositionExactly = true;
		}
		float eatStart = startTime + ambushDuration * 0.97f;
		float release = eatStart + eatReleaseTime;
		float catchAt = eatStart + eatCatchTime;
		yield return (object)new WaitUntil((Func<bool>)(() => Time.time >= release));
		if ((Object)(object)carriedBody != (Object)null)
		{
			Vector3 throwFrom = mouthSocket.position;
			bodyAnchor.SetPositionAndRotation(throwFrom, mouthSocket.rotation);
			carriedBody.attachedTo = bodyAnchor;
			Vector3 spinAxis = ((Component)this).transform.forward;
			float height = 4.5499997f;
			while (Time.time < catchAt && (Object)(object)carriedBody != (Object)null)
			{
				float num3 = Mathf.InverseLerp(release, catchAt, Time.time);
				bodyAnchor.SetPositionAndRotation(Vector3.Lerp(throwFrom, mouthSocket.position, num3) + Vector3.up * (height * 4f * num3 * (1f - num3)), Quaternion.AngleAxis(540f * num3, spinAxis) * mouthSocket.rotation);
				yield return null;
			}
		}
		yield return (object)new WaitUntil((Func<bool>)(() => Time.time >= catchAt));
		if ((Object)(object)carriedBody != (Object)null)
		{
			carriedBody.attachedTo = null;
			carriedBody.attachedLimb = null;
			carriedBody.matchPositionExactly = false;
			carriedBody.DeactivateBody(false);
			carriedBody = null;
		}
		yield return (object)new WaitUntil((Func<bool>)(() => Time.time >= eatStart + eatDuration));
		killRoutine = null;
		if (((NetworkBehaviour)this).IsOwner)
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(surface ? 11 : 5);
		}
	}

	private void DropCarriedBody()
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)carriedBody != (Object)null)
		{
			carriedBody.speedMultiplier = 12f;
			carriedBody.attachedTo = null;
			carriedBody.attachedLimb = null;
			carriedBody.matchPositionExactly = false;
			carriedBody.bodyParts[5].AddForce((((Component)this).transform.forward * 0.4f + Vector3.up * 0.3f) * 3f, (ForceMode)1);
			carriedBody = null;
		}
	}

	private bool PickRelocationSpot()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: 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_01d5: 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_0251: 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_0263: 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_026f: 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_028b: 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_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Expected O, but got Unknown
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = LampTrap.ShipPosition();
		List<Vector3> list = new List<Vector3>();
		EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
		foreach (EntranceTeleport val2 in array)
		{
			if (val2.isEntranceToBuilding && (wanderer || val2.entranceId == 0))
			{
				list.Add(((Component)val2).transform.position);
			}
		}
		int collidersAndRoomMaskAndDefault = StartOfRound.Instance.collidersAndRoomMaskAndDefault;
		float num = Mathf.Min(2.6000001f, 3f);
		HashSet<Collider> own = new HashSet<Collider>(((Component)this).GetComponentsInChildren<Collider>(true));
		NavMeshHit val5 = default(NavMeshHit);
		RaycastHit val6 = default(RaycastHit);
		for (int j = 0; j < 60; j++)
		{
			Vector3 val3 = val;
			float num2 = 24f;
			float num3 = 40f;
			if (Random.value >= 0.5f && list.Count != 0)
			{
				val3 = list[Random.Range(0, list.Count)];
				num2 = 12f;
				num3 = 24f;
			}
			Vector2 insideUnitCircle = Random.insideUnitCircle;
			Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized;
			Vector3 val4 = val3 + new Vector3(normalized.x, 0f, normalized.y) * Random.Range(num2, num3);
			if (!NavMesh.SamplePosition(val4, ref val5, 6f, -1))
			{
				continue;
			}
			Vector3 normal = LampTrap.Flat(((NavMeshHit)(ref val5)).position - val4);
			if (((Vector3)(ref normal)).magnitude > 4f)
			{
				continue;
			}
			Vector3 spot = ((NavMeshHit)(ref val5)).position;
			normal = LampTrap.Flat(spot - val);
			if (((Vector3)(ref normal)).magnitude < 22f)
			{
				continue;
			}
			normal = LampTrap.Flat(spot - ((Component)this).transform.position);
			if (((Vector3)(ref normal)).magnitude < 35f)
			{
				continue;
			}
			normal = LampTrap.Flat(spot - lastSpot);
			if (!(((Vector3)(ref normal)).magnitude < 35f) && !StartOfRound.Instance.allPlayerScripts.Any((PlayerControllerB p) => p.isPlayerControlled && !p.isPlayerDead && Vector3.Distance(((Component)p).transform.position, spot) < 10f) && (!Physics.Raycast(spot + Vector3.up * 2f, Vector3.down, ref val6, 5f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || !(((RaycastHit)(ref val6)).normal.y < 0.8f)) && !Physics.OverlapCapsule(spot + Vector3.up * (num + 0.5f), spot + Vector3.up * Mathf.Max(num + 0.6f, 5.2000003f), num, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1).Any((Collider c) => !own.Contains(c) && !(c is TerrainCollider)) && LampTrap.BodyFits(spot, Vector3.zero, 13f, own, out normal))
			{
				NavMeshPath val7 = new NavMeshPath();
				if (base.agent.CalculatePath(spot, val7) && (int)val7.status == 0 && LampTrap.WallCrossings(val7.corners, float.MaxValue) <= 0)
				{
					relocateSpot = spot;
					hasSpot = true;
					return true;
				}
			}
		}
		return false;
	}

	public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
		if (!base.isEnemyDead && timesPlayedInOneSpot <= 15 && noiseID != 7 && noiseID != 546 && noiseID != 675189)
		{
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)val != (Object)null && Vector3.Distance(((Component)val).transform.position, noisePosition) <= 5f)
			{
				Hear(noisePosition, noiseLoudness, val, noiseID == 75);
			}
		}
	}

	private void Hear(Vector3 noisePosition, float loud, PlayerControllerB me, bool voice, float dt = 0f)
	{
		//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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		if (me.isPlayerDead || !me.isPlayerControlled || me.isInsideFactory || me.isInHangarShipRoom)
		{
			return;
		}
		int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
		bool flag = currentBehaviourStateIndex == 3;
		bool flag2 = currentBehaviourStateIndex == 8 || currentBehaviourStateIndex == 9;
		if ((currentBehaviourStateIndex != 1 && currentBehaviourStateIndex != 6 && currentBehaviourStateIndex != 7 && !flag && !flag2) || (flag2 && !voice))
		{
			return;
		}
		Vector3 val = ((Component)this).transform.position + Vector3.up * 3.9f;
		if (Physics.Linecast(val, noisePosition, 256, (QueryTriggerInteraction)1))
		{
			loud *= 0.5f;
		}
		float num = Vector3.Distance(val, noisePosition);
		if (flag2)
		{
			if (Time.time >= nextHeardReport)
			{
				nextHeardReport = Time.time + 0.4f;
				SendToOwner(270081, me);
			}
			return;
		}
		float num2 = Mathf.Clamp(1f - num / 40f, 0.2f, 1f);
		float num3 = 0f;
		if (dt > 0f)
		{
			if (loud >= 0.35f)
			{
				num3 = loud * loud * num2 * dt;
			}
		}
		else if (!voice)
		{
			num3 = Mathf.Pow(Mathf.Min(loud, 1f), 4f) * num2 * 0.5f;
		}
		if (num3 > 0f && (!flag || num <= 12f))
		{
			pendingNoise += num3;
		}
		if (!voice || dt == 0f)
		{
			FlushNoise(me);
		}
		if (!flag && (loud >= 0.25f || voice) && Time.time >= nextHeardReport)
		{
			nextHeardReport = Time.time + 0.4f;
			SendToOwner(270081, me);
		}
	}

	private void FlushNoise(PlayerControllerB me)
	{
		if (pendingNoise > 0f && (Time.time >= nextNoiseReport || pendingNoise >= 0.3f))
		{
			nextNoiseReport = Time.time + 0.4f;
			int value = Mathf.Clamp(Mathf.RoundToInt(pendingNoise * 1000f), 1, 100000);
			pendingNoise = 0f;
			SendToOwner(270082, me, value);
		}
	}

	private float NoiseOf(int id, float now)
	{
		return noise[id] * Mathf.Exp((0f - (now - noiseAt[id])) / 4f);
	}

	private void SendToOwner(int message, PlayerControllerB player, int value = 0)
	{
		if (((NetworkBehaviour)this).IsOwner)
		{
			OnPlayerMessage(message, player, value);
		}
		else
		{
			((EnemyAI)this).HitEnemyServerRpc(value, (int)player.playerClientId, false, message);
		}
	}

	public override void OnCollideWithPlayer(Collider other)
	{
		((EnemyAI)this).OnCollideWithPlayer(other);
		PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
		int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
		if ((Object)(object)val != (Object)null && !base.isEnemyDead && Time.time >= nextTouchReport && (currentBehaviourStateIndex == 1 || currentBehaviourStateIndex == 6 || currentBehaviourStateIndex == 7))
		{
			nextTouchReport = Time.time + 0.5f;
			SendToOwner(270083, val);
		}
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		if (hitID == 270081 || hitID == 270082 || hitID == 270083)
		{
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)playerWhoHit != (Object)null)
			{
				OnPlayerMessage(hitID, playerWhoHit, force);
			}
			return;
		}
		((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		if (base.isEnemyDead)
		{
			return;
		}
		base.enemyHP -= force;
		if (base.enemyHP > 0)
		{
			PlayVoice(grugSound, 0.96f, 1.04f);
		}
		if (!((NetworkBehaviour)this).IsOwner)
		{
			return;
		}
		if (base.enemyHP <= 0)
		{
			((EnemyAI)this).KillEnemyOnOwnerClient(false);
		}
		else if (!((Object)(object)playerWhoHit == (Object)null) && !playerWhoHit.isPlayerDead)
		{
			switch (base.currentBehaviourStateIndex)
			{
			case 8:
			case 9:
				threatNoiseTime = Time.time;
				break;
			case 3:
				chaseTarget = (int)playerWhoHit.playerClientId;
				heardAt = ((Component)playerWhoHit).transform.position;
				heardTime = Time.time;
				((EnemyAI)this).SwitchToBehaviourClientRpc(4);
				break;
			default:
				OnPlayerMessage(270083, playerWhoHit, 0);
				break;
			}
		}
	}

	public override void KillEnemy(bool destroy = false)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (((NetworkBehaviour)this).IsOwner)
		{
			StopRoamingSearch();
		}
		((EnemyAI)this).KillEnemy(destroy);
		if (base.isEnemyDead)
		{
			deathTime = Time.time;
			diedBuried = sink > 0.5f;
			deathOffset = model.localPosition;
			rollSide = ((Random.value < 0.5f) ? (-1f) : 1f);
			if (killRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(killRoutine);
				killRoutine = null;
			}
			DropCarriedBody();
			currentVictim = null;
			SetDrip(on: false);
			if (trapLightsOn && (Object)(object)LampTrap.Instance != (Object)null)
			{
				trapLightsOn = false;
				LampTrap.Instance.SetTrapLit(lit: false);
			}
			base.creatureAnimator.SetBool("run", false);
			base.creatureAnimator.SetBool("backwards", false);
			base.creatureAnimator.SetFloat("speed", 0f);
			if (!diedBuried)
			{
				base.creatureAnimator.SetTrigger("recoil");
			}
		}
	}

	private void OnPlayerMessage(int message, PlayerControllerB player, int value)
	{
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: 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)
		if (base.isEnemyDead || player.isPlayerDead)
		{
			return;
		}
		int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
		int num = (int)player.playerClientId;
		int num2;
		switch (currentBehaviourStateIndex)
		{
		case 8:
		case 9:
			if (message != 270083 && (num == fleeTarget || (num >= 0 && num < 64 && scaredBy[num])))
			{
				threatNoiseTime = Time.time;
			}
			return;
		default:
			num2 = ((currentBehaviourStateIndex == 7) ? 1 : 0);
			break;
		case 1:
		case 6:
			num2 = 1;
			break;
		}
		bool flag = (byte)num2 != 0;
		if (message == 270082)
		{
			if (num < 0 || num >= 64 || (!flag && currentBehaviourStateIndex != 3))
			{
				return;
			}
			float time = Time.time;
			noise[num] = NoiseOf(num, time) + (float)value / 1000f;
			noiseAt[num] = time;
			if (time < overwhelmCooldown)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			int num3 = Mathf.Min(allPlayerScripts.Length, 64);
			float num4 = 0f;
			float num5 = 0f;
			int num6 = -1;
			int num7 = 0;
			for (int i = 0; i < num3; i++)
			{
				if ((Object)(object)allPlayerScripts[i] != (Object)null && allPlayerScripts[i].isPlayerControlled && !allPlayerScripts[i].isPlayerDead)
				{
					float num8 = NoiseOf(i, time);
					num4 += num8;
					if (num8 >= 0.35f)
					{
						num7++;
					}
					if (num8 > num5)
					{
						num5 = num8;
						num6 = i;
					}
				}
			}
			if (!(num4 * (1f + 0.75f * (float)Mathf.Max(0, num7 - 1)) < AnglerfishPlugin.OverwhelmPoints.Value) && num6 >= 0)
			{
				for (int j = 0; j < 64; j++)
				{
					scaredBy[j] = j < num3 && (j == num6 || NoiseOf(j, time) >= 0.35f);
				}
				for (int k = 0; k < 64; k++)
				{
					noise[k] = 0f;
				}
				overwhelmCooldown = time + 8f;
				fleeFrom = ((Component)allPlayerScripts[num6]).transform.position;
				fleeTarget = num6;
				threatNoiseTime = time;
				if (currentBehaviourStateIndex == 3)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(12);
					return;
				}
				StopRoamingSearch();
				((EnemyAI)this).SwitchToBehaviourClientRpc(8);
			}
		}
		else if (flag)
		{
			chaseTarget = num;
			heardAt = ((Component)player).transform.position;
			heardTime = Time.time;
			if (message == 270083 && InLungeRange(player))
			{
				Lunge(player);
			}
			else if (currentBehaviourStateIndex != 7)
			{
				StopRoamingSearch();
				((EnemyAI)this).SwitchToBehaviourClientRpc(7);
			}
		}
	}

	private void StopRoamingSearch()
	{
		if (base.currentSearch != null && base.currentSearch.inProgress)
		{
			((EnemyAI)this).StopSearch(base.currentSearch, true);
		}
	}

	private bool InLungeRange(PlayerControllerB player)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: 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)
		Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position;
		if (!player.isInHangarShipRoom && Mathf.Abs(val.y) < 7.8f)
		{
			Vector3 val2 = LampTrap.Flat(val);
			return ((Vector3)(ref val2)).magnitude <= (biteReach + 0.35f) * 13f;
		}
		return false;
	}

	private void Lunge(PlayerControllerB target)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		base.agent.speed = 0f;
		base.agent.velocity = Vector3.zero;
		base.moveTowardsDestination = false;
		((EnemyAI)this).SwitchToBehaviourClientRpc(80 + (int)target.playerClientId);
	}

	private void ResumeRoaming()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		chaseTarget = -1;
		base.agent.updateRotation = true;
		((EnemyAI)this).SwitchToBehaviourClientRpc(1);
		if (!hasTrap && !wanderer)
		{
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}
	}

	public override void OnDestroy()
	{
		allAnglers.Remove(this);
		if (hasTrap && trapLightsOn && (Object)(object)LampTrap.Instance != (Object)null)
		{
			LampTrap.Instance.SetTrapLit(lit: false);
		}
		((EnemyAI)this).OnDestroy();
	}

	public override void DoAIInterval()
	{
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae3: 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_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0932: Unknown result type (might be due to invalid IL or missing references)
		//IL_0938: Unknown result type (might be due to invalid IL or missing references)
		//IL_0823: Unknown result type (might be due to invalid IL or missing references)
		//IL_0829: Unknown result type (might be due to invalid IL or missing references)
		//IL_082e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0833: Unknown result type (might be due to invalid IL or missing references)
		//IL_0838: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_085c: Unknown result type (might be due to invalid IL or missing references)
		//IL_084e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0853: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_051a: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0511: Unknown result type (might be due to invalid IL or missing references)
		//IL_0679: Unknown result type (might be due to invalid IL or missing references)
		//IL_067f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0684: Unknown result type (might be due to invalid IL or missing references)
		//IL_0689: Unknown result type (might be due to invalid IL or missing references)
		//IL_068e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0861: Unknown result type (might be due to invalid IL or missing references)
		//IL_0869: Unknown result type (might be due to invalid IL or missing references)
		//IL_086e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0875: Unknown result type (might be due to invalid IL or missing references)
		//IL_087a: Unknown result type (might be due to invalid IL or missing references)
		//IL_087f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: 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_051f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0527: Unknown result type (might be due to invalid IL or missing references)
		//IL_052c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_0538: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_054f: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_099c: Unknown result type (might be due to invalid IL or missing references)
		//IL_089f: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0923: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_09af: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09be: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e9: Expected O, but got Unknown
		//IL_08f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0901: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: 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_0778: Unknown result type (might be due to invalid IL or missing references)
		//IL_077e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0783: Unknown result type (might be due to invalid IL or missing references)
		//IL_0788: Unknown result type (might be due to invalid IL or missing references)
		//IL_078d: Unknown result type (might be due to invalid IL or missing references)
		//IL_060c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0611: Unknown result type (might be due to invalid IL or missing references)
		//IL_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a04: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a09: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a17: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a41: Unknown result type (might be due to invalid IL or missing references)
		//IL_090a: Unknown result type (might be due to invalid IL or missing references)
		//IL_090f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_064c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07be: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DoAIInterval();
		if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
		{
			return;
		}
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
		case 4:
			base.agent.speed = 0f;
			if (!(stateTime >= stateLength))
			{
				break;
			}
			if (chaseTarget >= 0 && Time.time - heardTime < AnglerfishPlugin.ChaseMemory.Value)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(7);
				break;
			}
			((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			if (!hasTrap && !wanderer)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
			break;
		case 1:
			base.agent.speed = walkClipSpeed * 13f * 0.6f;
			if (hasTrap || wanderer)
			{
				if (wanderer && !hasSpot && Time.time >= nextPickAt)
				{
					nextPickAt = Time.time + 3f;
					PickRelocationSpot();
				}
				if (hasSpot || hasTrap)
				{
					Vector3 val12 = (hasSpot ? relocateSpot : trapRoot);
					((EnemyAI)this).SetDestinationToPosition(val12, false);
					bool flag3 = Vector3.Distance(LampTrap.Flat(((Component)this).transform.position), LampTrap.Flat(val12)) < ((val12 == trapRoot) ? 2f : 3f);
					if (flag3 && val12 != trapRoot)
					{
						lastSpot = val12;
					}
					if (flag3 || stateTime >= stateLength)
					{
						base.agent.speed = 0f;
						base.agent.velocity = Vector3.zero;
						base.moveTowardsDestination = false;
						((EnemyAI)this).SwitchToBehaviourClientRpc((flag3 && val12 == trapRoot) ? 6 : 2);
					}
				}
			}
			else if (stateTime >= stateLength)
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				base.agent.speed = 0f;
				base.agent.velocity = Vector3.zero;
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			}
			break;
		case 2:
		case 5:
			base.agent.speed = 0f;
			if (stateTime >= stateLength)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			}
			break;
		case 3:
			base.agent.speed = 0f;
			if (IsRelocating())
			{
				if (hasTrap && leftTrap)
				{
					break;
				}
				if (nextMoveAt < 0f)
				{
					nextMoveAt = Time.time + Random.Range(5f, 20f);
				}
				if (!(Time.time < nextMoveAt))
				{
					if (stateTime > 1f && PickRelocationSpot())
					{
						leftTrap = true;
						((EnemyAI)this).SwitchToBehaviourClientRpc(4);
					}
					else
					{
						nextMoveAt = Time.time + 15f;
					}
				}
			}
			else if (stateTime >= stateLength)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(4);
			}
			break;
		case 6:
		{
			base.agent.speed = 0f;
			bool flag2 = Quaternion.Angle(((Component)this).transform.rotation, Quaternion.LookRotation(IsAtTrap() ? trapFacing : ((Component)this).transform.forward, Vector3.up)) < 1f;
			if ((flag2 && stateTime >= turnedAt + 0.4f) || stateTime >= stateLength)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			}
			else if (!flag2)
			{
				turnedAt = stateTime;
			}
			break;
		}
		case 7:
		{
			base.agent.speed = AnglerfishPlugin.ChaseSpeed.Value;
			PlayerControllerB val15 = ((chaseTarget >= 0 && chaseTarget < allPlayerScripts.Length) ? allPlayerScripts[chaseTarget] : null);
			if ((Object)(object)val15 == (Object)null || val15.isPlayerDead || !val15.isPlayerControlled || val15.isInsideFactory || val15.isInHangarShipRoom || Time.time - heardTime > AnglerfishPlugin.ChaseMemory.Value)
			{
				ResumeRoaming();
				break;
			}
			bool flag4 = Time.time - heardTime < 1.5f;
			((EnemyAI)this).SetDestinationToPosition(flag4 ? ((Component)val15).transform.position : heardAt, false);
			if (flag4 && InLungeRange(val15))
			{
				Lunge(val15);
			}
			break;
		}
		case 8:
		{
			base.agent.speed = ((stateTime < recoilStepEnd) ? 1.6f : 0f);
			Vector3 val13 = LampTrap.Flat(((Component)this).transform.position - fleeFrom);
			val13 = ((((Vector3)(ref val13)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val13)).normalized : (-((Component)this).transform.forward));
			NavMeshHit val14 = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)this).transform.position + val13 * 6f, ref val14, 4f, -1))
			{
				((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val14)).position, false);
			}
			if (stateTime >= stateLength)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(9);
			}
			break;
		}
		case 9:
		{
			PlayerControllerB val = ((fleeTarget >= 0 && fleeTarget < allPlayerScripts.Length) ? allPlayerScripts[fleeTarget] : null);
			if ((Object)(object)val != (Object)null && !val.isPlayerDead && val.isPlayerControlled && !val.isInsideFactory)
			{
				fleeFrom = ((Component)val).transform.position;
				if (!val.isInHangarShipRoom && Time.time - threatNoiseTime > 3f)
				{
					chaseTarget = fleeTarget;
					heardAt = ((Component)val).transform.position;
					heardTime = Time.time;
					base.agent.velocity = Vector3.zero;
					if (InLungeRange(val))
					{
						Lunge(val);
						break;
					}
					((EnemyAI)this).SetDestinationToPosition(((Component)val).transform.position, false);
					base.agent.updateRotation = true;
					((EnemyAI)this).SwitchToBehaviourClientRpc(7);
					break;
				}
			}
			float num = 15f;
			Vector3 val2 = LampTrap.Flat(((Component)this).transform.position - fleeFrom);
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if ((stateTime > 1.5f && magnitude >= num) || stateTime > 15f)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(10);
				break;
			}
			if (Time.time >= nextBackSpeedChange)
			{
				nextBackSpeedChange = Time.time + Random.Range(0.4f, 1f);
				backDither = ((Random.value < 0.2f) ? 0f : Random.Range(0.5f, 1.4f));
			}
			float num2 = Mathf.InverseLerp(num, num / 3f, magnitude);
			base.agent.speed = Mathf.MoveTowards(base.agent.speed, Mathf.Lerp(1.2f * backDither, AnglerfishPlugin.ChaseSpeed.Value, num2), (num2 > 0.2f) ? 1.5f : 0.5f);
			Vector3 val3 = LampTrap.Flat(((Component)this).transform.position - fleeFrom);
			val3 = ((((Vector3)(ref val3)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val3)).normalized : (-((Component)this).transform.forward));
			NavMeshHit val4 = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)this).transform.position + val3 * 8f, ref val4, 4f, -1))
			{
				((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val4)).position, false);
			}
			break;
		}
		case 10:
		{
			base.agent.speed = AnglerfishPlugin.ChaseSpeed.Value;
			if (!fleeDestSet)
			{
				fleeDestSet = true;
				Vector3 val5 = LampTrap.Flat(((Component)this).transform.position - fleeFrom);
				val5 = ((((Vector3)(ref val5)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val5)).normalized : (-((Component)this).transform.forward));
				Vector3 val6 = ((Component)this).transform.position + val5 * 15f;
				float num3 = 90f;
				NavMeshHit val8 = default(NavMeshHit);
				for (int i = 0; i < 20; i++)
				{
					Vector3 val7 = Quaternion.AngleAxis(Random.Range(-60f, 60f), Vector3.up) * val5;
					if (NavMesh.SamplePosition(fleeFrom + val7 * Random.Range(num3, num3 + 15f), ref val8, 8f, -1))
					{
						NavMeshPath val9 = new NavMeshPath();
						if (base.agent.CalculatePath(((NavMeshHit)(ref val8)).position, val9) && (int)val9.status == 0)
						{
							val6 = ((NavMeshHit)(ref val8)).position;
							break;
						}
					}
				}
				((EnemyAI)this).SetDestinationToPosition(val6, false);
			}
			bool num4 = Vector3.Distance(((Component)this).transform.position, fleeFrom) >= 90f;
			bool flag = !base.agent.pathPending && base.agent.remainingDistance < 2f && stateTime > 1f;
			if (num4 || flag || stateTime >= stateLength)
			{
				Vector3 val10 = LampTrap.Flat((hasSpot ? relocateSpot : trapRoot) - ((Component)this).transform.position);
				if ((!hasSpot && !hasTrap) || ((Vector3)(ref val10)).sqrMagnitude < 4f)
				{
					ResumeRoaming();
					break;
				}
				turnStartYaw = ((Component)this).transform.eulerAngles.y;
				float num5 = turnStartYaw;
				Quaternion val11 = Quaternion.LookRotation(((Vector3)(ref val10)).normalized, Vector3.up);
				turnYaw = Mathf.DeltaAngle(num5, ((Quaternion)(ref val11)).eulerAngles.y);
				base.agent.speed = 0f;
				base.agent.velocity = Vector3.zero;
				base.moveTowardsDestination = false;
				((EnemyAI)this).SwitchToBehaviourClientRpc((turnYaw >= 0f == turnSide >= 0f) ? 13 : 14);
			}
			break;
		}
		case 11:
			base.agent.speed = 0f;
			if (stateTime >= stateLength)
			{
				ResumeRoaming();
			}
			break;
		case 12:
			base.agent.speed = 0f;
			if (stateTime >= stateLength)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(10);
			}
			break;
		case 13:
		case 14:
			base.agent.speed = 0f;
			base.agent.velocity = Vector3.zero;
			if (stateTime >= stateLength)
			{
				ResumeRoaming();
			}
			break;
		default:
			base.agent.speed = 0f;
			break;
		}
	}
}
[BepInPlugin("jaketraxx.BeaconAngler", "Beacon Angler", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AnglerfishPlugin : BaseUnityPlugin
{
	public static EnemyType enemyType;

	public static GameObject fakePolePrefab;

	public static TerminalNode bestiaryFile;

	public static Material lureMaterial;

	public static AudioClip lurePad;

	public static ConfigEntry<float> TrapDayChance;

	public static ConfigEntry<float> TrapSpawnDelayMin;

	public static ConfigEntry<float> TrapSpawnDelayMax;

	public static ConfigEntry<float> AmbushRadius;

	public static ConfigEntry<float> LurePullStrength;

	public static ConfigEntry<float> ChaseSpeed;

	public static ConfigEntry<float> ChaseMemory;

	public static ConfigEntry<float> OverwhelmPoints;

	public static ConfigEntry<string> MoonBlacklist;

	public static ConfigEntry<bool> RelocateEnabled;

	public static ConfigEntry<bool> LureEnabled;

	public static ConfigEntry<int> Health;

	private void Awake()
	{
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Expected O, but got Unknown
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		TrapDayChance = ((BaseUnityPlugin)this).Config.Bind<float>("LampTrap", "DayChance", 0.15f, "Chance (0-1) that he comes on a given day. Snowy moons can always have him, other moons only with a line of lamps or in fog. If he isn't coming there are no fake lamps. A moon with a line of lamps gets the trap if one fits, otherwise he roams.");
		TrapSpawnDelayMin = ((BaseUnityPlugin)this).Config.Bind<float>("LampTrap", "SpawnDelayMin", 60f, "Earliest he spawns, in seconds after landing.");
		TrapSpawnDelayMax = ((BaseUnityPlugin)this).Config.Bind<float>("LampTrap", "SpawnDelayMax", 240f, "Latest he spawns, in seconds after landing.");
		MoonBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("Moons", "Blacklist", "", "Comma-separated moons he never comes to (e.g. \"Rend, 85-Rend, MyModdedMoon\").");
		RelocateEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Relocation", "Enabled", true, "In the evening he digs out of the trap and waits by the main entrance or the ship until the ship leaves.");
		AmbushRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Ambush", "TriggerRadius", 3f, "How close (meters) to the lamp or his buried body a player gets eaten.");
		LureEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Lure", "Enabled", true, "Personal: walking towards his lamp the world goes quiet, a pad swells in, the screen distorts and you get pulled in.");
		LurePullStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Lure", "PullStrength", 5f, "How fast (m/s) the pull drags you at its strongest. Walking is about 4.5 m/s.");
		Health = ((BaseUnityPlugin)this).Config.Bind<int>("Combat", "Health", 7, "Hit points. A shovel hit takes 1, a knife 1, a shotgun blast up to 5.");
		ChaseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Hunting", "ChaseSpeed", 5.5f, "How fast he runs (m/s) at a player he heard and away from noise.");
		ChaseMemory = ((BaseUnityPlugin)this).Config.Bind<float>("Hunting", "ChaseMemory", 6f, "Seconds of silence before he loses track of who he was chasing.");
		OverwhelmPoints = ((BaseUnityPlugin)this).Config.Bind<float>("Hunting", "OverwhelmPoints", 1.6f, "How much loud noise it takes to overwhelm him. One player yelling right by him does it in about 2 seconds.");
		new Harmony("jaketraxx.BeaconAngler").PatchAll(typeof(TerminalPatch));
		AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "anglerfish"));
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not load the anglerfish bundle, it has to sit next to the dll");
			return;
		}
		enemyType = val.LoadAsset<EnemyType>("AnglerfishEnemyType");
		fakePolePrefab = val.LoadAsset<GameObject>("AnglerfishFakePole");
		bestiaryFile = val.LoadAsset<TerminalNode>("BeaconAnglerFile");
		lureMaterial = val.LoadAsset<Material>("LureLCD");
		lurePad = val.LoadAsset<AudioClip>("LurePad");
		DawnLib.RegisterNetworkPrefab(enemyType.enemyPrefab);
		DawnLib.DefineEnemy(NamespacedKey<DawnEnemyInfo>.From("beacon_angler", "beacon_angler"), enemyType, (Action<EnemyInfoBuilder>)delegate(EnemyInfoBuilder builder)
		{
			builder.CreateBestiaryNode(bestiaryFile.displayText).CreateNameKeyword("beacon-angler");
		});
		GameObject val2 = new GameObject("AnglerfishManager");
		Object.DontDestroyOnLoad((Object)val2);
		((Object)val2).hideFlags = (HideFlags)61;
		val2.AddComponent<LampTrap>();
		val2.AddComponent<LureHallucination>();
	}
}
[HarmonyPatch(typeof(Terminal))]
internal class TerminalPatch
{
	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static void AddAnglerKeyword(Terminal __instance)
	{
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Expected O, but got Unknown
		TerminalKeyword val = null;
		TerminalKeyword val2 = null;
		TerminalKeyword[] allKeywords = __instance.terminalNodes.allKeywords;
		foreach (TerminalKeyword val3 in allKeywords)
		{
			if (!((Object)(object)val3 == (Object)null))
			{
				if (val3.word == "info")
				{
					val = val3;
				}
				else if (val3.word == "angler")
				{
					val2 = val3;
				}
			}
		}
		TerminalNode val4 = __instance.enemyFiles.Find((TerminalNode node) => (Object)(object)node != (Object)null && node.creatureName == "Beacon angler");
		if ((Object)(object)val == (Object)null || (Object)(object)val4 == (Object)null)
		{
			return;
		}
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = ScriptableObject.CreateInstance<TerminalKeyword>();
			((Object)val2).name = "angler";
			val2.word = "angler";
			val2.defaultVerb = val;
			__instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, val2);
		}
		CompatibleNoun[] compatibleNouns = val.compatibleNouns;
		foreach (CompatibleNoun val5 in compatibleNouns)
		{
			if ((Object)(object)val5.noun != (Object)null && val5.noun.word == "angler")
			{
				return;
			}
		}
		val.compatibleNouns = CollectionExtensions.AddToArray<CompatibleNoun>(val.compatibleNouns, new CompatibleNoun(val2, val4));
	}

	[HarmonyPatch("LoadNewNode")]
	[HarmonyPrefix]
	private static void SetBestiaryVideo(TerminalNode node)
	{
		if ((Object)(object)node != (Object)null && (Object)(object)node.displayVideo == (Object)null && node.creatureName == "Beacon angler" && (Object)(object)AnglerfishPlugin.bestiaryFile != (Object)null)
		{
			node.displayVideo = AnglerfishPlugin.bestiaryFile.displayVideo;
		}
	}
}
public class LampTrap : MonoBehaviour
{
	private class SwitchableLamp
	{
		public GameObject gameObject;

		public MeshRenderer[] renderers;

		public Material[][] originalMaterials;

		public Light[] lights;
	}

	private class Lamp
	{
		public Transform root;

		public Light light;

		public Bounds bounds;

		public Vector3 foot;

		public float score;

		public float along;
	}

	private class Walk
	{
		public Vector3[] corners;

		public bool toMain;
	}

	private class Branch
	{
		public Lamp junction;

		public List<Vector3> points;

		public Vector3 root;

		public float score;
	}

	public static LampTrap Instance;

	public static HashSet<Collider> lampColliders = new HashSet<Collider>();

	public const float maxSlope = 14f;

	public bool trapActive;

	public bool wanderDay;

	public bool claimed;

	public Vector3 trapFacing;

	public Vector3 trapBodyRoot;

	private const int trailPoints = 6;

	private const int realLampsToDarken = 5;

	private const int minLampsInLine = 5;

	private const float nearWalk = 15f;

	private const float awayFromWalk = 25f;

	private const float maxLampHeight = 30f;

	private const float maxLampWidth = 12f;

	private bool setUp;

	private bool spawned;

	private bool trapLit;

	private float spawnAt = -1f;

	private List<SwitchableLamp> fakePoles = new List<SwitchableLamp>();

	private List<SwitchableLamp> darkenedLamps = new List<SwitchableLamp>();

	private Material onMaterial;

	private Material offMaterial;

	private Dictionary<Material, Material> offCopies = new Dictionary<Material, Material>();

	private Coroutine switching;

	public static Vector3 Flat(Vector3 v)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(v.x, 0f, v.z);
	}

	public static Vector3 ShipPosition()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)StartOfRound.Instance.shipLandingPositi