Decompiled source of NoUpdateScreen v1.2.1

NoUpdateScreen.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoUpdateTitle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fcb4b85e8cc7af32862e6c626a31befc95369c7f")]
[assembly: AssemblyProduct("NoUpdateTitle")]
[assembly: AssemblyTitle("NoUpdateTitle")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace NoUpdateTitle
{
	[BepInPlugin("com.onergy.noupdatescreen", "NoUpdateScreen", "1.0.0")]
	public class NoUpdateScreenPlugin : BaseUnityPlugin
	{
		public static class MyPluginInfo
		{
			public const string PLUGIN_GUID = "com.onergy.noupdatescreen";

			public const string PLUGIN_NAME = "NoUpdateScreen";

			public const string PLUGIN_VERSION = "1.0.0";

			private static bool _screenDestroyed;

			public static bool ScreenDestroyed
			{
				get
				{
					return _screenDestroyed;
				}
				set
				{
					_screenDestroyed = value;
				}
			}
		}

		[CompilerGenerated]
		private sealed class <AttemptDestroyModalCoroutine>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NoUpdateScreenPlugin <>4__this;

			private GameObject <targetObject>5__1;

			private int <maxAttempts>5__2;

			private float <delayBetweenAttempts>5__3;

			private int <i>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <AttemptDestroyModalCoroutine>d__9(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<targetObject>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<targetObject>5__1 = null;
					<maxAttempts>5__2 = 10;
					<delayBetweenAttempts>5__3 = 0.05f;
					Log.LogInfo((object)string.Format("[NoUpdateScreen] Starting coroutine to find '{0}' with {1} attempts.", "Modal(Clone)", <maxAttempts>5__2));
					<i>5__4 = 0;
					break;
				case 1:
					<>1__state = -1;
					<targetObject>5__1 = GameObject.Find("Modal(Clone)");
					if ((Object)(object)<targetObject>5__1 != (Object)null)
					{
						Log.LogInfo((object)string.Format("[NoUpdateScreen] Found '{0}' on attempt {1}. Destroying object.", "Modal(Clone)", <i>5__4 + 1));
						Object.Destroy((Object)(object)<targetObject>5__1);
						MyPluginInfo.ScreenDestroyed = true;
						return false;
					}
					Log.LogDebug((object)string.Format("[NoUpdateScreen] Attempt {0}: '{1}' not found. Retrying in {2}s.", <i>5__4 + 1, "Modal(Clone)", <delayBetweenAttempts>5__3));
					<i>5__4++;
					break;
				}
				if (<i>5__4 < <maxAttempts>5__2)
				{
					<>2__current = (object)new WaitForSeconds(<delayBetweenAttempts>5__3);
					<>1__state = 1;
					return true;
				}
				if (!MyPluginInfo.ScreenDestroyed)
				{
					Log.LogWarning((object)string.Format("[NoUpdateScreen] Failed to find and destroy '{0}' after {1} attempts in '{2}'.", "Modal(Clone)", <maxAttempts>5__2, "Title"));
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string TargetModalName = "Modal(Clone)";

		private const string MainMenuSceneName = "Title";

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"[NoUpdateScreen] Plugin com.onergy.noupdatescreen is loaded!");
			Log.LogInfo((object)"[NoUpdateScreen] Attempting to subscribe to SceneManager.sceneLoaded event.");
			SceneManager.sceneLoaded += OnSceneLoaded;
			ManualLogSource log = Log;
			Scene activeScene = SceneManager.GetActiveScene();
			log.LogInfo((object)("[NoUpdateScreen] Subscription to SceneManager.sceneLoaded attempted. Current active scene: " + ((Scene)(ref activeScene)).name));
		}

		private void OnDestroy()
		{
			Log.LogInfo((object)"[NoUpdateScreen] Plugin is being unloaded. Unsubscribing from scene events.");
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Invalid comparison between Unknown and I4
			ManualLogSource log = Log;
			object[] obj = new object[4]
			{
				((Scene)(ref scene)).name,
				((Scene)(ref scene)).buildIndex,
				mode,
				null
			};
			Scene activeScene = SceneManager.GetActiveScene();
			obj[3] = ((Scene)(ref activeScene)).name;
			log.LogInfo((object)string.Format("[NoUpdateScreen] SCENE LOADED: Name='{0}' (Build Index: {1}, Mode: {2}). Current active scene: {3}", obj));
			if (((Scene)(ref scene)).name == "Title" && (int)mode == 0)
			{
				Log.LogInfo((object)"[NoUpdateScreen] Targeted Main Menu scene 'Title' detected. Initiating modal destruction attempt.");
				((MonoBehaviour)this).StartCoroutine(AttemptDestroyModalCoroutine());
			}
		}

		[IteratorStateMachine(typeof(<AttemptDestroyModalCoroutine>d__9))]
		private IEnumerator AttemptDestroyModalCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AttemptDestroyModalCoroutine>d__9(0)
			{
				<>4__this = this
			};
		}
	}
}