Decompiled source of ImmortalSnail v0.7.5

ImmortalSnail.dll

Decompiled 5 months ago
using System;
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.Bootstrap;
using BepInEx.Configuration;
using GameNetcodeStuff;
using ImmortalSnail.NetcodePatcher;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("ImmortalSnail")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Escape from an incredibly slow snail that instantly kills you upon contact.")]
[assembly: AssemblyFileVersion("0.7.4.0")]
[assembly: AssemblyInformationalVersion("0.7.4")]
[assembly: AssemblyProduct("ImmortalSnail")]
[assembly: AssemblyTitle("ImmortalSnail")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.7.4.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace ImmortalSnail
{
	internal class ConfigManager
	{
		public static void setupLethalConfig()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0028: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0050: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0071: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0077: 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_0083: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0092: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			ConfigEntry<float> configSize = Plugin.configSize;
			FloatSliderOptions val = new FloatSliderOptions();
			((BaseRangeOptions<float>)val).Min = 75f;
			((BaseRangeOptions<float>)val).Max = 225f;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(configSize, val);
			ConfigEntry<float> configSpeed = Plugin.configSpeed;
			FloatSliderOptions val3 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val3).Min = 0.1f;
			((BaseRangeOptions<float>)val3).Max = 2f;
			FloatSliderConfigItem val4 = new FloatSliderConfigItem(configSpeed, val3);
			ConfigEntry<int> configMaxSnails = Plugin.configMaxSnails;
			IntSliderOptions val5 = new IntSliderOptions();
			((BaseRangeOptions<int>)val5).Min = 0;
			((BaseRangeOptions<int>)val5).Max = 10;
			IntSliderConfigItem val6 = new IntSliderConfigItem(configMaxSnails, val5);
			ConfigEntry<int> configRarity = Plugin.configRarity;
			IntSliderOptions val7 = new IntSliderOptions();
			((BaseRangeOptions<int>)val7).Min = 0;
			((BaseRangeOptions<int>)val7).Max = 100;
			IntSliderConfigItem val8 = new IntSliderConfigItem(configRarity, val7);
			BoolCheckBoxConfigItem val9 = new BoolCheckBoxConfigItem(Plugin.configGoOutside, false);
			BoolCheckBoxConfigItem val10 = new BoolCheckBoxConfigItem(Plugin.configEnterShip, false);
			BoolCheckBoxConfigItem val11 = new BoolCheckBoxConfigItem(Plugin.configGary, true);
			BoolCheckBoxConfigItem val12 = new BoolCheckBoxConfigItem(Plugin.configCanExplode, false);
			BoolCheckBoxConfigItem val13 = new BoolCheckBoxConfigItem(Plugin.configExplosionKillOthers, false);
			BoolCheckBoxConfigItem val14 = new BoolCheckBoxConfigItem(Plugin.configShowTarget, false);
			BoolCheckBoxConfigItem val15 = new BoolCheckBoxConfigItem(Plugin.configKillAnyPlayer, false);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val9);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val11);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val12);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val13);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val14);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val15);
		}
	}
	[BepInPlugin("ImmortalSnail", "ImmortalSnail", "0.7.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static AssetBundle bundle;

		public static ConfigEntry<float> configSize;

		public static ConfigEntry<float> configSpeed;

		public static ConfigEntry<int> configMaxSnails;

		public static ConfigEntry<int> configRarity;

		public static ConfigEntry<bool> configGoOutside;

		public static ConfigEntry<bool> configEnterShip;

		public static ConfigEntry<bool> configGary;

		public static ConfigEntry<bool> configCanExplode;

		public static ConfigEntry<bool> configExplosionKillOthers;

		public static ConfigEntry<bool> configShowTarget;

		public static ConfigEntry<bool> configKillAnyPlayer;

		private void Awake()
		{
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: 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_0392: 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)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading a mod by swAAn\n\n                                    _\n                                ,-\"\" \"\".\n                              ,'  ____  `.\n                            ,'  ,'    `.  `._\n   (`.         _..--.._   ,'  ,'        \\    \\\n  (`-.\\    .-\"\"        \"\"'   /          (  d _b\n (`._  `-\"\" ,._             (            `-(   \\\n <_  `     (  <`<            \\              `-._\\\n  <`-       (__< <           :\n   (__        (_<_<          ;\n    `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"\n         __,._\n        /  _  \\\n       |  6 \\  \\  oo\n        \\___/ .|__||\n __,..=\" ^  . , \"  ,\\\n<.__________________/");
			NetcodePatcher();
			configSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Scale", 100f, "The size of the snail.");
			configSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Speed", 0.5f, "The speed of the snail.");
			configMaxSnails = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Max Snails", 4, "The maximum number of snails that can spawn in a round.");
			configRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Rarity", 80, "Honestly not sure exactly how this works, but a higher \"Rarity\" will make the snail more likely to spawn.");
			configGoOutside = ((BaseUnityPlugin)this).Config.Bind<bool>("Pathing", "Can Go Outside", true, "If enabled, allows the snail to exit the factory and chase players outside.");
			configEnterShip = ((BaseUnityPlugin)this).Config.Bind<bool>("Pathing", "Can Enter Ship", true, "If enabled, allows the snail to target players that are in the ship room.");
			configGary = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Gary Mode", false, "Snail is reskinned to look like Spongebob's faithful pet snail, Gary!");
			configCanExplode = ((BaseUnityPlugin)this).Config.Bind<bool>("Explosions", "Can Explode", true, "Snail creates an explosion when killing player.");
			configExplosionKillOthers = ((BaseUnityPlugin)this).Config.Bind<bool>("Explosions", "Explosions Kill Other Players", false, "If enabled, snail explosion will kill other players in explosion radius.");
			configShowTarget = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Target on Scan", true, "If enabled, shows the targeted player when scanned.");
			configKillAnyPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Kill Any Player", false, "If enabled, the snail will kill ANY player it comes in contact with. The snail targeting system will work the same way.");
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				ConfigManager.setupLethalConfig();
			}
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "immortalsnail"));
			if ((Object)(object)bundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle.");
				return;
			}
			EnemyType val = bundle.LoadAsset<EnemyType>("ImmortalSnail.EnemyType");
			if ((Object)(object)val == (Object)null || (Object)(object)val.enemyPrefab == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Snail Failed to load properly.");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Configuring Snail.");
			if (configGary.Value)
			{
				val.enemyPrefab = bundle.LoadAsset<GameObject>("gary_snail.prefab");
			}
			val.enemyPrefab.AddComponent<SnailAI>();
			((EnemyAI)val.enemyPrefab.GetComponent<SnailAI>()).enemyType = val;
			val.enemyPrefab.GetComponentInChildren<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)val.enemyPrefab.GetComponent<SnailAI>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying User-Defined Configuration Settings");
			Transform transform = val.enemyPrefab.transform;
			transform.localScale *= configSize.Value / 100f;
			val.enemyPrefab.GetComponent<NavMeshAgent>().speed = configSpeed.Value;
			val.MaxCount = configMaxSnails.Value;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Registering Snail as Enemy");
			LevelTypes val2 = (LevelTypes)(-1);
			SpawnType val3 = (SpawnType)0;
			TerminalNode val4 = ScriptableObject.CreateInstance<TerminalNode>();
			val4.displayText = "The Immortal Snail\n\nDanger level: 50%\n\nThe following is a recitation of the events that transpired on [REDACTED] to the best of my memory. This is my experience with the entity and I swear to do right by the company and describe it as best I can. There were four of us out on a routine scrap-job, absolutely nothing was out of the ordinary before [REDACTED] spotted it. We laughed our asses off. Half the things in here will make you soil your hazmat suit on the spot, and then there's this thing, moving at, well you know. We had our fun, but ultimately moved on and forgot about the thing. Me and the boys went our separate ways and decided to rendezvous at the ship. Three of us returned, but [REDACTED] was missing. We all decided to go back in and investigate. The place was silent. We thought things might have taken a turn for the worse, so we decided to split up and either guide [REDACTED] back to ship, or at least recover his remains. As often happens, I found myself lost. Turning the corners of this elaborate labyrinth, I finally found what was left of [REDACTED]. It was unusual, I'd never seen a coworker left in such a state. Reality struck as I turned a corner and found another comrade waiting on the ground for me, and then another. I made the heartbreaking decision to leave my comrades behind. I was almost free, when I find staring at me from the front entrance the same snail I'd seen before. I saw red. I beat that thing as ruthlessly as I could (with my shovel), entirely imprinting my rage on its presumably fragile shell. I expected to find a small puddle where the snail once stood, but the it was unaffected. It moved towards me at the same agitating pace it did before. The aftermath is a blur. Sometimes I wonder if I even made it back to the ship at all.\n\n";
			val4.clearPreviousText = true;
			val4.maxCharactersToType = 2000;
			val4.creatureName = "The Immortal Snail";
			val4.creatureFileID = 1738;
			TerminalKeyword val5 = TerminalUtils.CreateTerminalKeyword("snail", false, (CompatibleNoun[])null, val4, (TerminalKeyword)null, false);
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, configRarity.Value, val2, val3, val4, val5);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ImmortalSnail 0.7.4 is loaded!");
		}

		private static void NetcodePatcher()
		{
			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 SnailAI : EnemyAI
	{
		private float timeAtLastUsingEntrance;

		private float timeOfLastExplosion;

		public override void Start()
		{
			base.enemyHP = 1;
			((EnemyAI)this).Start();
			RefreshTargetServerRpc();
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)"Snail collided with a player, but player was null.");
				return;
			}
			((EnemyAI)this).OnCollideWithPlayer(other);
			if ((Object.op_Implicit((Object)(object)base.targetPlayer) && component.playerClientId == base.targetPlayer.playerClientId) || Plugin.configKillAnyPlayer.Value)
			{
				KillPlayerServerRpc((int)component.playerClientId);
			}
		}

		public override void DoAIInterval()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || !base.targetPlayer.isPlayerControlled || (base.targetPlayer.isInHangarShipRoom && !Plugin.configEnterShip.Value) || (!base.targetPlayer.isInsideFactory && !Plugin.configGoOutside.Value))
			{
				RefreshTargetServerRpc();
			}
			if (base.movingTowardsTargetPlayer)
			{
				if (isInTargetPlayerArea())
				{
					base.destination = RoundManager.Instance.GetNavMeshPosition(((Component)base.targetPlayer).transform.position, RoundManager.Instance.navHit, 2.7f, -1);
				}
				else
				{
					SetDestinationToOtherArea();
				}
				base.agent.SetDestination(base.destination);
				base.agent.isStopped = false;
			}
			else
			{
				base.agent.isStopped = true;
			}
		}

		private void SetDestinationToOtherArea()
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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)
			Transform nearbyExitTransform = getNearbyExitTransform();
			if (Object.op_Implicit((Object)(object)nearbyExitTransform) && Time.realtimeSinceStartup - timeAtLastUsingEntrance > 3f)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					((Behaviour)base.agent).enabled = false;
					((Component)this).transform.position = nearbyExitTransform.position;
					((Behaviour)base.agent).enabled = true;
				}
				else
				{
					((Component)this).transform.position = nearbyExitTransform.position;
				}
				timeAtLastUsingEntrance = Time.realtimeSinceStartup;
				base.isOutside = !base.isOutside;
				base.destination = RoundManager.Instance.GetNavMeshPosition(((Component)base.targetPlayer).transform.position, RoundManager.Instance.navHit, 2.7f, -1);
			}
			else
			{
				base.destination = RoundManager.Instance.GetNavMeshPosition(getNearestExitTransform().position, RoundManager.Instance.navHit, 2.7f, -1);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RefreshTargetServerRpc()
		{
			//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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3872618423u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3872618423u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB val3 = null;
			float num = float.MaxValue;
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				if (!((Object)(object)allPlayerScripts[i] == (Object)null) && !allPlayerScripts[i].isPlayerDead && allPlayerScripts[i].isPlayerControlled && (!allPlayerScripts[i].isInHangarShipRoom || Plugin.configEnterShip.Value) && (allPlayerScripts[i].isInsideFactory || Plugin.configGoOutside.Value))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)allPlayerScripts[i]).transform.position);
					if (num2 < num)
					{
						val3 = allPlayerScripts[i];
						num = num2;
					}
				}
			}
			if ((Object)(object)val3 == (Object)null)
			{
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				RefreshTargetClientRpc(-1);
				return;
			}
			((EnemyAI)this).SetMovingTowardsTargetPlayer(val3);
			if (Plugin.configShowTarget.Value)
			{
				((Component)this).gameObject.GetComponentInChildren<ScanNodeProperties>().subText = "Current Target : " + val3.playerUsername;
			}
			RefreshTargetClientRpc((int)val3.playerClientId);
		}

		[ClientRpc]
		public void RefreshTargetClientRpc(int playerId)
		{
			//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)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3607601761u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3607601761u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if (playerId == -1)
			{
				base.targetPlayer = null;
				base.movingTowardsTargetPlayer = false;
				return;
			}
			PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
			((EnemyAI)this).SetMovingTowardsTargetPlayer(val3);
			if (Plugin.configShowTarget.Value)
			{
				((Component)this).gameObject.GetComponentInChildren<ScanNodeProperties>().subText = "Current Target: " + val3.playerUsername;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void KillPlayerServerRpc(int playerId)
		{
			//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)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(144219085u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 144219085u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				if (Plugin.configCanExplode.Value)
				{
					Explode(playerId, Plugin.configExplosionKillOthers.Value);
				}
				else
				{
					StartOfRound.Instance.allPlayerScripts[playerId].KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0, default(Vector3));
				}
				KillPlayerClientRpc(playerId, Plugin.configCanExplode.Value, Plugin.configExplosionKillOthers.Value);
			}
		}

		[ClientRpc]
		public void KillPlayerClientRpc(int playerId, bool explode, bool killOthers)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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(1023255967u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref explode, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref killOthers, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1023255967u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (explode)
				{
					Explode(playerId, killOthers);
				}
				else
				{
					StartOfRound.Instance.allPlayerScripts[playerId].KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0, default(Vector3));
				}
			}
		}

		private Transform getNearbyExitTransform()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
			EntranceTeleport[] array2 = array;
			foreach (EntranceTeleport val in array2)
			{
				if (!(Vector3.Distance(((Component)this).transform.position, val.entrancePoint.position) < 1f))
				{
					continue;
				}
				EntranceTeleport[] array3 = array;
				foreach (EntranceTeleport val2 in array3)
				{
					if (val2.isEntranceToBuilding != val.isEntranceToBuilding && val2.entranceId == val.entranceId)
					{
						return val2.entrancePoint;
					}
				}
			}
			return null;
		}

		private Transform getNearestExitTransform()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(false);
			Transform result = null;
			float num = float.MaxValue;
			EntranceTeleport[] array2 = array;
			foreach (EntranceTeleport val in array2)
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, val.entrancePoint.position);
				if (num2 < num)
				{
					result = val.entrancePoint;
					num = num2;
				}
			}
			return result;
		}

		private bool isInTargetPlayerArea()
		{
			return (base.targetPlayer.isInsideFactory && !base.isOutside) || (!base.targetPlayer.isInsideFactory && base.isOutside);
		}

		private void Explode(int playerId, bool killOthers)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.realtimeSinceStartup - timeOfLastExplosion <= 0.5f))
			{
				if (killOthers)
				{
					Landmine.SpawnExplosion(((Component)this).transform.position, true, 5.7f, 6.4f, 50, 0f, (GameObject)null, false);
				}
				else
				{
					Landmine.SpawnExplosion(((Component)this).transform.position, true, 0f, 0f, 50, 0f, (GameObject)null, false);
					StartOfRound.Instance.allPlayerScripts[playerId].KillPlayer(GetBodyVelocity(playerId), true, (CauseOfDeath)3, 0, default(Vector3));
				}
				timeOfLastExplosion = Time.realtimeSinceStartup;
			}
		}

		private Vector3 GetBodyVelocity(int playerId)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)StartOfRound.Instance.allPlayerScripts[playerId].gameplayCamera).transform.position;
			position -= ((Component)this).transform.position;
			position *= 80f;
			return position / Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[playerId].gameplayCamera).transform.position, ((Component)this).transform.position);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SnailAI()
		{
			//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
			NetworkManager.__rpc_func_table.Add(3872618423u, new RpcReceiveHandler(__rpc_handler_3872618423));
			NetworkManager.__rpc_func_table.Add(3607601761u, new RpcReceiveHandler(__rpc_handler_3607601761));
			NetworkManager.__rpc_func_table.Add(144219085u, new RpcReceiveHandler(__rpc_handler_144219085));
			NetworkManager.__rpc_func_table.Add(1023255967u, new RpcReceiveHandler(__rpc_handler_1023255967));
		}

		private static void __rpc_handler_3872618423(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;
				((SnailAI)(object)target).RefreshTargetServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3607601761(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 playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SnailAI)(object)target).RefreshTargetClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_144219085(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 playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SnailAI)(object)target).KillPlayerServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1023255967(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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				bool explode = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref explode, default(ForPrimitives));
				bool killOthers = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref killOthers, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SnailAI)(object)target).KillPlayerClientRpc(playerId, explode, killOthers);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SnailAI";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ImmortalSnail";

		public const string PLUGIN_NAME = "ImmortalSnail";

		public const string PLUGIN_VERSION = "0.7.4";
	}
}
namespace ImmortalSnail.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}