Decompiled source of CancerousRodent v1.0.4

NightFormula.CancerousRodent.dll

Decompiled 3 weeks 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CancerousRodent.Configuration;
using CancerousRodent.src;
using CancerousRodent.src.patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using NightFormula.CancerousRodent.NetcodePatcher;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[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("NightFormula.CancerousRodent")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+0864a05544691c96bb0f101813317f1ce77b7629")]
[assembly: AssemblyProduct("CancerousRodent")]
[assembly: AssemblyTitle("NightFormula.CancerousRodent")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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.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 CancerousRodent
{
	internal class CancerousRodentAI : EnemyAI
	{
		private enum State
		{
			SearchingForPlayer,
			ChasingPlayer
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		public GameObject audioSourceObject = null;

		public Light? cancerLight = null;

		private AudioSource? audioSource;

		private static readonly string hi = "thanks for de-compiling my code, Stranger, that's super cool of you!!! :3";

		public PlayerControllerB lastPlayerHitBy = null;

		private bool seenAPlayerBefore = false;

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

		public override void Start()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			LogIfDebugBuild("Cancerous rodent Spawned");
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			if ((Object)(object)audioSourceObject != (Object)null)
			{
				audioSource = audioSourceObject.GetComponent<AudioSource>();
				if ((Object)(object)audioSource == (Object)null)
				{
					LogIfDebugBuild("AudioSource component not found on the specified GameObject!");
				}
				else
				{
					audioSource.loop = true;
				}
			}
			else
			{
				LogIfDebugBuild("AudioSourceObject is not set!");
			}
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if ((Object)(object)audioSource != (Object)null && audioSource.isPlaying)
				{
					audioSource.Stop();
				}
				if ((Object)(object)cancerLight != (Object)null)
				{
					((Behaviour)cancerLight).enabled = false;
					cancerLight = null;
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 13f;
				if (FoundClosestPlayerInRange(65f, 10f))
				{
					LogIfDebugBuild("Start Target Player");
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					if (!seenAPlayerBefore)
					{
						seenAPlayerBefore = true;
						StartBossbarClientRpc();
					}
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					PlayAudioClientRpc();
				}
				break;
			case 1:
				base.agent.speed = 0.7f;
				if (!TargetClosestPlayerInAnyCase() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 35f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
				{
					LogIfDebugBuild("Stop Target Player");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					StopAudioClientRpc();
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				}
				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)
		{
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				LogIfDebugBuild("Cancerous Rodent Collision with Player!");
				val.drunkness += 0.1f;
			}
		}

		[ClientRpc]
		public void StartBossbarClientRpc()
		{
			//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)
			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(1284136319u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1284136319u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					EnemyHealthBarHandler.Instance.SetupForEnemy((EnemyAI)(object)this, "CANCEROUS RODENT", 1, 1);
				}
			}
		}

		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)
			{
				base.enemyHP -= force;
				if ((Object)(object)playerWhoHit != (Object)null)
				{
					lastPlayerHitBy = playerWhoHit;
				}
				if (!base.isEnemyDead && base.enemyHP <= 0)
				{
					EnemyHealthBarHandler.Instance.RequestStopFor((EnemyAI)(object)this);
				}
				if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
				{
					StopAudioClientRpc();
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
					((MonoBehaviour)this).StartCoroutine(DelayedDestroy());
				}
			}
		}

		private IEnumerator DelayedDestroy()
		{
			yield return (object)new WaitForSeconds(0.05f);
			((EnemyAI)this).KillEnemyOnOwnerClient(false);
			RoundManager.Instance.SpawnEnemyGameObject(((Component)this).transform.position, ((Component)this).transform.rotation.y, RoundManager.Instance.SpawnedEnemies.Count + 1, Plugin.ModAssets.LoadAsset<EnemyType>("VeryCancerousRodent"));
			VeryCancerousRodentAI[] bigGuys = Object.FindObjectsOfType<VeryCancerousRodentAI>();
			VeryCancerousRodentAI[] array = bigGuys;
			foreach (VeryCancerousRodentAI guy in array)
			{
				guy.grudgePlayer = lastPlayerHitBy;
			}
		}

		[ClientRpc]
		public void PlayAudioClientRpc()
		{
			//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)
			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(3458437415u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3458437415u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)audioSource != (Object)null)
			{
				audioSource.volume = Plugin.BoundConfig.MusicVolume.Value;
				if (!audioSource.isPlaying)
				{
					audioSource.Play();
				}
			}
		}

		[ClientRpc]
		public void StopAudioClientRpc()
		{
			//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)
			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(1770916279u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1770916279u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)audioSource != (Object)null)
				{
					audioSource.Stop();
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CancerousRodentAI()
		{
			//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
			NetworkManager.__rpc_func_table.Add(1284136319u, new RpcReceiveHandler(__rpc_handler_1284136319));
			NetworkManager.__rpc_func_table.Add(3458437415u, new RpcReceiveHandler(__rpc_handler_3458437415));
			NetworkManager.__rpc_func_table.Add(1770916279u, new RpcReceiveHandler(__rpc_handler_1770916279));
		}

		private static void __rpc_handler_1284136319(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)2;
				((CancerousRodentAI)(object)target).StartBossbarClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3458437415(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)2;
				((CancerousRodentAI)(object)target).PlayAudioClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1770916279(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)2;
				((CancerousRodentAI)(object)target).StopAudioClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "CancerousRodentAI";
		}
	}
	[BepInPlugin("NightFormula.CancerousRodent", "CancerousRodent", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger = null;

		public static AssetBundle? ModAssets;

		public static GameObject EnemyHealthBar = null;

		private static Harmony harmony = new Harmony("NightFormula.CancerousRodent");

		internal static PluginConfig BoundConfig { get; private set; } = null;


		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "cancerousrodentassets";
			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;
			}
			harmony.PatchAll(typeof(StartOfRoundPatch));
			EnemyType val = ModAssets.LoadAsset<EnemyType>("CancerousRodent");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("CancerousRodentTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("CancerousRodentTK");
			EnemyType val4 = ModAssets.LoadAsset<EnemyType>("VeryCancerousRodent");
			TerminalNode val5 = ModAssets.LoadAsset<TerminalNode>("VeryCancerousRodentTN");
			TerminalKeyword val6 = ModAssets.LoadAsset<TerminalKeyword>("VeryCancerousRodentTK");
			Logger.LogInfo((object)"Attempting to load EnemyHealthBarPrefab");
			EnemyHealthBar = ModAssets.LoadAsset<GameObject>("assets/cancerousrodentassets/healthbar/enemyhealthbarprefab.prefab");
			Logger.LogInfo((object)"Loaded EnemyHealthBarPrefab");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4.enemyPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, val3);
			Enemies.RegisterEnemy(val4, 0, (LevelTypes)(-1), val5, val6);
			Logger.LogInfo((object)"Plugin NightFormula.CancerousRodent 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);
					}
				}
			}
		}
	}
	internal class VeryCancerousRodentAI : EnemyAI
	{
		private enum State
		{
			Idle,
			TargetingPlayer,
			Attacking
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		public GameObject audioSourceObject = null;

		public Light? cancerLight = null;

		public float firingMargin = 30f;

		public HomingMissile missilePrefab = null;

		private Coroutine startAttack = null;

		public float rotationSpeed = 12f;

		public PlayerControllerB grudgePlayer = null;

		public float randomMissileOffsetMaxAngle = 20f;

		private bool doingSpawnAnim = true;

		private AudioSource? audioSource;

		private bool seenAPlayerBefore = false;

		private static readonly string hi = "thanks for the 1000+ downloads, i didnt think this mod would ever be NEAR that number, love you all so much!!! [A big mod is potentially in the works...]";

		private static readonly string thanks = "special thanks to the lovely people over on the unofficial lethal company modding discord, especially @Alecksword, for giving me the motivation to work on adding the very cancerous rodent :3";

		private int cachedStartHealth = 15;

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

		public void FixedUpdate()
		{
			//IL_0038: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			//IL_0069: 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_007b: 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)
			if (!base.isEnemyDead && !((Object)(object)base.targetPlayer == (Object)null) && base.currentBehaviourStateIndex != 0)
			{
				Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				normalized.y = 0f;
				Quaternion val2 = Quaternion.LookRotation(normalized);
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, rotationSpeed * Time.deltaTime);
			}
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			cachedStartHealth = base.enemyHP;
			LogIfDebugBuild("Very Cancerous rodent Spawned");
			if ((Object)(object)grudgePlayer != (Object)null)
			{
				base.targetPlayer = grudgePlayer;
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			if ((Object)(object)missilePrefab == (Object)null)
			{
				Plugin.Logger.LogError((object)"MISSILE PREFAB WAS NULL");
			}
			if ((Object)(object)audioSourceObject != (Object)null)
			{
				audioSource = audioSourceObject.GetComponent<AudioSource>();
				if ((Object)(object)audioSource == (Object)null)
				{
					LogIfDebugBuild("AudioSource component not found on the specified GameObject!");
				}
				else
				{
					audioSource.loop = true;
				}
			}
			else
			{
				LogIfDebugBuild("AudioSourceObject is not set!");
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				StartSpawnAnimClientRpc();
			}
		}

		[ClientRpc]
		public void StartSpawnAnimClientRpc()
		{
			//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)
			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(89749402u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 89749402u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(SpawnAnimRoutine());
				}
			}
		}

		public IEnumerator SpawnAnimRoutine()
		{
			doingSpawnAnim = true;
			Vector3 originalScale = ((Component)this).transform.localScale;
			for (int i = 0; i <= 100; i++)
			{
				float newYScale = Mathf.Lerp(0.01f, originalScale.y, (float)i / 100f);
				((Component)this).transform.localScale = new Vector3(originalScale.x, newYScale, originalScale.z);
				yield return (object)new WaitForSeconds(0.01f);
			}
			doingSpawnAnim = false;
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if ((Object)(object)audioSource != (Object)null && audioSource.isPlaying)
				{
					audioSource.Stop();
				}
				if ((Object)(object)cancerLight != (Object)null)
				{
					((Behaviour)cancerLight).enabled = false;
					cancerLight = null;
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_02b4: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: 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).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || doingSpawnAnim)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (FoundClosestPlayerInRange(100f, 13f))
				{
					LogIfDebugBuild("Start Target Player");
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					if (!seenAPlayerBefore)
					{
						seenAPlayerBefore = true;
						StartBossbarClientRpc(cachedStartHealth);
					}
					PlayAudioClientRpc();
				}
				break;
			case 1:
			{
				base.agent.angularSpeed = 120f;
				if ((!TargetClosestPlayerInAnyCase() || Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 100f) && (Object)(object)base.targetPlayer == (Object)null)
				{
					LogIfDebugBuild("Stop Target Player");
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
					StopAudioClientRpc();
					break;
				}
				Debug.DrawRay(((Component)this).transform.position, ((Component)this).transform.position, Color.cyan);
				Debug.DrawRay(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position, Color.magenta);
				Vector3 forward = ((Component)this).transform.forward;
				Vector3 val = ((Component)base.targetPlayer.playerEye).transform.position - ((Component)this).transform.position;
				float num = Vector3.SignedAngle(forward, ((Vector3)(ref val)).normalized, Vector3.up);
				if (Mathf.Abs(num) <= firingMargin && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.playerEye).transform.position, 45f, 60, -1f, (Transform)null))
				{
					int num2 = Random.Range(1, 3);
					Vector2[] array = (Vector2[])(object)new Vector2[num2];
					for (int i = 0; i < num2; i++)
					{
						Random random = new Random();
						array[i] = new Vector2(((float)random.NextDouble() * 2f - 1f) * randomMissileOffsetMaxAngle, ((float)random.NextDouble() * 2f - 1f) * randomMissileOffsetMaxAngle);
					}
					MissileFireClientRpc(num2, array);
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				break;
			}
			case 2:
				base.agent.angularSpeed = 180f;
				((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		[ClientRpc]
		public void StartBossbarClientRpc(int startHealth)
		{
			//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(1559643699u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, startHealth);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1559643699u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					EnemyHealthBarHandler.Instance.SetupForEnemy((EnemyAI)(object)this, "VERY CANCEROUS RODENT", startHealth, base.enemyHP);
				}
			}
		}

		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)
		{
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				LogIfDebugBuild("Very Cancerous Rodent Collision with Player!");
				val.drunkness += 0.1f;
			}
		}

		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)
			{
				return;
			}
			if ((Object)(object)playerWhoHit != (Object)null)
			{
				if (base.currentBehaviourStateIndex == 0)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				base.targetPlayer = playerWhoHit;
				base.enemyHP -= force;
			}
			if (!base.isEnemyDead && base.enemyHP <= 0)
			{
				EnemyHealthBarHandler.Instance.RequestStopFor((EnemyAI)(object)this);
			}
			if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
			{
				StopAudioClientRpc();
				((MonoBehaviour)this).StopCoroutine(startAttack);
				((MonoBehaviour)this).StartCoroutine(DelayedDestroy());
			}
		}

		private IEnumerator DelayedDestroy()
		{
			yield return (object)new WaitForSeconds(0.05f);
			((EnemyAI)this).KillEnemyOnOwnerClient(true);
			Vector3 originalScale = ((Component)this).transform.localScale;
			for (int i = 0; i <= 100; i++)
			{
				float newYScale = Mathf.Lerp(originalScale.y, 0.01f, (float)i / 100f);
				((Component)this).transform.localScale = new Vector3(originalScale.x, newYScale, originalScale.z);
				yield return (object)new WaitForSeconds(0.01f);
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		[ClientRpc]
		public void PlayAudioClientRpc()
		{
			//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)
			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(2102744949u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2102744949u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)audioSource != (Object)null)
			{
				audioSource.volume = Plugin.BoundConfig.MusicVolume.Value;
				if (!audioSource.isPlaying)
				{
					audioSource.Play();
				}
			}
		}

		[ClientRpc]
		public void StopAudioClientRpc()
		{
			//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)
			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(1801162864u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1801162864u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)audioSource != (Object)null)
				{
					audioSource.Stop();
				}
			}
		}

		[ClientRpc]
		public void MissileFireClientRpc(int missileCount, Vector2[] randomMissileOffsets)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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)
			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(3549503012u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, missileCount);
				bool flag = randomMissileOffsets != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(randomMissileOffsets);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3549503012u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				startAttack = ((MonoBehaviour)this).StartCoroutine(StartAttack(missileCount, randomMissileOffsets));
			}
		}

		private IEnumerator StartAttack(int missileCount, Vector2[] randomMissileOffsets)
		{
			yield return (object)new WaitForSeconds(0.25f);
			for (int i = 0; i < missileCount; i++)
			{
				float randomYaw = randomMissileOffsets[i].x;
				float randomPitch = randomMissileOffsets[i].y;
				Quaternion baseRotation = Quaternion.LookRotation(((Component)base.eye).transform.forward, ((Component)base.eye).transform.up);
				Quaternion yawRotation = Quaternion.AngleAxis(randomYaw, ((Component)base.eye).transform.up);
				Quaternion pitchRotation = Quaternion.AngleAxis(randomPitch, ((Component)base.eye).transform.right);
				Quaternion finalRotation = baseRotation * yawRotation * pitchRotation;
				HomingMissile missile = Object.Instantiate<HomingMissile>(missilePrefab, ((Component)base.eye).transform.position, finalRotation);
				((Component)missile).transform.parent = null;
				missile.targetPlayer = base.targetPlayer;
				yield return (object)new WaitForSeconds(0.2f);
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				yield return (object)new WaitForSeconds(1.5f);
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_VeryCancerousRodentAI()
		{
			//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
			NetworkManager.__rpc_func_table.Add(89749402u, new RpcReceiveHandler(__rpc_handler_89749402));
			NetworkManager.__rpc_func_table.Add(1559643699u, new RpcReceiveHandler(__rpc_handler_1559643699));
			NetworkManager.__rpc_func_table.Add(2102744949u, new RpcReceiveHandler(__rpc_handler_2102744949));
			NetworkManager.__rpc_func_table.Add(1801162864u, new RpcReceiveHandler(__rpc_handler_1801162864));
			NetworkManager.__rpc_func_table.Add(3549503012u, new RpcReceiveHandler(__rpc_handler_3549503012));
		}

		private static void __rpc_handler_89749402(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)2;
				((VeryCancerousRodentAI)(object)target).StartSpawnAnimClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1559643699(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 startHealth = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref startHealth);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((VeryCancerousRodentAI)(object)target).StartBossbarClientRpc(startHealth);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2102744949(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)2;
				((VeryCancerousRodentAI)(object)target).PlayAudioClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1801162864(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)2;
				((VeryCancerousRodentAI)(object)target).StopAudioClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3549503012(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int missileCount = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref missileCount);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				Vector2[] randomMissileOffsets = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref randomMissileOffsets);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((VeryCancerousRodentAI)(object)target).MissileFireClientRpc(missileCount, randomMissileOffsets);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "VeryCancerousRodentAI";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NightFormula.CancerousRodent";

		public const string PLUGIN_NAME = "CancerousRodent";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}
namespace CancerousRodent.src
{
	internal class EnemyHealthBarHandler : MonoBehaviour
	{
		public Slider HealthBarSlider = null;

		public TMP_Text EnemyNameDisplay = null;

		private EnemyAI trackingEnemyAI = null;

		private bool lastResultState = false;

		private float lerpHealthValue = 1f;

		public float targetHealth = 1f;

		public float healthSmoothTime = 0.6f;

		public float maxDisplayDistance = 25f;

		private float healthVelocity = 0f;

		public static EnemyHealthBarHandler Instance { get; set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)this);
			}
			Instance = this;
			((Component)EnemyNameDisplay).gameObject.SetActive(false);
			((Component)HealthBarSlider).gameObject.SetActive(false);
		}

		public void SetupForEnemy(EnemyAI enemyAI, string name = "", int maxHealth = -1, int currentHealth = -1)
		{
			if (maxHealth == -1)
			{
				maxHealth = enemyAI.enemyHP;
			}
			if (name == "")
			{
				name = enemyAI.enemyType.enemyName;
			}
			if (currentHealth == -1)
			{
				currentHealth = enemyAI.enemyHP;
			}
			if ((Object)(object)trackingEnemyAI != (Object)null)
			{
				RequestStopFor(trackingEnemyAI);
			}
			EnemyNameDisplay.text = name.ToUpper();
			HealthBarSlider.maxValue = maxHealth;
			targetHealth = currentHealth;
			lerpHealthValue = targetHealth;
			trackingEnemyAI = enemyAI;
		}

		public void Update()
		{
			if (Plugin.BoundConfig.HealthBarsEnabled.Value)
			{
				bool flag = ShouldShowHealthBar();
				if (flag != lastResultState)
				{
					((Component)EnemyNameDisplay).gameObject.SetActive(flag);
					((Component)HealthBarSlider).gameObject.SetActive(flag);
					lastResultState = flag;
				}
				lerpHealthValue = Mathf.SmoothDamp(lerpHealthValue, targetHealth, ref healthVelocity, 0.5f);
				HealthBarSlider.value = lerpHealthValue;
				if (!((Object)(object)trackingEnemyAI == (Object)null))
				{
					targetHealth = trackingEnemyAI.enemyHP;
				}
			}
		}

		public void RequestStopFor(EnemyAI enemyAI)
		{
			if (!((Object)(object)trackingEnemyAI != (Object)(object)enemyAI) && !((Object)(object)trackingEnemyAI == (Object)null))
			{
				trackingEnemyAI = null;
				EnemyNameDisplay.text = "!!! FKAF !!!";
				HealthBarSlider.maxValue = 1f;
				targetHealth = 1f;
				lerpHealthValue = targetHealth;
			}
		}

		private bool ShouldShowHealthBar()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.BoundConfig.HealthBarsEnabled.Value)
			{
				return false;
			}
			if ((Object)(object)trackingEnemyAI == (Object)null)
			{
				return false;
			}
			if (Vector3.Distance(((Component)trackingEnemyAI).transform.position, ((Component)StartOfRound.Instance.localPlayerController).transform.position) >= maxDisplayDistance)
			{
				return false;
			}
			return true;
		}
	}
	internal class HomingMissile : MonoBehaviour
	{
		[Header("Missile Settings")]
		public float speed = 13.5f;

		public float rotationSpeed = 3.5f;

		public float lifeTime = 7f;

		public int damage = 20;

		[Header("Target Settings")]
		public PlayerControllerB targetPlayer = null;

		private Rigidbody rb;

		private float timer;

		public float postLaunchSteeringLoss = 0.02f;

		public float steeringMult = 1f;

		public void Awake()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
			if ((Object)(object)rb == (Object)null)
			{
				Plugin.Logger.LogError((object)"[Homing Missile] Rigidbody is missing! Please add one you silly goose");
			}
			else
			{
				rb.useGravity = false;
			}
		}

		private void Start()
		{
			timer = 0f;
			steeringMult = 1f;
			if ((Object)(object)targetPlayer == (Object)null)
			{
				Plugin.Logger.LogError((object)"[Homing Missile] No target assigned! Self-destructing...");
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void FixedUpdate()
		{
			timer += Time.fixedDeltaTime;
			steeringMult -= postLaunchSteeringLoss;
			steeringMult = ((steeringMult >= 0.13f) ? steeringMult : 0.13f);
			if (timer >= lifeTime)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if ((Object)(object)targetPlayer != (Object)null)
			{
				TrackAndMoveTowardTarget();
			}
		}

		private void TrackAndMoveTowardTarget()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0057: 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)
			//IL_0069: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)targetPlayer == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Vector3 val = ((Component)targetPlayer.playerEye).transform.position - ((Component)this).transform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Quaternion val2 = Quaternion.LookRotation(normalized);
			((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, rotationSpeed * Time.deltaTime * steeringMult);
			rb.velocity = ((Component)this).transform.forward * speed;
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if ((((Component)other).gameObject.layer == LayerMask.NameToLayer("Player") || ((Component)other).gameObject.layer == LayerMask.NameToLayer("Room")) && lifeTime > 0.5f)
			{
				Landmine.SpawnExplosion(((Component)this).transform.position, true, 1.3f, 4f, damage, 1.4f, (GameObject)null, false);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}
namespace CancerousRodent.src.patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(StartOfRound __instance)
		{
			Plugin.Logger.LogInfo((object)"Attempting to instantiate EnemyHealthBar...");
			GameObject val = Object.Instantiate<GameObject>(Plugin.EnemyHealthBar, ((Component)__instance).transform);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to instantiate EnemyHealthBar prefab!");
				return;
			}
			EnemyHealthBarHandler component = val.GetComponent<EnemyHealthBarHandler>();
			if ((Object)(object)component == (Object)null)
			{
				Plugin.Logger.LogError((object)"EnemyHealthBarHandler component is missing on the instantiated prefab!");
			}
			else
			{
				Plugin.Logger.LogInfo((object)"Successfully instantiated EnemyHealthBar and initialized EnemyHealthBarHandler.");
			}
		}
	}
}
namespace CancerousRodent.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		[Range(0f, 1f)]
		public ConfigEntry<float> MusicVolume;

		public ConfigEntry<bool> HealthBarsEnabled;

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 30, "The spawn chance weight for the silly little guy, relative to the other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			MusicVolume = cfg.Bind<float>("General", "Music volume", 0.3f, "The volume of the 'Theme Of Cancer' played when the Rodent finds you.\nRanges from 0.0 to 1.0, with 1.0 being quite loud, and 0.0 being silent.");
			HealthBarsEnabled = cfg.Bind<bool>("General", "Health Bars Enabled", true, "Whether or not there are health bars at the top of the screen when you find a rodent. \nTrue makes the health bars show, False makes them not show up.");
			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 NightFormula.CancerousRodent.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}