Decompiled source of NoMoreMotionBlur v2.0.2

No Motion Blur!.dll

Decompiled 2 weeks 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.Configuration;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("No Motion Blur!")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("No Motion Blur!")]
[assembly: AssemblyTitle("No Motion Blur!")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace No_Motion_Blur_;

[BepInPlugin("com.kobbler.nomotionblur", "No More Motion Blur", "2.0.2")]
public class NoMotionBlurPlugin : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <AutoRefreshRoutine>d__8 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public NoMotionBlurPlugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			int num = <>1__state;
			NoMotionBlurPlugin noMotionBlurPlugin = <>4__this;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
			}
			else
			{
				<>1__state = -1;
				((BaseUnityPlugin)noMotionBlurPlugin).Logger.LogInfo((object)"[NoMoreMotionBlur] Auto-refresh mode active.");
			}
			Volume[] array = Object.FindObjectsOfType<Volume>(true);
			MotionBlur val2 = default(MotionBlur);
			foreach (Volume val in array)
			{
				if (!((Object)(object)val.profile == (Object)null))
				{
					if (noMotionBlurPlugin.DisableMotionBlur.Value && val.profile.TryGet<MotionBlur>(ref val2))
					{
						((VolumeComponent)val2).active = false;
					}
					if (noMotionBlurPlugin.DisablePostProcessing.Value)
					{
						((Behaviour)val).enabled = false;
					}
				}
			}
			<>2__current = (object)new WaitForSeconds(2f);
			<>1__state = 1;
			return true;
		}

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

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

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

		private object <>2__current;

		public NoMotionBlurPlugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			int num = <>1__state;
			NoMotionBlurPlugin noMotionBlurPlugin = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(noMotionBlurPlugin.SceneDelaySeconds.Value);
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				Volume[] array = Object.FindObjectsOfType<Volume>(true);
				ManualLogSource logger = ((BaseUnityPlugin)noMotionBlurPlugin).Logger;
				object arg = array.Length;
				Scene activeScene = SceneManager.GetActiveScene();
				logger.LogInfo((object)$"[NoMoreMotionBlur] Found {arg} Volume(s) in scene {((Scene)(ref activeScene)).name}.");
				Volume[] array2 = array;
				MotionBlur val2 = default(MotionBlur);
				foreach (Volume val in array2)
				{
					if (!((Object)(object)val.profile == (Object)null))
					{
						if (noMotionBlurPlugin.DisableMotionBlur.Value && val.profile.TryGet<MotionBlur>(ref val2))
						{
							((VolumeComponent)val2).active = false;
							((BaseUnityPlugin)noMotionBlurPlugin).Logger.LogInfo((object)"[NoMoreMotionBlur] Motion Blur disabled.");
						}
						if (noMotionBlurPlugin.DisablePostProcessing.Value)
						{
							((Behaviour)val).enabled = false;
							((BaseUnityPlugin)noMotionBlurPlugin).Logger.LogInfo((object)"[NoMoreMotionBlur] Post-processing disabled.");
						}
					}
				}
				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 ConfigEntry<bool> DisableMotionBlur;

	private ConfigEntry<bool> DisablePostProcessing;

	private ConfigEntry<bool> UseAutoRefresh;

	private ConfigEntry<float> SceneDelaySeconds;

	private void Awake()
	{
		DisableMotionBlur = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "DisableMotionBlur", true, "Set to true to disable motion blur, false to leave it enabled.");
		DisablePostProcessing = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "DisablePostProcessing", false, "Disables all post-processing effects");
		UseAutoRefresh = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "UseAutoRefresh", false, "Keep disabling effects continuously (instead of once per scene load.) Set to true if OneTime doesn't disable effects");
		SceneDelaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "SceneDelaySeconds", 1f, "Delay after scene load before disabling effects (seconds) Leave at default if you aren't sure what this does");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[NoMoreMotionBlur] Config loaded. DisableMotionBlur={DisableMotionBlur.Value}, DisablePostProcessing={DisablePostProcessing.Value}, UseAutoRefresh={UseAutoRefresh.Value}, SceneDelaySeconds={SceneDelaySeconds.Value}");
		if (UseAutoRefresh.Value)
		{
			((MonoBehaviour)this).StartCoroutine(AutoRefreshRoutine());
			return;
		}
		SceneManager.sceneLoaded += OnSceneLoaded;
		((MonoBehaviour)this).StartCoroutine(OneTimeDisableRoutine());
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (!UseAutoRefresh.Value)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[NoMoreMotionBlur] Scene changed -> " + ((Scene)(ref scene)).name + ", running one-time disable."));
			((MonoBehaviour)this).StartCoroutine(OneTimeDisableRoutine());
		}
	}

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

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