Decompiled source of SkipIntro v1.0.0

BepInEx/plugins/SkipIntro.dll

Decompiled 5 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SkipIntro")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0")]
[assembly: AssemblyProduct("SkipIntro")]
[assembly: AssemblyTitle("SkipIntro")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SkipIntro
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SkipIntro";

		public const string PLUGIN_NAME = "SkipIntro";

		public const string PLUGIN_VERSION = "0.0.0";
	}
}
namespace MycopunkSkipIntro
{
	[BepInPlugin("com.yourname.skipintro", "SkipIntro", "1.0.0")]
	[MycoMod(/*Could not decode attribute arguments.*/)]
	public class SkipIntroPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.yourname.mycopunkskipintro";

		public const string PluginName = "Mycopunk Skip Intro";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("com.yourname.skipintro");
			val.PatchAll(typeof(IntroPatches));
			Logger.LogInfo((object)(val.Id + " loaded!"));
		}
	}
	internal class IntroPatches
	{
		[HarmonyPatch(typeof(StartMenu), "Awake")]
		[HarmonyPrefix]
		private static bool SkipIntroPrefix(StartMenu __instance)
		{
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			Traverse val = Traverse.Create(typeof(StartMenu));
			if (!val.Field("hasInitialized").GetValue<bool>())
			{
				SkipIntroPlugin.Logger.LogInfo((object)"Skipping Mycopunk intro sequence via Awake prefix...");
				Traverse val2 = Traverse.Create((object)__instance);
				val.Field("hasInitialized").SetValue((object)true);
				Type type = AccessTools.TypeByName("GameManager");
				if (type != null)
				{
					Traverse.Create(type).Method("InitializeSettingRecursive", new Type[1] { typeof(Transform) }, (object[])null).GetValue(new object[1] { ((Component)val2.Field("settingsWindow").GetValue<Window>()).transform });
				}
				else
				{
					SkipIntroPlugin.Logger.LogWarning((object)"GameManager type not found—settings initialization may be skipped.");
				}
				val2.Field("initializeScreen").GetValue<GameObject>().SetActive(false);
				((Component)val2.Field("startScreen").GetValue<RectTransform>()).gameObject.SetActive(true);
				val2.Field("bootingScreen").GetValue<GameObject>().SetActive(false);
				val2.Field("splashScreen").GetValue<GameObject>().SetActive(false);
				val2.Field("initializeBar").GetValue<GameObject>().SetActive(false);
				((Component)val2.Field("logText").GetValue<TextMeshProUGUI>()).gameObject.SetActive(false);
				val2.Field("initializeStuff").GetValue<GameObject>().SetActive(false);
				((Component)val2.Field("verifiedText").GetValue<TextMeshProUGUI>()).gameObject.SetActive(false);
				((Component)val2.Field("loadingBar").GetValue<Image>()).gameObject.SetActive(false);
				RectTransform value = val2.Field("initializeWipe").GetValue<RectTransform>();
				value.anchoredPosition = new Vector2(0f, -2160f);
				val2.Field("wipeChild").GetValue<RectTransform>().anchoredPosition = new Vector2(0f, 2160f);
				((Component)value).gameObject.SetActive(false);
				Type type2 = AccessTools.TypeByName("PlayerInput");
				if (type2 != null)
				{
					Traverse.Create(type2).Method("UnlockCursor", Array.Empty<object>()).GetValue();
				}
				else
				{
					SkipIntroPlugin.Logger.LogWarning((object)"PlayerInput type not found—cursor may remain locked.");
				}
				if (!val2.Field("isMusicPlaying").GetValue<bool>())
				{
					object value2 = val2.Field("music").GetValue();
					if (value2 != null && value2.GetType().ToString().Contains("AK.Wwise.Event"))
					{
						Traverse.Create(value2).Method("Post", new Type[1] { typeof(GameObject) }, (object[])null).GetValue(new object[1] { ((Component)__instance).gameObject });
						val2.Field("isMusicPlaying").SetValue((object)true);
					}
				}
				Type type3 = AccessTools.TypeByName("PlayerData");
				if (type3 != null)
				{
					object value3 = Traverse.Create(type3).Field("Instance").GetValue();
					if (value3 != null)
					{
						object value4 = Traverse.Create(value3).Property("ProfileConfig", (object[])null).GetValue();
						if (value4 != null)
						{
							object value5 = Traverse.Create(value4).Property("CurrentProfile", (object[])null).GetValue();
							if (value5 != null)
							{
								bool value6 = Traverse.Create(value5).Method("IsValid", Array.Empty<object>()).GetValue<bool>();
								int value7 = Traverse.Create(value3).Method("GetFlag", new Type[1] { typeof(string) }, (object[])null).GetValue<int>(new object[1] { "autohub" });
								if (!value6 && value7 == 0)
								{
									Traverse.Create(value3).Method("SetFlag", new Type[2]
									{
										typeof(string),
										typeof(int)
									}, (object[])null).GetValue(new object[2] { "autohub", 1 });
									val2.Method("Host", Array.Empty<object>()).GetValue();
								}
							}
						}
					}
				}
				else
				{
					SkipIntroPlugin.Logger.LogWarning((object)"PlayerData type not found—skipping profile/auto-host check.");
				}
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}