Decompiled source of LandingLag v1.0.3

BepInEx/plugins/LandingLag.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
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("LandingLag")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+e66c3f7e852f7896132cbbf8c61fb355a0d5b62d")]
[assembly: AssemblyProduct("LandingLag")]
[assembly: AssemblyTitle("LandingLag")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LandingLag
{
	[BepInPlugin("LandingLag", "LandingLag", "1.0.3")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private Harmony HarInstance;

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

		public static EnemyAI[] GetAIs()
		{
			return RoundManager.Instance.SpawnedEnemies.ToArray();
		}

		[HarmonyPatch(typeof(StartOfRound), "SetPlayerSafeInShip")]
		[HarmonyPriority(0)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			MethodInfo methodInfo = AccessTools.Method(typeof(Plugin), "GetAIs", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Object), "FindObjectOfType", Type.EmptyTypes, (Type[])null)?.MakeGenericMethod(typeof(EnemyAI));
			if (methodInfo2 == null || methodInfo == null)
			{
				return list;
			}
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.Calls(list[i], methodInfo2))
				{
					list[i] = new CodeInstruction(OpCodes.Call, (object)methodInfo);
				}
			}
			return list;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LandingLag";

		public const string PLUGIN_NAME = "LandingLag";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}