Decompiled source of AutoConfirmStartKick v0.1.0

BepInEx/plugins/NoConfirm/NoConfirm.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace RepoShadow
{
	[BepInPlugin("com.github.reposhadow.autoconfirm", "AutoConfirm (Start + Kick)", "0.1.0")]
	public sealed class MinimalPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.github.reposhadow.autoconfirm";

		public const string PluginName = "AutoConfirm (Start + Kick)";

		public const string PluginVersion = "0.1.0";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.github.reposhadow.autoconfirm").PatchAll();
		}
	}
}
namespace RepoShadow.patches
{
	[HarmonyPatch(typeof(MenuButton))]
	internal static class MenuButton_StartGame_NoConfirm_Patch
	{
		private static readonly FieldInfo? MenuButtonPopUpField = AccessTools.Field(typeof(MenuButton), "menuButtonPopUp");

		private static readonly FieldInfo? DisabledField = AccessTools.Field(typeof(MenuButton), "disabled");

		private static readonly FieldInfo? DoButtonEffectField = AccessTools.Field(typeof(MenuButton), "doButtonEffect");

		[HarmonyPrefix]
		[HarmonyPatch("OnSelect")]
		private static bool OnSelectPrefix(MenuButton __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if (MenuButtonPopUpField == null)
			{
				return true;
			}
			bool flag = false;
			try
			{
				if ((Object)(object)MenuPageLobby.instance != (Object)null && __instance == MenuPageLobby.instance.startButton)
				{
					flag = true;
				}
			}
			catch
			{
			}
			try
			{
				if (!flag)
				{
					object value = MenuButtonPopUpField.GetValue(__instance);
					MenuButtonPopUp val = (MenuButtonPopUp)((value is MenuButtonPopUp) ? value : null);
					if (val != null)
					{
						string text = val.headerText ?? string.Empty;
						string text2 = val.bodyText ?? string.Empty;
						if (text.Trim().Equals("KICK PLAYER", StringComparison.OrdinalIgnoreCase))
						{
							flag = true;
						}
						else if (text2.IndexOf("want to kick", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							flag = true;
						}
					}
				}
			}
			catch
			{
			}
			if (!flag)
			{
				return true;
			}
			try
			{
				if (DisabledField != null && (bool)DisabledField.GetValue(__instance))
				{
					MenuManager.instance.MenuEffectClick((MenuClickEffectType)2, (MenuPage)null, -1f, -1f, false);
					return false;
				}
			}
			catch
			{
			}
			try
			{
				if (DoButtonEffectField != null && (bool)DoButtonEffectField.GetValue(__instance))
				{
					MenuManager.instance.MenuEffectClick((MenuClickEffectType)0, MenuPageLobby.instance.menuPage, -1f, -1f, false);
				}
			}
			catch
			{
			}
			try
			{
				object value2 = MenuButtonPopUpField.GetValue(__instance);
				MenuButtonPopUp val2 = (MenuButtonPopUp)((value2 is MenuButtonPopUp) ? value2 : null);
				if (val2 != null)
				{
					UnityEvent option1Event = val2.option1Event;
					if (option1Event != null)
					{
						option1Event.Invoke();
					}
					return false;
				}
				try
				{
					if ((Object)(object)MenuPageLobby.instance != (Object)null && __instance == MenuPageLobby.instance.startButton)
					{
						MenuPageLobby.instance.ButtonStart();
					}
				}
				catch
				{
				}
				return false;
			}
			catch
			{
				return false;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}