Decompiled source of CutsceneSkipFix v1.0.0

Mods/CutsceneSkipFix.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using CutsceneSkipFix;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using StressLevelZero.Utilities;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Video;
using Valve.VR;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(CutsceneSkipFixMod), "CutsceneSkipFix", "1.0.0", "zaynethedev", null)]
[assembly: MelonGame("Stress Level Zero", "BONEWORKS")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 CutsceneSkipFix
{
	public class CutsceneSkipFixMod : MelonMod
	{
		internal static void SkipToNextLevel(GameControl_Theatrigon theatrigon)
		{
			if (!theatrigon._hasLoadedLevel)
			{
				theatrigon._hasLoadedLevel = true;
				KillActiveLoader();
				int num = NextSceneIndex();
				MelonLogger.Msg($"Skipping cutscene, loading scene {num}");
				BoneworksSceneManager.LoadScene(num);
			}
		}

		private static void KillActiveLoader()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			SceneLoader active = SceneLoader._active;
			if ((Object)(object)active == (Object)null)
			{
				return;
			}
			((MonoBehaviour)active).StopAllCoroutines();
			CVROverlay overlay = OpenVR.Overlay;
			if (overlay != null)
			{
				if (active.progressBarOverlayHandle != 0L)
				{
					overlay.HideOverlay(active.progressBarOverlayHandle);
				}
				if (active.loadingScreenOverlayHandle != 0L)
				{
					overlay.HideOverlay(active.loadingScreenOverlayHandle);
				}
			}
			Object.Destroy((Object)(object)((Component)active).gameObject);
			SceneLoader._active = null;
			PreloadLevel.onPreloadStartDelegate = null;
			PreloadLevel.onPreloadCompleteDelegate = null;
		}

		private static int NextSceneIndex()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (((Scene)(ref sceneAt)).name.StartsWith("scene_theatrigon_movie"))
				{
					return ((Scene)(ref sceneAt)).buildIndex + 1;
				}
			}
			Scene activeScene = SceneManager.GetActiveScene();
			return ((Scene)(ref activeScene)).buildIndex + 1;
		}
	}
	[HarmonyPatch(typeof(GameControl_Theatrigon), "Stop")]
	internal static class StopPatch
	{
		private static bool Prefix(GameControl_Theatrigon __instance)
		{
			__instance._preShow = false;
			__instance._hasPlayed = true;
			Coroutine playPlaylistCoroutine = __instance._playPlaylistCoroutine;
			if (playPlaylistCoroutine != null)
			{
				((MonoBehaviour)__instance).StopCoroutine(playPlaylistCoroutine);
				__instance._playPlaylistCoroutine = null;
				VideoPlayer videoPlayer = __instance.videoPlayer;
				if (videoPlayer != null)
				{
					videoPlayer.Stop();
				}
			}
			CutsceneSkipFixMod.SkipToNextLevel(__instance);
			return false;
		}
	}
	[HarmonyPatch(typeof(GameControl_Theatrigon), "NEXTLEVEL")]
	internal static class NextLevelPatch
	{
		private static bool Prefix(GameControl_Theatrigon __instance)
		{
			CutsceneSkipFixMod.SkipToNextLevel(__instance);
			return false;
		}
	}
}