Decompiled source of Loading Screen Skipper v0.0.4

LoadingScreenSkip.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
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 CG.Client.Player.HUD;
using CG.Client.UI;
using CG.Game.Player;
using CG.GameLoopStateMachine.GameStates;
using CG.Input;
using CG.Ship.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UIElements;
using VoidManager;
using VoidManager.MPModChecks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("LoadingScreenSkip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Skips intro cutscenes and various loading screens.")]
[assembly: AssemblyFileVersion("0.0.4.0")]
[assembly: AssemblyInformationalVersion("0.0.4+76f01a9a2e8fa9271615be3bde6cb414fcd2463f")]
[assembly: AssemblyProduct("LoadingScreenSkip")]
[assembly: AssemblyTitle("Skips intro cutscenes and various loading screens.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.4.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 LoadingScreenSkip
{
	[BepInPlugin("18107.LoadingScreenSkip", "Loading Screen Skipper", "0.0.4")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		public static BepinPlugin Instance { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.LoadingScreenSkip");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"LoadingScreenSkip loaded");
		}
	}
	[HarmonyPatch(typeof(CursorUtility), "ShowCursor")]
	internal class CursorUtilityPatch
	{
		private static readonly FieldInfo mainMenuField = AccessTools.Field(typeof(EscapeMenu), "_mainMenu");

		private static readonly FieldInfo respawnButtonField = AccessTools.Field(typeof(MainMenu), "_forceRespawnButton");

		private static readonly FieldInfo cloneTubesField = AccessTools.Field(typeof(SpawnSystem), "clonetubes");

		private static void Postfix(IShowCursorSource source, bool show)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			MenuScreenController val = (MenuScreenController)(object)((source is MenuScreenController) ? source : null);
			if ((Object)(object)val == (Object)null || !show || (Object)(object)SpawnSystem.Instance == (Object)null)
			{
				return;
			}
			foreach (CloneTube item in (List<CloneTube>)cloneTubesField.GetValue(SpawnSystem.Instance))
			{
				if ((Object)(object)item.GetOccupant() == (Object)(object)LocalPlayer.Instance)
				{
					return;
				}
			}
			EscapeMenu obj = val.FindScreen<EscapeMenu>();
			MainMenu obj2 = (MainMenu)mainMenuField.GetValue(obj);
			Button val2 = (Button)respawnButtonField.GetValue(obj2);
			((VisualElement)val2).SetEnabled(true);
		}
	}
	[HarmonyPatch(typeof(FadeController), "FadeToClear")]
	internal class FadeToClearPatch
	{
		[HarmonyPrefix]
		private static void DurationReplacement(ref float duration)
		{
			duration = 0f;
		}
	}
	[HarmonyPatch(typeof(FadeController), "FadeToClearDelayed")]
	internal class FadeToClearDelayedPatch
	{
		[HarmonyPrefix]
		private static void DurationReplacement(ref float delay, ref float duration)
		{
			delay = 0f;
			duration = 0f;
		}
	}
	[HarmonyPatch(typeof(GSIntro), "OnEnter")]
	internal class GSIntroPatch
	{
		private static void Postfix(ref float ____timer)
		{
			____timer = 0f;
		}
	}
	[HarmonyPatch(typeof(HUD_BootSequence), "OnLifeformStateChanged")]
	internal class HUD_BootSequencePatch
	{
		private static readonly MethodInfo bootSequenceComplete = AccessTools.Method(typeof(HUD_BootSequence), "OnBootSequenceComplete", (Type[])null, (Type[])null);

		private static bool Prefix(HUD_BootSequence __instance, ILifeform lifeform, UnityEvent ___OnAlive, ref bool ____isFirstTime, ref float ___backgroundFadeDelay)
		{
			if (lifeform != LocalPlayer.Instance)
			{
				return true;
			}
			if (____isFirstTime)
			{
				___OnAlive.Invoke();
				____isFirstTime = false;
				___backgroundFadeDelay = 0f;
				bootSequenceComplete.Invoke(__instance, new object[0]);
				return false;
			}
			return true;
		}

		public static void Nop()
		{
		}
	}
	[HarmonyPatch(typeof(MainMenuTimelineController), "Update")]
	internal class MainMenuTimelineControllerPatch
	{
		private static void Prefix(ref bool ____skipIntro)
		{
			____skipIntro = true;
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.LoadingScreenSkip";

		public const string PLUGIN_NAME = "LoadingScreenSkip";

		public const string USERS_PLUGIN_NAME = "Loading Screen Skipper";

		public const string PLUGIN_VERSION = "0.0.4";

		public const string PLUGIN_DESCRIPTION = "Skips intro cutscenes and various loading screens. Client-Side.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107, Dragon";

		public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Loading_Screen_Skipper";
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "18107, Dragon";

		public override string Description => "Skips intro cutscenes and various loading screens. Client-Side.";

		public override string ThunderstoreID => "VoidCrewModdingTeam/Loading_Screen_Skipper";
	}
}