Decompiled source of Anderdingus v1.0.5

Yebeka.Anderdingus.dll

Decompiled 2 weeks ago
#define DEBUG
using System;
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 Anderdingus.Configuration;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using Yebeka.Anderdingus.NetcodePatcher;

[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("Yebeka.Anderdingus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4c7b90c70da44bbcc93498a78a4b77abd680d808")]
[assembly: AssemblyProduct("Anderdingus")]
[assembly: AssemblyTitle("Yebeka.Anderdingus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 Anderdingus
{
	public class AnderdingusAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			ChasingPlayer,
			InvestigatingLastSeen,
			TempState,
			MovingToInvestigate
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		public AudioClip hauntSFX = null;

		public AudioClip spotPlayerSFX = null;

		private float timeSinceHittingLocalPlayer;

		private Random enemyRandom = null;

		private bool isDeadAnimationDone;

		private Vector3 lastSeenPlayerPos;

		private float timeSinceSeeingPlayer;

		private float timeSinceLastNoise;

		private float chaseVoiceTimer;

		private float syncTargetTimer;

		private float timeInSearchState;

		private float timeInChase;

		private float timeInTempState;

		private Vector3 investigateLookPoint;

		private float investigateLookTimer;

		private PlayerControllerB? hauntedPlayer;

		private float hauntTimer;

		private float nextHauntInterval;

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

		public override void Start()
		{
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			LogIfDebugBuild("[BEHAVIOR DEBUG] Anderdingus Spawned & Start() Called");
			timeSinceHittingLocalPlayer = 0f;
			base.creatureAnimator.SetTrigger("startWalk");
			timeSinceSeeingPlayer = 0f;
			timeSinceLastNoise = 2f;
			timeInSearchState = 0f;
			timeInChase = 0f;
			timeInTempState = 0f;
			investigateLookTimer = 0f;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			EnemyAICollisionDetect[] componentsInChildren = ((Component)this).GetComponentsInChildren<EnemyAICollisionDetect>();
			foreach (EnemyAICollisionDetect val in componentsInChildren)
			{
				if ((Object)(object)val.mainScript == (Object)null)
				{
					val.mainScript = (EnemyAI)(object)this;
				}
			}
			if (base.openDoorSpeedMultiplier <= 0f)
			{
				base.openDoorSpeedMultiplier = 2f;
			}
			isDeadAnimationDone = false;
			chaseVoiceTimer = 3f;
			base.currentBehaviourStateIndex = 0;
			if (((NetworkBehaviour)this).IsOwner)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				int maxValue = StartOfRound.Instance.connectedPlayersAmount + 1;
				int num = enemyRandom.Next(0, maxValue);
				hauntedPlayer = StartOfRound.Instance.allPlayerScripts[num];
				hauntTimer = 0f;
				nextHauntInterval = (float)enemyRandom.NextDouble() * 30f + 30f;
			}
		}

		public override void Update()
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: 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_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: 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_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: 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_017e: 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_01f9: 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_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				return;
			}
			timeSinceHittingLocalPlayer += Time.deltaTime;
			timeSinceLastNoise += Time.deltaTime;
			if (base.currentBehaviourStateIndex == 1 || base.currentBehaviourStateIndex == 2)
			{
				timeSinceSeeingPlayer += Time.deltaTime;
			}
			ManageHaunting();
			if (base.stunNormalizedTimer <= 0f)
			{
				Vector3 val;
				switch (base.currentBehaviourStateIndex)
				{
				case 1:
					if (timeSinceSeeingPlayer <= 1f)
					{
						base.agent.updateRotation = false;
						if (!((Object)(object)base.targetPlayer != (Object)null))
						{
							break;
						}
						Vector3 val2 = ((Component)base.targetPlayer).transform.position + Vector3.up * 1.5f;
						if ((Object)(object)base.targetPlayer.gameplayCamera != (Object)null && (Object)(object)((Component)base.targetPlayer.gameplayCamera).transform != (Object)null)
						{
							val2 = ((Component)base.targetPlayer.gameplayCamera).transform.position;
						}
						if ((Object)(object)turnCompass != (Object)null)
						{
							turnCompass.LookAt(val2);
							((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 8f * Time.deltaTime);
							break;
						}
						val = val2 - ((Component)this).transform.position;
						Vector3 normalized2 = ((Vector3)(ref val)).normalized;
						normalized2.y = 0f;
						if (normalized2 != Vector3.zero)
						{
							((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.LookRotation(normalized2), 8f * Time.deltaTime);
						}
					}
					else
					{
						base.agent.updateRotation = true;
					}
					break;
				case 2:
				{
					base.agent.updateRotation = false;
					investigateLookTimer -= Time.deltaTime;
					if (((NetworkBehaviour)this).IsOwner && investigateLookTimer <= 0f)
					{
						investigateLookTimer = 0.5f + (float)enemyRandom.NextDouble();
						investigateLookPoint = ((Component)this).transform.position + new Vector3((float)enemyRandom.NextDouble() * 10f - 5f, 0f, (float)enemyRandom.NextDouble() * 10f - 5f);
						SyncInvestigatePointClientRpc(investigateLookPoint, investigateLookTimer);
					}
					val = investigateLookPoint - ((Component)this).transform.position;
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					normalized.y = 0f;
					if (normalized != Vector3.zero)
					{
						((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.LookRotation(normalized), 5f * Time.deltaTime);
					}
					break;
				}
				default:
					base.agent.updateRotation = true;
					break;
				}
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
		}

		private void ManageHaunting()
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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)
			if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && (Object)(object)hauntedPlayer != (Object)null && !hauntedPlayer.isPlayerDead && hauntedPlayer.isInsideFactory)
			{
				hauntTimer += Time.deltaTime;
				if (hauntTimer >= nextHauntInterval)
				{
					hauntTimer = 0f;
					nextHauntInterval = (float)enemyRandom.NextDouble() * 15f + 45f;
					float num = (float)enemyRandom.NextDouble() * 5f + 10f;
					float num2 = (float)enemyRandom.NextDouble() * MathF.PI * 2f;
					Vector3 val = new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * num;
					Vector3 position = ((Component)hauntedPlayer).transform.position + val;
					PlayHauntSoundClientRpc(position);
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: 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_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0803: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_065a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: 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_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || !((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			bool flag = base.currentBehaviourStateIndex == 1;
			base.agent.autoBraking = !flag;
			base.agent.stoppingDistance = (flag ? 0f : 1f);
			base.movingTowardsTargetPlayer = flag;
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 3.5f;
				timeInSearchState += base.AIIntervalTime;
				if (FoundClosestPlayerInRange(25f, 2f))
				{
					timeInSearchState = 0f;
					timeInChase = 0f;
					chaseVoiceTimer = 3f;
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					PlaySpotSoundClientRpc();
					UpdateTargetClientRpc((int)base.targetPlayer.playerClientId, ((Component)base.targetPlayer).transform.position);
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(1);
				}
				break;
			case 1:
			{
				timeInChase += base.AIIntervalTime;
				chaseVoiceTimer -= base.AIIntervalTime;
				if (chaseVoiceTimer <= 0f)
				{
					chaseVoiceTimer = 3f + (float)enemyRandom.NextDouble() * 3f;
					PlayVoiceLineClientRpc();
				}
				base.agent.speed = Mathf.Clamp(5f + timeInChase * 0.35f, 8f, 13f);
				if ((Object)(object)base.targetPlayer == (Object)null)
				{
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(0);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					break;
				}
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position);
				if (num > 100f)
				{
					timeInTempState = 0f;
					investigateLookTimer = 0f;
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(3);
					break;
				}
				Vector3 val2;
				if (num <= 2.5f)
				{
					val2 = ((Component)base.targetPlayer).transform.position;
					base.agent.Warp(((Component)base.targetPlayer).transform.position);
				}
				else
				{
					Vector3 val3 = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
					Vector3 normalized = ((Vector3)(ref val3)).normalized;
					val2 = ((Component)base.targetPlayer).transform.position + normalized * 2f;
				}
				if (((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, 90f, 40, -1f, (Transform)null))
				{
					syncTargetTimer += base.AIIntervalTime;
					if (timeSinceSeeingPlayer > 0.5f || syncTargetTimer > 0.5f)
					{
						syncTargetTimer = 0f;
						UpdateTargetClientRpc((int)base.targetPlayer.playerClientId, ((Component)base.targetPlayer).transform.position);
					}
					else
					{
						timeSinceSeeingPlayer = 0f;
						lastSeenPlayerPos = ((Component)base.targetPlayer).transform.position;
					}
					((EnemyAI)this).SetDestinationToPosition(val2, false);
				}
				else if (timeSinceSeeingPlayer <= 2f)
				{
					lastSeenPlayerPos = ((Component)base.targetPlayer).transform.position;
					((EnemyAI)this).SetDestinationToPosition(val2, false);
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(lastSeenPlayerPos, false);
					if (Vector3.Distance(((Component)this).transform.position, lastSeenPlayerPos) < 1.5f || Vector3.Distance(((Component)this).transform.position, base.agent.destination) < 0.5f)
					{
						investigateLookTimer = 0f;
						timeInTempState = 4f + (float)enemyRandom.NextDouble() * 6f;
						PlayVoiceLineClientRpc();
						((EnemyAI)this).SwitchToBehaviourState(2);
					}
				}
				break;
			}
			case 2:
				base.agent.speed = 0f;
				timeInTempState -= base.AIIntervalTime;
				if ((Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, 90f, 40, -1f, (Transform)null))
				{
					UpdateTargetClientRpc((int)base.targetPlayer.playerClientId, ((Component)base.targetPlayer).transform.position);
					chaseVoiceTimer = 3f;
					timeInTempState = 0f;
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(1);
				}
				else if (timeInTempState <= 0f)
				{
					timeInTempState = 0f;
					investigateLookTimer = 0f;
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(3);
				}
				break;
			case 3:
				base.agent.speed = 6f;
				timeInTempState += base.AIIntervalTime;
				if ((Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, 50f, 40, -1f, (Transform)null))
				{
					UpdateTargetClientRpc((int)base.targetPlayer.playerClientId, ((Component)base.targetPlayer).transform.position);
					timeInChase = 0f;
					chaseVoiceTimer = 3f;
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(1);
					break;
				}
				if (Vector3.Distance(((Component)this).transform.position, base.agent.destination) < 1.5f || investigateLookTimer <= 0f)
				{
					investigateLookTimer = 2.5f;
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor((float)enemyRandom.NextDouble() * 30f - 15f, 0f, (float)enemyRandom.NextDouble() * 30f - 15f);
					((EnemyAI)this).SetDestinationToPosition(lastSeenPlayerPos + val, false);
				}
				else
				{
					investigateLookTimer -= base.AIIntervalTime;
				}
				if (timeInTempState > 12f)
				{
					timeInSearchState = 0f;
					timeInTempState = 0f;
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(0);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				break;
			case 4:
				base.agent.speed = 4.5f;
				if (FoundClosestPlayerInRange(25f, 2f))
				{
					timeInChase = 0f;
					chaseVoiceTimer = 3f;
					UpdateTargetClientRpc((int)base.targetPlayer.playerClientId, ((Component)base.targetPlayer).transform.position);
					PlaySpotSoundClientRpc();
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(1);
					break;
				}
				((EnemyAI)this).SetDestinationToPosition(lastSeenPlayerPos, false);
				if (Vector3.Distance(((Component)this).transform.position, lastSeenPlayerPos) < 1.5f || Vector3.Distance(((Component)this).transform.position, base.agent.destination) < 0.5f)
				{
					investigateLookTimer = 0f;
					timeInTempState = 4f + (float)enemyRandom.NextDouble() * 6f;
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(2);
				}
				break;
			}
		}

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

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_004c: 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)
			if (!(timeSinceHittingLocalPlayer < 1f) && base.currentBehaviourStateIndex != 3)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					timeSinceHittingLocalPlayer = 0f;
					val.DamagePlayer(35, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
			if (base.isEnemyDead || base.stunNormalizedTimer > 0f || !((NetworkBehaviour)this).IsOwner || timeSinceLastNoise < 1.5f || noiseLoudness < 0.25f || (base.currentBehaviourStateIndex != 0 && base.currentBehaviourStateIndex != 3 && base.currentBehaviourStateIndex != 2))
			{
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, noisePosition);
			float num2 = 20f * noiseLoudness;
			bool flag = Physics.Linecast(((Component)this).transform.position, noisePosition, 256);
			if (base.currentBehaviourStateIndex == 2)
			{
				num2 = Mathf.Max(num2 * 2f, 25f);
				if (flag && num > 25f)
				{
					num2 /= 2f;
				}
			}
			else if (flag)
			{
				num2 /= 2f;
			}
			else if (num < 10f)
			{
				num2 = Mathf.Max(num2, 10f);
			}
			if (num < num2)
			{
				timeSinceLastNoise = 0f;
				if (base.currentBehaviourStateIndex == 0)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
				}
				lastSeenPlayerPos = noisePosition;
				if (base.currentBehaviourStateIndex != 4 && base.currentBehaviourStateIndex != 2)
				{
					PlayVoiceLineClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(4);
				}
				else if (base.currentBehaviourStateIndex == 2)
				{
					((EnemyAI)this).SwitchToBehaviourState(4);
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(lastSeenPlayerPos, false);
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (!base.isEnemyDead)
			{
			}
		}

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

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3301273424u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3301273424u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void PlayHauntSoundClientRpc(Vector3 position)
		{
			//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_0089: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(943223559u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 943223559u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (!((Object)(object)hauntSFX == (Object)null))
				{
					GameObject val3 = new GameObject("AnderdingusHauntAudio");
					val3.transform.position = position;
					AudioSource val4 = val3.AddComponent<AudioSource>();
					val4.clip = hauntSFX;
					val4.spatialBlend = 1f;
					val4.rolloffMode = (AudioRolloffMode)1;
					val4.minDistance = 5f;
					val4.maxDistance = 30f;
					val4.dopplerLevel = 0f;
					val4.Play();
					Object.Destroy((Object)(object)val3, hauntSFX.length + 0.1f);
				}
			}
		}

		[ClientRpc]
		public void UpdateTargetClientRpc(int playerId, Vector3 lastSeenPos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3017976578u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref lastSeenPos);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3017976578u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[playerId];
					timeSinceSeeingPlayer = 0f;
					lastSeenPlayerPos = lastSeenPos;
				}
			}
		}

		[ClientRpc]
		public void SyncInvestigatePointClientRpc(Vector3 lookPoint, float time)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1190953912u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref lookPoint);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref time, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1190953912u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					investigateLookPoint = lookPoint;
					investigateLookTimer = time;
				}
			}
		}

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

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3880278754u, new RpcReceiveHandler(__rpc_handler_3880278754), "PlaySpotSoundClientRpc");
			((NetworkBehaviour)this).__registerRpc(3301273424u, new RpcReceiveHandler(__rpc_handler_3301273424), "DoAnimationClientRpc");
			((NetworkBehaviour)this).__registerRpc(943223559u, new RpcReceiveHandler(__rpc_handler_943223559), "PlayHauntSoundClientRpc");
			((NetworkBehaviour)this).__registerRpc(3017976578u, new RpcReceiveHandler(__rpc_handler_3017976578), "UpdateTargetClientRpc");
			((NetworkBehaviour)this).__registerRpc(1190953912u, new RpcReceiveHandler(__rpc_handler_1190953912), "SyncInvestigatePointClientRpc");
			((NetworkBehaviour)this).__registerRpc(3146437861u, new RpcReceiveHandler(__rpc_handler_3146437861), "PlayVoiceLineClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

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

		private static void __rpc_handler_3301273424(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_0061: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AnderdingusAI)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_943223559(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AnderdingusAI)(object)target).PlayHauntSoundClientRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3017976578(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 playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				Vector3 lastSeenPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref lastSeenPos);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AnderdingusAI)(object)target).UpdateTargetClientRpc(playerId, lastSeenPos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1190953912(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 lookPoint = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref lookPoint);
				float time = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref time, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AnderdingusAI)(object)target).SyncInvestigatePointClientRpc(lookPoint, time);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "AnderdingusAI";
		}
	}
	[BepInPlugin("Yebeka.Anderdingus", "Anderdingus", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "modassets";
			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>("AnderdingusObj");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("AnderdingusTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("AnderdingusTK");
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
			{
				Logger.LogError((object)"Failed to load EnemyType or Terminal assets.");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, val3);
			Logger.LogInfo((object)"Plugin Yebeka.Anderdingus 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 static class PluginInfo
	{
		public const string PLUGIN_GUID = "Yebeka.Anderdingus";

		public const string PLUGIN_NAME = "Anderdingus";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Anderdingus.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 20, "The spawn chance weight for Anderdingus, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace Yebeka.Anderdingus.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}