Decompiled source of AnomalousDucks v1.1.5

AnomalousDucks.dll

Decompiled 2 months ago
#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
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 AnomalousDucks.NetcodePatcher;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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: AssemblyCompany("AnomalousDucks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("duckies")]
[assembly: AssemblyFileVersion("2.1.7.0")]
[assembly: AssemblyInformationalVersion("2.1.7+46619184e748b9bf195407bcea4b161f0801657f")]
[assembly: AssemblyProduct("AnomalousDucks")]
[assembly: AssemblyTitle("AnomalousDucks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AnomalousDucks
{
	internal class FlashbangGnomeAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			PlayerFound
		}

		public Transform turnCompass;

		public Transform attackArea;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 lastKnownPlayerPos;

		private bool gotLastPos = false;

		public float stareDistance;

		public Transform cornerDetection;

		private LineRenderer line;

		private float currentChaseSpeed = 6f;

		private Random enemyRandom;

		private bool isDeadAnimationDone;

		public AudioClip gnomeTeleport;

		private float chaseTime;

		private bool startChase;

		private bool chaseStarted;

		private float teleportTimer;

		public AudioClip flashbangSound;

		private Vector3 newTeleport;

		private PlayerControllerB previousTarget;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			LogIfDebugBuild("Blue Gnome Spawned");
			stareDistance = 40f;
			line = ((Component)this).gameObject.AddComponent<LineRenderer>();
			line.widthMultiplier = 0.2f;
			timeSinceHittingLocalPlayer = 0f;
			base.creatureAnimator.SetTrigger("startWalk");
			timeSinceNewRandPos = 0f;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			base.currentBehaviourStateIndex = 0;
		}

		public override void Update()
		{
			//IL_02ef: 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_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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)
			((EnemyAI)this).Update();
			if (!chaseStarted)
			{
				teleportTimer += Time.deltaTime;
				if (teleportTimer > 45f && (Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null && RoundManager.Instance.insideAINodes.Length != 0 && 0 == 0)
				{
					bool flag = true;
					timeSinceHittingLocalPlayer = 0f;
					newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: false);
					base.serverPosition = newTeleport;
					((Component)this).transform.position = newTeleport;
					base.agent.Warp(newTeleport);
					((EnemyAI)this).SyncPositionToClients();
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					if (((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).OwnerClientId != 0)
					{
						((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					}
					teleportTimer = 0f;
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceNewRandPos += Time.deltaTime;
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			bool flag2 = false;
			if (chaseTime <= 3f)
			{
				base.agent.speed = 6f;
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
				{
					if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, base.eye.position) > 0.3f)
					{
						flag2 = true;
						chaseTime = 0f;
					}
					if (startChase != flag2)
					{
						startChase = flag2;
					}
				}
			}
			if (chaseStarted && ((NetworkBehaviour)this).IsOwner)
			{
				chaseTime += Time.deltaTime;
				base.agent.speed = 8f;
			}
			if (startChase)
			{
				if (!chaseStarted)
				{
					chaseStarted = true;
					if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 70f, 25, -1f))
					{
						chaseTime = 0f;
					}
				}
			}
			else if (chaseTime >= 6f)
			{
				chaseStarted = false;
				if (((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					base.agent.speed = 2f;
				}
			}
			else
			{
				chaseTime += Time.deltaTime;
			}
		}

		public static IEnumerator DrawPath(LineRenderer line, NavMeshAgent agent)
		{
			if (((Behaviour)agent).enabled)
			{
				yield return (object)new WaitForEndOfFrame();
				line.SetPosition(0, ((Component)agent).transform.position);
				line.positionCount = agent.path.corners.Length;
				for (int i = 1; i < agent.path.corners.Length; i++)
				{
					line.SetPosition(i, agent.path.corners[i]);
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (!((NetworkBehaviour)this).IsServer)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					break;
				}
				for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
				{
					if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 30f)
					{
						((EnemyAI)this).SwitchToBehaviourServerRpc(1);
						return;
					}
				}
				base.movingTowardsTargetPlayer = false;
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				break;
			}
			case 1:
				base.agent.speed = 0f;
				if (base.currentSearch != null)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
				}
				if (((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
				{
					if ((Object)(object)previousTarget != (Object)(object)base.targetPlayer)
					{
						previousTarget = base.targetPlayer;
						((EnemyAI)this).ChangeEnemyOwnerServerRpc(base.targetPlayer.actualClientId);
					}
					base.movingTowardsTargetPlayer = true;
				}
				else
				{
					base.agent.speed = 2f;
					((EnemyAI)this).SwitchToBehaviourServerRpc(0);
					((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				}
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
				range = senseRange;
			}
			return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			return true;
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			((Component)this).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
			StunExplosion(((Component)this).transform.position, affectAudio: true, 1f, 7.5f);
			if (RoundManager.Instance.insideAINodes.Length != 0 && 0 == 0)
			{
				((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).GetComponentInChildren<AudioSource>().PlayOneShot(flashbangSound);
				((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
				bool flag = true;
				timeSinceHittingLocalPlayer = 0f;
				newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: false);
				base.serverPosition = newTeleport;
				((Component)this).transform.position = newTeleport;
				base.agent.Warp(newTeleport);
				((EnemyAI)this).SyncPositionToClients();
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				if (((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).OwnerClientId != 0)
				{
					((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				}
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
		}

		private Vector3 GenerateTeleportLocation(Vector3 teleportposition, bool isPlayer)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_013b: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0145: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0081: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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)
			Vector3 position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
			Plugin.Logger.LogInfo((object)"Generating Teleport Location!");
			if (!isPlayer && (Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null)
			{
				while (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) <= 40f)
				{
					position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
					if (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) >= 40f)
					{
						position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
						teleportposition = position;
						return teleportposition;
					}
				}
				return teleportposition;
			}
			position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
			position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
			teleportposition = position;
			return teleportposition;
		}

		private void StunExplosion(Vector3 explosionPosition, bool affectAudio, float flashSeverityMultiplier, float enemyStunTime, float flashSeverityDistanceRolloff = 1f, bool isHeldItem = false, float addToFlashSeverity = 0f)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: 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_01d6: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = GameNetworkManager.Instance.localPlayerController;
			if (GameNetworkManager.Instance.localPlayerController.isPlayerDead && (Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)
			{
				val = GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript;
			}
			float num = Vector3.Distance(((Component)val).transform.position, explosionPosition);
			float num2 = 7f / (num * flashSeverityDistanceRolloff);
			if (Physics.Linecast(explosionPosition + Vector3.up * 0.5f, ((Component)val.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				num2 /= 13f;
			}
			else if (num < 2f)
			{
				num2 = 1f;
			}
			else if (!val.HasLineOfSightToPosition(explosionPosition, 60f, 15, 2f))
			{
				num2 = Mathf.Clamp(num2 / 3f, 0f, 1f);
			}
			num2 = Mathf.Clamp(num2 * flashSeverityMultiplier, 0f, 1f);
			if (num2 > 0.6f)
			{
				num2 += addToFlashSeverity;
			}
			HUDManager.Instance.flashFilter = num2;
			if (affectAudio)
			{
				SoundManager.Instance.earsRingingTimer = num2;
			}
			if (enemyStunTime <= 0f)
			{
				return;
			}
			Collider[] array = Physics.OverlapSphere(explosionPosition, 12f, 524288);
			if (array.Length == 0)
			{
				return;
			}
			for (int i = 0; i < array.Length; i++)
			{
				EnemyAICollisionDetect component = ((Component)array[i]).GetComponent<EnemyAICollisionDetect>();
				if (!((Object)(object)component == (Object)null))
				{
					Vector3 val2 = ((Component)component.mainScript).transform.position + Vector3.up * 0.5f;
					if (((Component)component).GetComponentInParent<FlashbangGnomeAI>().DWHasLineOfSightToPosition(explosionPosition + Vector3.up * 0.5f, 120f, 23, 7f) || (!Physics.Linecast(explosionPosition + Vector3.up * 0.5f, ((Component)component.mainScript).transform.position + Vector3.up * 0.5f, 256) && Vector3.Distance(explosionPosition, val2) < 11f))
					{
						component.mainScript.SetEnemyStunned(true, enemyStunTime, (PlayerControllerB)null);
					}
				}
			}
		}

		public bool DWHasLineOfSightToPosition(Vector3 pos, float width = 45f, int range = 30, float proximityAwareness = 7.5f)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.eye == (Object)null)
			{
				_ = ((Component)this).transform;
			}
			else
			{
				_ = base.eye;
			}
			if (Vector3.Distance(base.eye.position, pos) < (float)range && !Physics.Linecast(base.eye.position, pos, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				Vector3 val = pos - base.eye.position;
				if (Vector3.Angle(base.eye.forward, val) < width || Vector3.Distance(((Component)this).transform.position, pos) < proximityAwareness)
				{
					return true;
				}
			}
			return false;
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "FlashbangGnomeAI";
		}
	}
	internal class GnomeAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			PlayerFound
		}

		public Transform turnCompass;

		public Transform attackArea;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 lastKnownPlayerPos;

		private bool gotLastPos = false;

		public float stareDistance;

		public Transform cornerDetection;

		private LineRenderer line;

		private float currentChaseSpeed = 6f;

		private Random enemyRandom;

		private bool isDeadAnimationDone;

		public AudioClip gnomeTeleport;

		private Vector3 newTeleport;

		private Vector3 newTeleportPlayer;

		private bool stopmoving;

		private bool hasStopped;

		private bool wasOwnerLastFrame;

		private float stopAndGoMinimumInterval;

		private PlayerControllerB previousTarget;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			LogIfDebugBuild("Example Enemy Spawned");
			stareDistance = 40f;
			line = ((Component)this).gameObject.AddComponent<LineRenderer>();
			line.widthMultiplier = 0.2f;
			timeSinceHittingLocalPlayer = 0f;
			base.creatureAnimator.SetTrigger("startWalk");
			timeSinceNewRandPos = 0f;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			base.currentBehaviourStateIndex = 0;
		}

		public override void Update()
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_00ff: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: 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)
			((EnemyAI)this).Update();
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceNewRandPos += Time.deltaTime;
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (stopAndGoMinimumInterval > 0f)
			{
				stopAndGoMinimumInterval -= Time.deltaTime;
			}
			if (!wasOwnerLastFrame)
			{
				wasOwnerLastFrame = true;
				if (!stopmoving)
				{
					base.agent.speed = currentChaseSpeed;
				}
				else
				{
					base.agent.speed = 0f;
				}
			}
			bool flag = false;
			for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
			{
				if ((((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, base.eye.position) > 0.3f) || (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(cornerDetection.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, base.eye.position) > 0.3f))
				{
					flag = true;
				}
			}
			if (base.stunNormalizedTimer > 0f)
			{
				flag = true;
			}
			if (flag != stopmoving && stopAndGoMinimumInterval <= 0f)
			{
				stopAndGoMinimumInterval = 0.15f;
				stopmoving = flag;
			}
			if (stopmoving)
			{
				if (!hasStopped)
				{
					hasStopped = true;
					if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position, 70f, 25, -1f) || GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(cornerDetection.position, 70f, 25, -1f))
					{
						base.agent.speed = 0f;
					}
				}
				if (((NetworkBehaviour)this).IsOwner)
				{
					base.agent.speed = 0f;
				}
			}
			else
			{
				if (hasStopped)
				{
					hasStopped = false;
				}
				if (((NetworkBehaviour)this).IsOwner)
				{
					base.agent.speed = Mathf.Lerp(base.agent.speed, currentChaseSpeed, 4.5f * Time.deltaTime);
					((EnemyAI)this).SwitchToBehaviourServerRpc(0);
				}
			}
		}

		public static IEnumerator DrawPath(LineRenderer line, NavMeshAgent agent)
		{
			if (((Behaviour)agent).enabled)
			{
				yield return (object)new WaitForEndOfFrame();
				line.SetPosition(0, ((Component)agent).transform.position);
				line.positionCount = agent.path.corners.Length;
				for (int i = 1; i < agent.path.corners.Length; i++)
				{
					line.SetPosition(i, agent.path.corners[i]);
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (!((NetworkBehaviour)this).IsServer)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					break;
				}
				for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
				{
					if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 30f)
					{
						((EnemyAI)this).SwitchToBehaviourServerRpc(1);
						return;
					}
				}
				base.agent.speed = 6f;
				if (base.currentSearch == null)
				{
					base.movingTowardsTargetPlayer = false;
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				break;
			}
			case 1:
				if (base.currentSearch != null)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
				}
				if (((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f))
				{
					if ((Object)(object)previousTarget != (Object)(object)base.targetPlayer)
					{
						previousTarget = base.targetPlayer;
						((EnemyAI)this).ChangeEnemyOwnerServerRpc(base.targetPlayer.actualClientId);
					}
					base.movingTowardsTargetPlayer = true;
				}
				else
				{
					((EnemyAI)this).SwitchToBehaviourServerRpc(0);
					((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				}
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
				range = senseRange;
			}
			return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
		}

		private bool TargetClosestPlayerInAnyCase()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer == (Object)null)
			{
				return false;
			}
			return true;
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			if (timeSinceHittingLocalPlayer < 1f)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			((Component)this).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
			if (RoundManager.Instance.insideAINodes.Length == 0)
			{
				return;
			}
			if (0 == 0)
			{
				bool flag = true;
				newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: true);
				val.movementAudio.PlayOneShot(gnomeTeleport);
				val.averageVelocity = 0f;
				StartOfRound.Instance.allPlayerScripts[val.playerClientId].TeleportPlayer(newTeleport, false, 0f, false, true);
			}
			if (0 == 0)
			{
				((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).GetComponentInChildren<AudioSource>().PlayOneShot(gnomeTeleport);
				bool flag2 = true;
				timeSinceHittingLocalPlayer = 0f;
				newTeleport = GenerateTeleportLocation(Vector3.zero, isPlayer: false);
				base.serverPosition = newTeleport;
				((Component)this).transform.position = newTeleport;
				base.agent.Warp(newTeleport);
				((EnemyAI)this).SyncPositionToClients();
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				if (((NetworkBehaviour)this).IsOwner && ((NetworkBehaviour)this).OwnerClientId != 0)
				{
					((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				}
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
		}

		private Vector3 GenerateTeleportLocation(Vector3 teleportposition, bool isPlayer)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_0142: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
			if (!isPlayer)
			{
				while (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) <= 60f && ((EnemyAI)this).GetClosestPlayer(false, false, false).isInsideFactory)
				{
					position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
					if (Vector3.Distance(position, ((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position) >= 60f && ((EnemyAI)this).GetClosestPlayer(false, false, false).isInsideFactory)
					{
						position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
						teleportposition = position;
						return teleportposition;
					}
				}
				return teleportposition;
			}
			position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
			position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position, 10f, default(NavMeshHit));
			teleportposition = position;
			return teleportposition;
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "GnomeAI";
		}
	}
	[BepInPlugin("sconeys.AnomalousDucks", "AnomalousDucks", "2.1.7")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "sconeys.AnomalousDucks";

		internal static ManualLogSource Logger;

		public static AssetBundle ModAssets;

		private int duckyspawnrate = 100;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			loadConfig();
			InitializeNetworkBehaviours();
			string path = "anomalousducksassets";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("DuckyAI");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Utilities.FixMixerGroups(val.enemyPrefab);
			Enemies.RegisterEnemy(val, duckyspawnrate, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null);
			Logger.LogInfo((object)"Plugin AnomalousDucks is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		public int RandomNumber(int value)
		{
			Random random = new Random(StartOfRound.Instance.randomMapSeed);
			return random.Next(0, 100);
		}

		private void loadConfig()
		{
			duckyspawnrate = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DuckySpawnRate", 100, "What should the spawnrate of SCP-1356 be?").Value;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "AnomalousDucks";

		public const string PLUGIN_NAME = "AnomalousDucks";

		public const string PLUGIN_VERSION = "2.1.7";
	}
}
namespace AnomalousDucks.src
{
	internal class DefaultADuck : EnemyAI
	{
		private enum State
		{
			TeleportingToPlayer,
			PlayerFound
		}

		public Transform turnCompass;

		public Transform attackArea;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 lastKnownPlayerPos;

		private bool gotLastPos = false;

		public float stareDistance;

		public Transform cornerDetection;

		private Random enemyRandom;

		private bool isDeadAnimationDone;

		public AudioClip duckyTeleport;

		private Random random;

		private int realSeed;

		private PlayerControllerB chosenPlayer;

		private bool timerStart;

		private float timer;

		private float timerEnd;

		private Vector3 teleportlocation;

		private bool wasOwnerLastFrame;

		private bool ableToRotate;

		private PlayerControllerB previousTarget;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			SyncSeedServerRpc();
			base.agent.speed = 0f;
			LogIfDebugBuild("Duck Spawned");
			realSeed = StartOfRound.Instance.randomMapSeed;
			random = new Random(realSeed);
			timeSinceHittingLocalPlayer = 0f;
			base.creatureAnimator.SetTrigger("startWalk");
			timeSinceNewRandPos = 0f;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			base.currentBehaviourStateIndex = 0;
		}

		public override void Update()
		{
			//IL_00b6: 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_00f0: 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)
			((EnemyAI)this).Update();
			if (timerStart)
			{
				timer += Time.deltaTime;
			}
			if (timer > timerEnd && ((NetworkBehaviour)this).IsHost)
			{
				TeleportDuckyServerRpc();
			}
			if (!((NetworkBehaviour)this).IsOwner || !((Object)(object)chosenPlayer != (Object)null))
			{
				return;
			}
			if (!wasOwnerLastFrame)
			{
				wasOwnerLastFrame = true;
			}
			bool flag = false;
			for (int i = 0; i < GameNetworkManager.Instance.maxAllowedPlayers; i++)
			{
				if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, base.eye.position) > 0.3f)
				{
					flag = true;
				}
			}
			if (flag != ableToRotate)
			{
				ableToRotate = flag;
			}
			if (!ableToRotate)
			{
				if (ableToRotate)
				{
					ableToRotate = false;
				}
				if (((NetworkBehaviour)this).IsOwner && (Object)(object)((EnemyAI)this).GetClosestPlayer(false, false, false) != (Object)null)
				{
					((Component)this).transform.LookAt(((Component)((EnemyAI)this).GetClosestPlayer(false, false, false)).transform.position);
				}
			}
		}

		[ServerRpc]
		private void TeleportDuckyServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0158: 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_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2333165593u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2333165593u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || !((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			SyncSeedServerRpc();
			int num = random.Next(0, StartOfRound.Instance.allPlayerScripts.Length);
			chosenPlayer = StartOfRound.Instance.allPlayerScripts[num];
			for (int i = 0; i < RoundManager.Instance.insideAINodes.Length; i++)
			{
				if (Vector3.Distance(RoundManager.Instance.insideAINodes[i].transform.position, ((Component)chosenPlayer).transform.position) < 10f && chosenPlayer.isInsideFactory)
				{
					teleportlocation = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(((Component)chosenPlayer).transform.position, 10f, default(NavMeshHit));
				}
			}
			TeleportDuckyClientRpc(num, teleportlocation);
		}

		[ClientRpc]
		private void TeleportDuckyClientRpc(int randomPlayer, Vector3 teleportLoc)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2094056816u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, randomPlayer);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref teleportLoc);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2094056816u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			chosenPlayer = StartOfRound.Instance.allPlayerScripts[randomPlayer];
			Plugin.Logger.LogInfo((object)("Chosen Player:" + (object)chosenPlayer));
			if (!((Object)(object)chosenPlayer == (Object)null))
			{
				Plugin.Logger.LogInfo((object)teleportLoc);
				if (chosenPlayer.isInsideFactory)
				{
					((Component)this).GetComponentInChildren<AudioSource>().PlayOneShot(duckyTeleport);
					base.serverPosition = teleportLoc;
					((Component)this).transform.position = teleportLoc;
					base.agent.Warp(teleportLoc);
					((EnemyAI)this).SyncPositionToClients();
					Plugin.Logger.LogInfo((object)("Ducky Teleported! Target: " + (object)chosenPlayer));
					TimerServerRpc();
					((EnemyAI)this).SwitchToBehaviourServerRpc(1);
				}
				else
				{
					Plugin.Logger.LogInfo((object)$"Could not teleport to player: {chosenPlayer}, are they outside?");
					TimerServerRpc();
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				((EnemyAI)this).ChangeEnemyOwnerServerRpc(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				if (!timerStart)
				{
					TimerServerRpc();
				}
				break;
			case 1:
				timerStart = false;
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				if (Vector3.Distance(((Component)chosenPlayer).transform.position, ((Component)this).transform.position) > 25f && !timerStart)
				{
					((EnemyAI)this).SwitchToBehaviourServerRpc(0);
				}
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		[ServerRpc]
		private void TimerServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1599205276u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1599205276u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncSeedServerRpc();
				if (((NetworkBehaviour)this).IsHost)
				{
					timerEnd = random.Next(30, 190);
					TimerClientRpc(timerEnd);
				}
			}
		}

		[ClientRpc]
		private void TimerClientRpc(float randomNumber)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2012931513u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref randomNumber, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2012931513u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (!timerStart)
				{
					timerEnd = randomNumber;
					timerStart = true;
					timer = 0f;
					Plugin.Logger.LogInfo((object)("Timer End: " + timerEnd));
				}
				else
				{
					timerStart = false;
					timer = 0f;
				}
			}
		}

		[ServerRpc]
		private void SyncSeedServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(688727343u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 688727343u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviour)this).IsHost)
			{
				realSeed++;
				SyncSeedClientRpc(realSeed);
			}
		}

		[ClientRpc]
		private void SyncSeedClientRpc(int currentseed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3941998498u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, currentseed);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3941998498u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					realSeed = currentseed;
					random = new Random(realSeed);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_DefaultADuck()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2333165593u, new RpcReceiveHandler(__rpc_handler_2333165593));
			NetworkManager.__rpc_func_table.Add(2094056816u, new RpcReceiveHandler(__rpc_handler_2094056816));
			NetworkManager.__rpc_func_table.Add(1599205276u, new RpcReceiveHandler(__rpc_handler_1599205276));
			NetworkManager.__rpc_func_table.Add(2012931513u, new RpcReceiveHandler(__rpc_handler_2012931513));
			NetworkManager.__rpc_func_table.Add(688727343u, new RpcReceiveHandler(__rpc_handler_688727343));
			NetworkManager.__rpc_func_table.Add(3941998498u, new RpcReceiveHandler(__rpc_handler_3941998498));
		}

		private static void __rpc_handler_2333165593(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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_008c: 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_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DefaultADuck)(object)target).TeleportDuckyServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2094056816(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int randomPlayer = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref randomPlayer);
				Vector3 teleportLoc = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref teleportLoc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DefaultADuck)(object)target).TeleportDuckyClientRpc(randomPlayer, teleportLoc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1599205276(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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_008c: 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_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DefaultADuck)(object)target).TimerServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2012931513(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float randomNumber = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref randomNumber, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DefaultADuck)(object)target).TimerClientRpc(randomNumber);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_688727343(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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_008c: 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_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DefaultADuck)(object)target).SyncSeedServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3941998498(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int currentseed = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref currentseed);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DefaultADuck)(object)target).SyncSeedClientRpc(currentseed);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "DefaultADuck";
		}
	}
}
namespace AnomalousDucks.Configuration
{
	public class PluginConfig
	{
		private void ClearUnusedEntries(BaseUnityPlugin plugin)
		{
			PropertyInfo property = ((object)plugin.Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(plugin.Config, null);
			dictionary.Clear();
			plugin.Config.Save();
		}
	}
}
namespace AnomalousDucks.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}