Decompiled source of No Load Lag Lethal v1.0.0

BepInEx/plugins/NoLoadLagLethal.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("NoLoadLagLethal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f3c2744276af7217e5917606df6039b63747bb71")]
[assembly: AssemblyProduct("No Load Lag Lethal")]
[assembly: AssemblyTitle("NoLoadLagLethal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NoLoadLagLethal
{
	[BepInPlugin("NoLoadLagLethal", "No Load Lag Lethal", "1.0.0")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private Harmony HarInstance;

		public static List<EnemyAI> EnemyAIList = new List<EnemyAI>();

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin NoLoadLagLethal is loaded!");
			HarInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			Logger.LogInfo((object)"Applied game patch to round start code.");
		}

		[HarmonyPatch(typeof(StartOfRound), "SetPlayerSafeInShip")]
		[HarmonyPriority(0)]
		[HarmonyPrefix]
		private static void Prefix(StartOfRound __instance, ref bool __runOriginal)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			if (!__runOriginal)
			{
				return;
			}
			__runOriginal = false;
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (localPlayerController.isPlayerDead && (Object)localPlayerController.spectatedPlayerScript != (Object)null)
			{
				localPlayerController = localPlayerController.spectatedPlayerScript;
			}
			List<EnemyAI> enemyAIList = EnemyAIList;
			if (__instance.hangarDoorsClosed && GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)
			{
				for (int i = 0; i < enemyAIList.Count; i++)
				{
					enemyAIList[i].EnableEnemyMesh(enemyAIList[i].isInsidePlayerShip, false, false);
				}
			}
			else
			{
				for (int j = 0; j < enemyAIList.Count; j++)
				{
					enemyAIList[j].EnableEnemyMesh(true, false, false);
				}
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPriority(800)]
		[HarmonyPostfix]
		private static void PostFix(EnemyAI __instance)
		{
			if (!EnemyAIList.Contains(__instance))
			{
				EnemyAIList.Add(__instance);
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "OnDestroy")]
		[HarmonyPriority(800)]
		[HarmonyPrefix]
		private static void Prefix1(EnemyAI __instance)
		{
			EnemyAIList.Remove(__instance);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoLoadLagLethal";

		public const string PLUGIN_NAME = "No Load Lag Lethal";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}