Decompiled source of SkipIntros v1.0.0

plugins/GoblinCleanupSkipIntros.dll

Decompiled 18 hours ago
using System;
using System.Collections;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("GoblinCleanupSkipIntros")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f36f236867210c5a68c569c06d5e0e45368d1525")]
[assembly: AssemblyProduct("Skip Intros")]
[assembly: AssemblyTitle("Skip Intros")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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")]
	[Embedded]
	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")]
	[Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace GoblinCleanupSkipIntros
{
	[BepInPlugin("GoblinCleanupSkipIntros", "Skip Intros", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance;

		internal static ManualLogSource Logger;

		internal static Harmony HarmonyInstance;

		public const string Id = "GoblinCleanupSkipIntros";

		public static string Name => "Skip Intros";

		public static string Version => "1.0.0";

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			HarmonyInstance = new Harmony("GoblinCleanupSkipIntros");
			Logger.LogInfo((object)"Plugin GoblinCleanupSkipIntros loaded!");
			HarmonyInstance.PatchAll(typeof(Plugin).Assembly);
			Logger.LogInfo((object)"All patches applied");
		}

		private void OnDestroy()
		{
			Harmony harmonyInstance = HarmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.UnpatchSelf();
			}
			Logger.LogInfo((object)"Plugin unloaded");
		}
	}
}
namespace GoblinCleanupSkipIntros.Patches
{
	[HarmonyPatch]
	public static class BootPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Boot), "Start")]
		private static bool LoadMainMenuDirectlyPrefix(Boot __instance)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)"LoadMainMenuDirectlyPrefix: Start of prefix");
			try
			{
				Scene activeScene = SceneManager.GetActiveScene();
				Plugin.Logger.LogInfo((object)("LoadMainMenuDirectlyPrefix: Active scene is " + ((Scene)(ref activeScene)).name));
				GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
				Plugin.Logger.LogInfo((object)$"LoadMainMenuDirectlyPrefix: Found {rootGameObjects.Length} root game objects");
				GameObject[] array = rootGameObjects;
				foreach (GameObject val in array)
				{
					if (((Object)val).name == "CanvasSplash" || ((Object)val).name == "CanvasDisclaimer")
					{
						Plugin.Logger.LogInfo((object)("LoadMainMenuDirectlyPrefix: Setting " + ((Object)val).name + " to inactive"));
						val.SetActive(false);
					}
					else if (((Object)val).name == "CanvasLoading")
					{
						Plugin.Logger.LogInfo((object)"LoadMainMenuDirectlyPrefix: Setting CanvasLoading to active");
						val.SetActive(true);
						CanvasGroup component = val.GetComponent<CanvasGroup>();
						if ((Object)(object)component != (Object)null)
						{
							Plugin.Logger.LogInfo((object)"LoadMainMenuDirectlyPrefix: Setting CanvasLoading CanvasGroup alpha to 1");
							component.alpha = 1f;
							component.interactable = true;
							component.blocksRaycasts = true;
						}
					}
				}
				Plugin.Logger.LogInfo((object)"LoadMainMenuDirectlyPrefix: Performing PlayerPrefs cleanups");
				Cursor.visible = false;
				PlayerPrefs.DeleteKey("LastLobbyID");
				Plugin.Logger.LogInfo((object)"LoadMainMenuDirectlyPrefix: Setting booted to true");
				__instance.booted = true;
				Plugin.Logger.LogInfo((object)"LoadMainMenuDirectlyPrefix: Starting LoadMainMenuAsync coroutine on Plugin.Instance");
				((MonoBehaviour)Plugin.Instance).StartCoroutine(LoadMainMenuAsync());
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"LoadMainMenuDirectlyPrefix: Exception occurred: {arg}");
			}
			Plugin.Logger.LogInfo((object)"LoadMainMenuDirectlyPrefix: End of prefix, returning false");
			return false;
		}

		private static IEnumerator LoadMainMenuAsync()
		{
			Plugin.Logger.LogInfo((object)"LoadMainMenuAsync: Coroutine started");
			yield return null;
			Plugin.Logger.LogInfo((object)"LoadMainMenuAsync: After yield return null");
			Plugin.Logger.LogInfo((object)"LoadMainMenuAsync: Starting SceneManager.LoadSceneAsync('MainMenu')");
			AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("MainMenu");
			if (asyncLoad == null)
			{
				Plugin.Logger.LogError((object)"LoadMainMenuAsync: LoadSceneAsync('MainMenu') returned null!");
				yield break;
			}
			while (!asyncLoad.isDone)
			{
				yield return null;
			}
			Plugin.Logger.LogInfo((object)"LoadMainMenuAsync: Loading completed! Destroying CanvasLoading.");
			GameObject val = GameObject.Find("CanvasLoading");
			if ((Object)(object)val != (Object)null)
			{
				val.SetActive(false);
				Object.Destroy((Object)(object)val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIHome), "Start")]
		private static void SkipHomeScreen()
		{
			Plugin.Logger.LogInfo((object)"SkipHomeScreen: Bypassing UIHome screen");
			UIHome.noMoreHome = true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}