Decompiled source of BuiltinTurnOFF v1.0.2

plugins/BuiltInTurnOFF.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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: AssemblyTitle("Guild")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Guild")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ba17b609-0f9b-40d4-af88-2ee23a0554ae")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.reckss.erenshor.disablebuiltinDPS", "Disable Built-in DPS UI", "1.0.2")]
public class DisableBuiltInDPS : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <DisableCoroutine>d__6 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public DisableBuiltInDPS <>4__this;

		private string <current>5__1;

		private float <elapsed>5__2;

		private GameObject <target>5__3;

		private GameObject <uiRoot>5__4;

		private Transform <t>5__5;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<current>5__1 = null;
			<target>5__3 = null;
			<uiRoot>5__4 = null;
			<t>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				Scene activeScene = SceneManager.GetActiveScene();
				<current>5__1 = ((Scene)(ref activeScene)).name;
				if (Array.IndexOf(<>4__this._skipScenes, <current>5__1) >= 0)
				{
					return false;
				}
				<elapsed>5__2 = 0f;
				<target>5__3 = null;
				break;
			}
			case 1:
				<>1__state = -1;
				<elapsed>5__2 += Time.unscaledDeltaTime;
				<uiRoot>5__4 = null;
				break;
			}
			if (<elapsed>5__2 < 5f)
			{
				<uiRoot>5__4 = GameObject.Find("UI");
				if ((Object)(object)<uiRoot>5__4 != (Object)null)
				{
					<t>5__5 = <uiRoot>5__4.transform.Find("UIElements/DPSMeters/DPSPAR");
					if ((Object)(object)<t>5__5 != (Object)null)
					{
						<target>5__3 = ((Component)<t>5__5).gameObject;
						goto IL_0121;
					}
					<t>5__5 = null;
				}
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			goto IL_0121;
			IL_0121:
			if ((Object)(object)<target>5__3 != (Object)null)
			{
				<target>5__3.SetActive(false);
				((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)$"[DisableBuiltInDPS] Disabled built-in DPS UI after {<elapsed>5__2:F2}s on scene '{<current>5__1}'");
			}
			else
			{
				((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)string.Format("[DisableBuiltInDPS] Could not find DPSPAR under '{0}/{1}' after {2}s on scene '{3}'", "UI", "UIElements/DPSMeters/DPSPAR", 5f, <current>5__1));
			}
			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 UiRootName = "UI";

	private const string PathFromUi = "UIElements/DPSMeters/DPSPAR";

	private const float MaxRetryTime = 5f;

	private readonly string[] _skipScenes = new string[2] { "Menu", "LoadScene" };

	private void Awake()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
		((MonoBehaviour)this).StartCoroutine(DisableCoroutine());
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (Array.IndexOf(_skipScenes, ((Scene)(ref scene)).name) < 0)
		{
			((MonoBehaviour)this).StartCoroutine(DisableCoroutine());
		}
	}

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