Decompiled source of Reboot v1.0.1

Reboot.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Linq;
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 TMPro;
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
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("com.sqbi.lethallanfixfix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Lethal Lan Fix Fix")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("LethalLanFixFix")]
[assembly: AssemblyTitle("com.sqbi.lethallanfixfix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 LethalLanFixFix
{
	[BepInPlugin("com.sqbi.lethallanfixfix", "LethalLanFixFix", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.sqbi.lethallanfixfix is loaded!");
			SceneManager.sceneLoaded += OnSceneLoaded;
			Harmony val = new Harmony("com.sqbi.lethallanfixfix");
			val.PatchAll();
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			string name = ((Scene)(ref scene)).name;
			string text = name;
			if (text == "MainMenu")
			{
				MenuManagerPatches.AddIPInputMenu();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"IP Input menu added");
				MenuManagerPatches.Patch_StartLAN();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"StartLAN button swapped");
			}
		}
	}
	public class MenuManagerPatches : MonoBehaviour
	{
		[HarmonyPatch(typeof(MenuManager), "LAN_HostSetAllowRemoteConnections")]
		public static class MenuManager_LAN_HostSetAllowRemoteConnections
		{
			[HarmonyPostfix]
			public static void Postfix(MenuManager __instance)
			{
				if (!((object)Traverse.Create((object)__instance).Field("startingAClient")).Equals((object?)false))
				{
					Debug.Log((object)("Listening to LAN server: " + IPInput.IP_Address));
					((Component)NetworkManager.Singleton).GetComponent<UnityTransport>().ConnectionData.Address = IPInput.IP_Address;
				}
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__0_0;

			internal void <Patch_StartLAN>b__0_0()
			{
				OnStartLANClick();
			}
		}

		public static void Patch_StartLAN()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			GameObject val = GameObject.Find("Canvas/MenuContainer/MainButtons/StartLAN");
			val.GetComponent<Button>().onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick = val.GetComponent<Button>().onClick;
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					OnStartLANClick();
				};
				<>c.<>9__0_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
		}

		private static void OnStartLANClick()
		{
			GameObject.Find("Canvas/MenuContainer/IPInputMenu").gameObject.SetActive(true);
		}

		public static void AddIPInputMenu()
		{
			GameObject val = IPInput.Create();
			GameObject val2 = GameObject.Find("Canvas/MenuContainer");
			val.transform.SetParent(val2.transform);
		}
	}
	public class IPInput : MonoBehaviour
	{
		public static string IP_Address = "192.168.20.4";

		public static GameObject Create()
		{
			//IL_0024: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			GameObject val = GameObject.Find("Canvas/MenuContainer");
			GameObject val2 = GameObject.Find("Canvas/MenuContainer/LANWarning");
			GameObject val3 = Object.Instantiate<GameObject>(val2, val2.transform.position, val2.transform.rotation, val.transform);
			Transform val4 = val3.transform.Find("Panel");
			GameObject gameObject = ((Component)val4.Find("NotificationText")).gameObject;
			GameObject gameObject2 = ((Component)(from obj in Resources.FindObjectsOfTypeAll<TMP_InputField>()
				where ((Object)obj).name == "ServerNameField"
				select obj).ElementAt(0)).gameObject;
			GameObject ip_field = Object.Instantiate<GameObject>(gameObject2, val4.position + new Vector3(0f, 2f, 0f), val4.rotation, val4);
			GameObject gameObject3 = ((Component)val3.transform.Find("Panel/Confirm")).gameObject;
			GameObject val5 = Object.Instantiate<GameObject>(gameObject3, gameObject3.transform.position + new Vector3(0f, 6f, 0f), gameObject3.transform.rotation, val4);
			((Object)val3).name = "IPInputMenu";
			((Object)gameObject).name = "HeaderText";
			((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).text = "Enter LAN Server IP Address";
			((Object)ip_field).name = "IPInputField";
			((TMP_Text)((Component)ip_field.GetComponent<TMP_InputField>().placeholder).GetComponent<TextMeshProUGUI>()).text = "127.0.0.1";
			ip_field.GetComponent<TMP_InputField>().onValueChanged = new OnChangeEvent();
			((Object)gameObject3).name = "Connect";
			((TMP_Text)gameObject3.GetComponentInChildren<TextMeshProUGUI>()).text = "[ Connect ]";
			((UnityEvent)gameObject3.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				if (ip_field.GetComponent<TMP_InputField>().text != "")
				{
					IP_Address = ip_field.GetComponent<TMP_InputField>().text;
				}
				else
				{
					IP_Address = "127.0.0.1";
				}
				GameObject.Find("MenuManager").GetComponent<MenuManager>().StartAClient();
			});
			((Object)val5).name = "Cancel";
			((TMP_Text)val5.GetComponentInChildren<TextMeshProUGUI>()).text = "[ Cancel ]";
			return val3;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.sqbi.lethallanfixfix";

		public const string PLUGIN_NAME = "LethalLanFixFix";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}