Decompiled source of Sentinel Mod v1.1.0

SentinelMod.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("AubPiggybackAPI")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("SentinelMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SentinelMod")]
[assembly: AssemblyTitle("SentinelMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SentinelMod
{
	[BepInPlugin("SentinelMod", "SentinelMod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			AubPiggyback.ModLoadStage("SentinelMod");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			AubPiggyback.assetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "sentinelbundle"));
			if ((Object)(object)AubPiggyback.assetBundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			Debug.Log((object)("Mod (" + AubPiggyback.modName + ") Loaded custom assets :)"));
			SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity();
			val.enemyType = AubPiggyback.assetBundle.LoadAsset<EnemyType>("Assets/LethalCompany/Mods/SentinelMod/Sentinel.asset");
			val.rarity = 80;
			AubPiggyback.prep();
			AubPiggyback.addEnemy(val, 82267);
			AubPiggyback.addTerminalNode(AubPiggyback.assetBundle.LoadAsset<TerminalNode>("Assets/LethalCompany/Mods/SentinelMod/SentinelTerminal.asset"));
			AubPiggyback.addBoomboxAudio(AubPiggyback.assetBundle.LoadAsset<AudioClip>("Assets/LethalCompany/Mods/SentinelMod/sfx/BoomboxMusicMammoth.ogg"));
			AubPiggyback.setPrefabRegistry("SentinelBulletTracer", AubPiggyback.assetBundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/SentinelMod/bullet_tracer.prefab"), false);
			AubPiggyback.setSFXRegistry("SentinelEngine", AubPiggyback.assetBundle.LoadAsset<AudioClip>("Assets/LethalCompany/Mods/SentinelMod/sfx/sentinel_engine.wav"));
			AubPiggyback.execute();
		}
	}
	public class SentinelAI : EnemyAI
	{
		public AISearchRoutine searchForPlayers;

		private float checkLineOfSightInterval;

		public float maxSearchAndRoamRadius = 150f;

		[Space(5f)]
		public float noticePlayerTimer;

		private bool hasEnteredChaseMode;

		private bool lostPlayerInChase;

		private bool beginningChasingThisClient;

		private Collider[] nearPlayerColliders;

		private Vector3 previousPosition;

		private float previousVelocity;

		private float averageVelocity;

		private float velocityInterval;

		private float velocityAverageCount;

		private float wallCollisionSFXDebounce;

		private float timeSinceHittingPlayer;

		public AudioClip[] walkSFX;

		public AudioClip[] moveSFX;

		public AudioClip[] hurtSFX;

		public AudioClip gunStartSFX;

		public AudioClip gunLoopSFX;

		public AudioClip gunEndSFX;

		public AudioClip gunShotSFX;

		public AudioClip gunBulletImpactSFX;

		public AudioClip deathSFX;

		public AudioClip critSFX;

		public AudioClip chaseSFX;

		public AudioClip beepSFX;

		private float agentSpeedWithNegative;

		private Vector3 lastPositionOfSeenPlayer;

		[Space(5f)]
		public float BaseAcceleration = 5f;

		public float SpeedAccelerationEffect = 1f;

		public float SpeedIncreaseRate = 1f;

		private float lastTimeHit;

		public bool isCrawling = false;

		private bool isCrawlTemp = false;

		private float crawlingWaitTime = 0f;

		private Vector3 slope;

		private Light HeadLight;

		private GameObject Torso;

		private GameObject GunFlareL;

		private GameObject GunFlareR;

		private GameObject BoomboxTrig;

		private float DamageOffset = 0f;

		private Vector3 targetPoint = Vector3.zero;

		private float shootCycle = 0f;

		private bool cycleToDo = false;

		private GameObject Barrel;

		public float lockOnSpeed = 3.5f;

		public int boomboxInRange = 0;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsServer)
			{
				isCrawling = false;
			}
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			base.creatureAnimator.SetBool("dancing", false);
			nearPlayerColliders = (Collider[])(object)new Collider[4];
			BaseAcceleration = 5f;
			base.creatureSFX.clip = AubPiggyback.getSFXRegistry("SentinelEngine");
			base.creatureSFX.loop = true;
			base.creatureSFX.Play();
			HeadLight = ((Component)((Component)this).transform.Find("SentinelModel/sentinel/root/waist/torso/head/Point Light")).GetComponent<Light>();
			Torso = ((Component)((Component)this).transform.Find("SentinelModel/sentinel/root/waist/torso")).gameObject;
			GunFlareL = ((Component)((Component)this).transform.Find("SentinelModel/sentinel/root/waist/torso/arm.L/hand.L/gun.L/gunflare")).gameObject;
			GunFlareL.AddComponent<DelayedDisable>();
			GunFlareR = ((Component)((Component)this).transform.Find("SentinelModel/sentinel/root/waist/torso/arm.R/hand.R/gun.R/gunflare")).gameObject;
			GunFlareR.AddComponent<DelayedDisable>();
			BoomboxTrig = ((Component)((Component)this).transform.Find("BoomboxTrigger")).gameObject;
			BoomboxTrig.AddComponent<SentinelBoomboxTrigger>();
			base.enemyHP = 10;
		}

		public override void DoAIInterval()
		{
			//IL_0058: 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)
			((EnemyAI)this).DoAIInterval();
			if (StartOfRound.Instance.livingPlayers == 0 || base.isEnemyDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (!searchForPlayers.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayers);
					Debug.Log((object)$"Sentinel: Started new search; is searching?: {searchForPlayers.inProgress}");
				}
				break;
			case 1:
				CheckForVeryClosePlayer();
				if (lostPlayerInChase)
				{
					base.movingTowardsTargetPlayer = false;
					if (!searchForPlayers.inProgress)
					{
						searchForPlayers.searchWidth = 50f;
						((EnemyAI)this).StartSearch(lastPositionOfSeenPlayer, searchForPlayers);
						Debug.Log((object)"Sentinel: Lost player in chase; beginning search where the player was last seen");
					}
				}
				else if (searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(searchForPlayers, true);
					base.movingTowardsTargetPlayer = true;
					Debug.Log((object)"Sentinel: Found player during chase; stopping search coroutine and moving after target player");
				}
				break;
			}
		}

		public override void FinishedCurrentSearchRoutine()
		{
			((EnemyAI)this).FinishedCurrentSearchRoutine();
			searchForPlayers.searchWidth = Mathf.Clamp(searchForPlayers.searchWidth + 10f, 1f, maxSearchAndRoamRadius);
		}

		public override void Update()
		{
			//IL_0052: 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_0061: 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_0129: 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)
			//IL_013a: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: 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_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: 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)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: 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_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: 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_0a83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_095d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0962: Unknown result type (might be due to invalid IL or missing references)
			//IL_097a: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a16: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a26: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				base.creatureAnimator.SetBool("death", true);
				base.creatureAnimator.SetFloat("turn", 0f);
				if ((Object)(object)HeadLight != (Object)null)
				{
					Light headLight = HeadLight;
					headLight.color -= Color.white * 0.5f * Time.deltaTime;
				}
				base.creatureSFX.Stop();
				return;
			}
			if (!((NetworkBehaviour)this).IsOwner)
			{
				base.inSpecialAnimation = false;
			}
			DamageOffset *= 1f - Time.deltaTime * 0.35f;
			if (boomboxInRange < 1)
			{
				CalculateAgentSpeed();
			}
			else
			{
				base.agent.speed = 0f;
				base.agent.acceleration = 0f;
			}
			float num = Mathf.Clamp(base.creatureAnimator.GetFloat("speedMultiplier") * 0.16666f, 0f, 1f);
			isCrawlTemp = Physics.Linecast(((Component)this).transform.position + ((Component)this).transform.forward * num * 1f + Vector3.up * 0.15f, ((Component)this).transform.position + ((Component)this).transform.forward * num * 1f + Vector3.up * 5.2f, StartOfRound.Instance.collidersAndRoomMask);
			if (isCrawlTemp)
			{
				crawlingWaitTime = Time.fixedTime + 2f;
				isCrawling = true;
			}
			else
			{
				isCrawling = !(Time.fixedTime > crawlingWaitTime);
			}
			base.creatureAnimator.SetBool("crawling", isCrawling);
			base.creatureAnimator.SetBool("left_arm_crawl", Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.15f, ((Component)this).transform.position + Vector3.up * 0.15f + ((Component)this).transform.right * -4f, StartOfRound.Instance.collidersAndRoomMask));
			base.creatureAnimator.SetBool("right_arm_crawl", Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.15f, ((Component)this).transform.position + Vector3.up * 0.15f + ((Component)this).transform.right * 4f, StartOfRound.Instance.collidersAndRoomMask));
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(((Component)this).transform.position + Vector3.up * 1.5f, ((Component)this).transform.up * -1f, ref val, float.PositiveInfinity, StartOfRound.Instance.collidersAndRoomMask))
			{
				slope = new Vector3(((RaycastHit)(ref val)).normal.x, 0f, ((RaycastHit)(ref val)).normal.z);
				base.creatureAnimator.SetFloat("updown", Mathf.Clamp((slope.x + slope.z) * 2f, -1f, 1f));
				base.creatureAnimator.SetLayerWeight(3, Mathf.Clamp(Mathf.Abs((slope.x + slope.z) * 2f), 0f, 1f));
			}
			base.creatureSFX.pitch = Mathf.Clamp(num * 3f, 0f, 1f);
			base.creatureSFX.volume = Mathf.Clamp(num * 4f, 0f, 1f);
			timeSinceHittingPlayer += Time.deltaTime;
			if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.25f, 80f, 25, 5f))
			{
				if (base.currentBehaviourStateIndex == 1)
				{
					GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(0.1f, 1f);
				}
				else
				{
					GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(0.1f, 0.01f);
				}
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if ((Object)(object)HeadLight != (Object)null)
				{
					HeadLight.color = Color.white * (1f - Mathf.Abs(DamageOffset * 0.95f));
				}
				if (boomboxInRange >= 1)
				{
					break;
				}
				if (hasEnteredChaseMode)
				{
					hasEnteredChaseMode = false;
					searchForPlayers.searchWidth = 50f;
					beginningChasingThisClient = false;
					noticePlayerTimer = 0f;
					base.useSecondaryAudiosOnAnimatedObjects = false;
					base.openDoorSpeedMultiplier = 1.5f;
					base.agent.stoppingDistance = 0f;
					base.agent.speed = 5f;
				}
				if (checkLineOfSightInterval <= 0.05f)
				{
					checkLineOfSightInterval += Time.deltaTime;
					break;
				}
				checkLineOfSightInterval = 0f;
				PlayerControllerB val4;
				if ((Object)(object)base.stunnedByPlayer != (Object)null)
				{
					val4 = base.stunnedByPlayer;
					noticePlayerTimer = 1f;
				}
				else
				{
					val4 = ((EnemyAI)this).CheckLineOfSightForPlayer(55f, 60, -1);
				}
				if ((Object)(object)val4 == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					noticePlayerTimer = Mathf.Clamp(noticePlayerTimer + 0.05f, 0f, 10f);
					if (noticePlayerTimer > 0.2f && !beginningChasingThisClient)
					{
						beginningChasingThisClient = true;
						BeginChasingPlayerServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
						((EnemyAI)this).ChangeOwnershipOfEnemy(val4.actualClientId);
						Debug.Log((object)"Sentinel: Begin chasing on local client");
					}
				}
				else
				{
					noticePlayerTimer -= Time.deltaTime;
				}
				break;
			}
			case 1:
				if (boomboxInRange < 1)
				{
					if ((Object)(object)HeadLight != (Object)null)
					{
						HeadLight.color = Color.red * (1f - Mathf.Abs(DamageOffset * 0.95f));
					}
					if (!hasEnteredChaseMode)
					{
						hasEnteredChaseMode = true;
						lostPlayerInChase = false;
						checkLineOfSightInterval = 0f;
						noticePlayerTimer = 0f;
						beginningChasingThisClient = false;
						base.useSecondaryAudiosOnAnimatedObjects = true;
						base.openDoorSpeedMultiplier = 2f;
						base.agent.stoppingDistance = 0.5f;
						base.agent.speed = 0f;
					}
					if (!((NetworkBehaviour)this).IsOwner || base.stunNormalizedTimer > 0f)
					{
						break;
					}
					if (checkLineOfSightInterval <= 0.075f)
					{
						checkLineOfSightInterval += Time.deltaTime;
						break;
					}
					checkLineOfSightInterval = 0f;
					if (lostPlayerInChase)
					{
						PlayerControllerB val2 = ((EnemyAI)this).CheckLineOfSightForPlayer(55f, 60, -1);
						if (Object.op_Implicit((Object)(object)val2))
						{
							noticePlayerTimer = 0f;
							lostPlayerInChase = false;
							MakeBeepNoiseServerRpc();
							if ((Object)(object)val2 != (Object)(object)base.targetPlayer)
							{
								((EnemyAI)this).SetMovingTowardsTargetPlayer(val2);
								((EnemyAI)this).ChangeOwnershipOfEnemy(val2.actualClientId);
							}
						}
						else
						{
							noticePlayerTimer -= 0.075f;
							if (noticePlayerTimer < -15f)
							{
								((EnemyAI)this).SwitchToBehaviourState(0);
							}
						}
						break;
					}
					PlayerControllerB val3 = ((EnemyAI)this).CheckLineOfSightForPlayer(65f, 80, -1);
					if ((Object)(object)val3 != (Object)null)
					{
						noticePlayerTimer = 0f;
						lastPositionOfSeenPlayer = ((Component)val3).transform.position;
						if ((Object)(object)val3 != (Object)(object)base.targetPlayer)
						{
							base.targetPlayer = val3;
							((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
						}
					}
					else
					{
						noticePlayerTimer += 0.075f;
						if (noticePlayerTimer > 1.8f)
						{
							lostPlayerInChase = true;
						}
					}
					if ((Object)(object)base.targetPlayer != (Object)null)
					{
						Vector3 localEulerAngles = Torso.transform.localEulerAngles;
						Torso.transform.LookAt(((Component)base.targetPlayer).transform, Vector3.up);
						if (Mathf.Abs(DamageOffset) > 0.3f)
						{
							targetPoint = new Vector3(DamageOffset * 45f - 90f, 0f, 0f);
						}
						else
						{
							targetPoint = new Vector3(targetPoint.x + (Torso.transform.localEulerAngles.y - targetPoint.x) * 0.99f * (Time.deltaTime * lockOnSpeed), 0f, 0f);
						}
						Torso.transform.localEulerAngles = localEulerAngles;
						base.creatureAnimator.SetFloat("turn", Mathf.Clamp(targetPoint.x * 0.011111f + DamageOffset, -1f, 1f));
					}
				}
				else if ((Object)(object)HeadLight != (Object)null)
				{
					HeadLight.color = Color.white * (1f - Mathf.Abs(DamageOffset * 0.95f));
				}
				break;
			}
			if (boomboxInRange > 0)
			{
				base.creatureAnimator.SetBool("dancing", true);
				if (boomboxInRange > 1)
				{
					base.creatureAnimator.SetBool("breakdance", true);
				}
			}
			else
			{
				base.creatureAnimator.SetBool("dancing", false);
				base.creatureAnimator.SetBool("breakdance", false);
			}
		}

		public void LateUpdate()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!base.isEnemyDead && boomboxInRange < 1 && base.currentBehaviourStateIndex == 1 && (Object)(object)base.targetPlayer != (Object)null)
			{
				Torso.transform.localEulerAngles = new Vector3(Torso.transform.localEulerAngles.x, targetPoint.x + 180f, Torso.transform.localEulerAngles.z);
				TryShoot();
			}
		}

		public void TryShoot()
		{
			//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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: 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_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.fixedTime > shootCycle))
			{
				return;
			}
			shootCycle = Time.fixedTime + 0.15f;
			cycleToDo = !cycleToDo;
			base.creatureSFX.PlayOneShot(gunShotSFX, 0.95f);
			Vector2 val = Vector2.op_Implicit(new Vector3(Random.Range(0.03f, -0.03f), Random.Range(0.03f, -0.03f)));
			if (cycleToDo)
			{
				Barrel = GunFlareL;
			}
			else
			{
				Barrel = GunFlareR;
			}
			Barrel.SetActive(true);
			Barrel.GetComponent<DelayedDisable>().disableTime = Time.fixedTime + 0.05f;
			Barrel.GetComponent<ParticleSystem>().Play();
			GameObject val2 = Object.Instantiate<GameObject>(AubPiggyback.getPrefabRegistry("SentinelBulletTracer"), Barrel.transform.position + Barrel.transform.up * -2f, Quaternion.identity);
			SentinelGunTracer sentinelGunTracer = val2.AddComponent<SentinelGunTracer>();
			sentinelGunTracer.creator = this;
			sentinelGunTracer.StartPos = Barrel.transform.position + Barrel.transform.up * -2f;
			sentinelGunTracer.deleteTime = Time.fixedTime + 0.7f;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(Barrel.transform.position + Barrel.transform.up * -2f, Barrel.transform.up * 1f + Barrel.transform.forward * val.y + Barrel.transform.right * val.x, ref val3, float.PositiveInfinity, StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers))
			{
				sentinelGunTracer.EndHitPos = ((RaycastHit)(ref val3)).point;
				PlayerControllerB component = ((Component)((RaycastHit)(ref val3)).collider).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null)
				{
					timeSinceHittingPlayer = 0f;
					component.DamagePlayer(8, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
					HitPlayerServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
				}
			}
			else
			{
				sentinelGunTracer.EndHitPos = (Barrel.transform.up * 1f + Barrel.transform.forward * val.y + Barrel.transform.right * val.x) * 10f;
			}
		}

		private void CalculateAgentSpeed()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (base.stunNormalizedTimer >= 0f)
			{
				base.agent.speed = 0.1f;
				base.agent.acceleration = 200f;
				return;
			}
			base.creatureAnimator.SetFloat("speedMultiplier", Mathf.Clamp(averageVelocity / 12f * 2.5f, 0.1f, 6f));
			Vector3 val = ((Component)this).transform.position - previousPosition;
			float num = ((Vector3)(ref val)).magnitude / (Time.deltaTime / 1.4f);
			if (velocityInterval <= 0f)
			{
				previousVelocity = averageVelocity;
				velocityInterval = 0.05f;
				velocityAverageCount += 1f;
				if (velocityAverageCount > 5f)
				{
					averageVelocity += (num - averageVelocity) / 3f;
				}
				else
				{
					averageVelocity += num;
					if (velocityAverageCount == 2f)
					{
						averageVelocity /= velocityAverageCount;
					}
				}
			}
			else
			{
				velocityInterval -= Time.deltaTime;
			}
			if (((NetworkBehaviour)this).IsOwner && averageVelocity - num > Mathf.Clamp(num * 0.17f, 2f, 100f) && num > 3f && base.currentBehaviourStateIndex == 1)
			{
				if (wallCollisionSFXDebounce > 0.5f)
				{
					if (((NetworkBehaviour)this).IsServer)
					{
						CollideWithWallServerRpc();
					}
					else
					{
						CollideWithWallClientRpc();
					}
				}
				agentSpeedWithNegative *= 0.2f;
				wallCollisionSFXDebounce = 0f;
			}
			wallCollisionSFXDebounce += Time.deltaTime;
			previousPosition = ((Component)this).transform.position;
			if (base.currentBehaviourStateIndex == 0)
			{
				base.agent.speed = 6f;
				base.agent.acceleration = 26f;
			}
			else if (base.currentBehaviourStateIndex == 1)
			{
				float num2 = SpeedIncreaseRate;
				if (Time.realtimeSinceStartup - lastTimeHit < 1f)
				{
					num2 += 4.25f;
				}
				agentSpeedWithNegative += Time.deltaTime * num2;
				base.agent.speed = Mathf.Clamp(agentSpeedWithNegative, -3f, 16f);
				base.agent.acceleration = Mathf.Clamp(BaseAcceleration - averageVelocity * SpeedAccelerationEffect, 4f, 10f);
				if (base.agent.acceleration > 22f)
				{
					base.agent.angularSpeed = 800f;
					NavMeshAgent agent = base.agent;
					agent.acceleration += 20f;
				}
				else
				{
					base.agent.angularSpeed = 230f;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void CollideWithWallServerRpc()
		{
			CollideWithWallClientRpc();
		}

		[ClientRpc]
		public void CollideWithWallClientRpc()
		{
			//IL_0011: 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)
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position);
			if (num < 15f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 24f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
		}

		private void CheckForVeryClosePlayer()
		{
			//IL_0007: 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_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_0075: Unknown result type (might be due to invalid IL or missing references)
			if (Physics.OverlapSphereNonAlloc(((Component)this).transform.position, 1.5f, nearPlayerColliders, 8, (QueryTriggerInteraction)1) > 0)
			{
				PlayerControllerB component = ((Component)((Component)nearPlayerColliders[0]).transform).GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && (Object)(object)component != (Object)(object)base.targetPlayer && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.3f, ((Component)component).transform.position, StartOfRound.Instance.collidersAndRoomMask))
				{
					base.targetPlayer = component;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void BeginChasingPlayerServerRpc(int playerObjectId)
		{
			BeginChasingPlayerClientRpc(playerObjectId);
		}

		[ClientRpc]
		public void BeginChasingPlayerClientRpc(int playerObjectId)
		{
			MakeBeep();
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
			((EnemyAI)this).SetMovingTowardsTargetPlayer(StartOfRound.Instance.allPlayerScripts[playerObjectId]);
		}

		[ServerRpc(RequireOwnership = false)]
		public void MakeBeepNoiseServerRpc()
		{
			MakeBeepNoiseClientRpc();
		}

		[ClientRpc]
		public void MakeBeepNoiseClientRpc()
		{
			MakeBeep();
		}

		private void MakeBeep()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			base.creatureVoice.PlayOneShot(beepSFX);
			WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, beepSFX, 1f);
			if (Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position) < 15f)
			{
				GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.2f, true);
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
		}

		[ServerRpc(RequireOwnership = false)]
		public void HitPlayerServerRpc(int playerId)
		{
			HitPlayerClientRpc(playerId);
		}

		[ClientRpc]
		public void HitPlayerClientRpc(int playerId)
		{
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(false);
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, false, -1);
			if (!base.isEnemyDead)
			{
				base.agent.speed = 2f;
				base.enemyHP -= force;
				agentSpeedWithNegative = Random.Range(-2.8f, -2f);
				lastTimeHit = Time.realtimeSinceStartup;
				averageVelocity = 0f;
				RoundManager.PlayRandomClip(base.creatureVoice, hurtSFX, true, 1f, 0, 1000);
				DamageOffset = Random.Range(-1.5f, 1.5f);
				if (base.enemyHP <= 0 && ((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}
	}
	public class SentinelGunTracer : MonoBehaviour
	{
		public Vector3 StartPos;

		public Vector3 EndHitPos;

		public bool firing = false;

		private bool fired = false;

		public float deleteTime;

		public SentinelAI creator;

		private void FixedUpdate()
		{
			//IL_004b: 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)
			if (Time.fixedTime > deleteTime)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			if (firing)
			{
				if (!fired)
				{
					fired = true;
					((Component)this).transform.position = EndHitPos;
					((Component)this).transform.Find("bullet_impact").position = EndHitPos;
					((Component)((Component)this).transform.Find("bullet_impact")).gameObject.SetActive(true);
					((Component)((Component)this).transform.Find("bullet_impact")).gameObject.GetComponent<ParticleSystem>().Play();
					((Component)this).gameObject.GetComponent<AudioSource>().volume = 0.25f;
					((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(creator.gunBulletImpactSFX);
				}
			}
			else
			{
				firing = true;
			}
		}
	}
	public class SentinelBoomboxTrigger : MonoBehaviour
	{
		private void OnTriggerEnter(Collider collider)
		{
			if (!((Object)(object)((Component)collider).gameObject.GetComponent<BoomboxItem>() == (Object)null) && ((Component)collider).gameObject.GetComponent<BoomboxItem>().isPlayingMusic)
			{
				((Component)((Component)this).transform.parent).gameObject.GetComponent<SentinelAI>().boomboxInRange++;
				Debug.Log((object)"Sentinel started dancing to boombox audio :D");
			}
		}

		private void OnTriggerExit(Collider collider)
		{
			if (!((Object)(object)((Component)collider).gameObject.GetComponent<BoomboxItem>() == (Object)null) && ((Component)collider).gameObject.GetComponent<BoomboxItem>().isPlayingMusic)
			{
				((Component)((Component)this).transform.parent).gameObject.GetComponent<SentinelAI>().boomboxInRange--;
				Debug.Log((object)"Sentinel stopped dancing to boombox audio :(");
			}
		}
	}
	public class DelayedDisable : MonoBehaviour
	{
		public float disableTime = 0f;

		private void FixedUpdate()
		{
			if (Time.fixedTime > disableTime)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
	public class SentinelTurn : StateMachineBehaviour
	{
		public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			((Component)animator.avatarRoot).gameObject.transform.eulerAngles = new Vector3(((Component)animator.avatarRoot).gameObject.transform.eulerAngles.x, ((Component)animator.avatarRoot).gameObject.transform.eulerAngles.y, ((Component)animator.avatarRoot).gameObject.transform.eulerAngles.z * -1f);
			animator.SetBool("turn_around", false);
		}
	}
	public class SentinelTurnWeights : StateMachineBehaviour
	{
		public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
		{
			animator.SetLayerWeight(layerIndex + 1, Mathf.Abs(animator.GetFloat("turn")));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SentinelMod";

		public const string PLUGIN_NAME = "SentinelMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}