Decompiled source of CombinedMenu v1.0.0

plugins/CombinedMenu/CombinedMenu.dll

Decompiled 6 days 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 BepInEx.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2.UI.MainMenu;
using RoR2;
using RoR2.UI;
using RoR2.UI.MainMenu;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CombinedMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+363fbcd6bb89fc2fc2e8d3ce724174f17cc2e9b4")]
[assembly: AssemblyProduct("CombinedMenu")]
[assembly: AssemblyTitle("CombinedMenu")]
[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 CombinedMenu
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("CombinedMenu");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "CombinedMenu".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Nuxlar.CombinedMenu", "CombinedMenu", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__EditMainMenu;
		}

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

			public static UnityAction <>9__14_0;

			internal void <EditMainMenu>b__14_0()
			{
				Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
				Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
			}
		}

		public const string PluginGUID = "Nuxlar.CombinedMenu";

		public const string PluginAuthor = "Nuxlar";

		public const string PluginName = "CombinedMenu";

		public const string PluginVersion = "1.0.0";

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		public void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Instance = SingletonHelper.Assign<Main>(Instance, this);
			Log.Init(((BaseUnityPlugin)this).Logger);
			object obj = <>O.<0>__EditMainMenu;
			if (obj == null)
			{
				hook_Awake val = EditMainMenu;
				<>O.<0>__EditMainMenu = val;
				obj = (object)val;
			}
			MainMenuController.Awake += (hook_Awake)obj;
		}

		private void OnDestroy()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__EditMainMenu;
			if (obj == null)
			{
				hook_Awake val = EditMainMenu;
				<>O.<0>__EditMainMenu = val;
				obj = (object)val;
			}
			MainMenuController.Awake -= (hook_Awake)obj;
			Instance = SingletonHelper.Unassign<Main>(Instance, this);
		}

		private static void EditMainMenu(orig_Awake orig, MainMenuController self)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			orig.Invoke(self);
			Transform val = ((Component)self).transform.Find("MENU: Title/TitleMenu/SafeZone/GenericMenuButtonPanel/JuicePanel/GenericMenuButton (Singleplayer)");
			Transform val2 = ((Component)self).transform.Find("MENU: Title/TitleMenu/SafeZone/GenericMenuButtonPanel/JuicePanel/GenericMenuButton (Extra Game Mode)");
			Transform val3 = ((Component)self).transform.Find("MENU: Extra Game Mode/ExtraGameModeMenu/Main Panel/GenericMenuButtonPanel/JuicePanel/");
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
			{
				return;
			}
			GameObject obj = Object.Instantiate<GameObject>(((Component)((Component)self).transform.Find("MENU: Extra Game Mode/ExtraGameModeMenu/Main Panel/GenericMenuButtonPanel/JuicePanel/GenericMenuButton (Eclipse)")).gameObject, val3);
			obj.transform.SetSiblingIndex(1);
			obj.GetComponent<LanguageTextMeshController>().token = "Classic";
			HGButton component = obj.GetComponent<HGButton>();
			component.hoverToken = "Play the classic Risk of Rain 2 experience.";
			((Button)component).onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick = ((Button)component).onClick;
			object obj2 = <>c.<>9__14_0;
			if (obj2 == null)
			{
				UnityAction val4 = delegate
				{
					Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
				};
				<>c.<>9__14_0 = val4;
				obj2 = (object)val4;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj2);
			Object.Destroy((Object)(object)((Component)val).gameObject);
			HGButton component2 = ((Component)val2).GetComponent<HGButton>();
			val2.SetSiblingIndex(1);
			((Component)val2).GetComponent<LanguageTextMeshController>().token = "Singleplayer";
			component2.hoverToken = "Choose your preferred game mode.";
		}
	}
}