Decompiled source of Ambient Muter v1.0.1

AmbientMuter.dll

Decompiled 7 hours 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 System.Security;
using System.Security.Permissions;
using BepInEx;
using FMOD.Studio;
using FMODUnity;
using FistVR;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("AmbientMuter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AmbientMuter")]
[assembly: AssemblyTitle("AmbientMuter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AmbientMuter;

[BepInPlugin("h3vr.ambientmuter", "AmbientMuter", "1.0.1")]
public class AmbientMuterPlugin : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <MuteAmbientDelayed>d__6 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AmbientMuterPlugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			int num = <>1__state;
			AmbientMuterPlugin ambientMuterPlugin = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(4f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				ambientMuterPlugin.MuteAmbientSources();
				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 Bus _musicBus;

	private bool _busObtained;

	private void Awake()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[AmbientMuter] Loaded. Will silence map music and ambient audio.");
	}

	private void TryGetBus()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			_musicBus = RuntimeManager.GetBus("bus:/Music");
			_busObtained = true;
		}
		catch
		{
		}
	}

	private void Update()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!_busObtained)
		{
			TryGetBus();
			return;
		}
		try
		{
			((Bus)(ref _musicBus)).setVolume(0f);
		}
		catch
		{
			_busObtained = false;
		}
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		_busObtained = false;
		((MonoBehaviour)this).StartCoroutine(MuteAmbientDelayed());
	}

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

	private void MuteAmbientSources()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		int num = 0;
		int num2 = 0;
		AudioSource[] array = Object.FindObjectsOfType<AudioSource>();
		foreach (AudioSource val in array)
		{
			if ((Object)(object)((Component)val).GetComponent<FVRPooledAudioSource>() != (Object)null)
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<FVRPhysicalObject>() != (Object)null)
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<Sosig>() != (Object)null)
			{
				num2++;
				continue;
			}
			Scene scene = ((Component)val).gameObject.scene;
			if (((Scene)(ref scene)).name == "DontDestroyOnLoad")
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<BaseUnityPlugin>() != (Object)null)
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<FVRMovementManager>() != (Object)null)
			{
				num2++;
				continue;
			}
			val.mute = true;
			num++;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[AmbientMuter] Scene sweep done. Muted: {num}, Kept: {num2}");
	}
}

bin\Release\net46\AmbientMuter.dll

Decompiled 7 hours 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 System.Security;
using System.Security.Permissions;
using BepInEx;
using FMOD.Studio;
using FMODUnity;
using FistVR;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("AmbientMuter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AmbientMuter")]
[assembly: AssemblyTitle("AmbientMuter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AmbientMuter;

[BepInPlugin("h3vr.ambientmuter", "AmbientMuter", "1.0.0")]
public class AmbientMuterPlugin : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <MuteAmbientDelayed>d__6 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AmbientMuterPlugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			int num = <>1__state;
			AmbientMuterPlugin ambientMuterPlugin = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(4f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				ambientMuterPlugin.MuteAmbientSources();
				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 Bus _musicBus;

	private bool _busObtained;

	private void Awake()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[AmbientMuter] Loaded. Will silence map music and ambient audio.");
	}

	private void TryGetBus()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			_musicBus = RuntimeManager.GetBus("bus:/Music");
			_busObtained = true;
		}
		catch
		{
		}
	}

	private void Update()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!_busObtained)
		{
			TryGetBus();
			return;
		}
		try
		{
			((Bus)(ref _musicBus)).setVolume(0f);
		}
		catch
		{
			_busObtained = false;
		}
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		_busObtained = false;
		((MonoBehaviour)this).StartCoroutine(MuteAmbientDelayed());
	}

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

	private void MuteAmbientSources()
	{
		int num = 0;
		int num2 = 0;
		AudioSource[] array = Object.FindObjectsOfType<AudioSource>();
		foreach (AudioSource val in array)
		{
			if ((Object)(object)((Component)val).GetComponent<FVRPooledAudioSource>() != (Object)null)
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<FVRPhysicalObject>() != (Object)null)
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<Sosig>() != (Object)null)
			{
				num2++;
				continue;
			}
			val.mute = true;
			num++;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[AmbientMuter] Scene sweep done. Muted: {num}, Kept: {num2}");
	}
}

obj\Release\net46\AmbientMuter.dll

Decompiled 7 hours 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 System.Security;
using System.Security.Permissions;
using BepInEx;
using FMOD.Studio;
using FMODUnity;
using FistVR;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("AmbientMuter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AmbientMuter")]
[assembly: AssemblyTitle("AmbientMuter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AmbientMuter;

[BepInPlugin("h3vr.ambientmuter", "AmbientMuter", "1.0.0")]
public class AmbientMuterPlugin : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <MuteAmbientDelayed>d__6 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AmbientMuterPlugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			int num = <>1__state;
			AmbientMuterPlugin ambientMuterPlugin = <>4__this;
			switch (num)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(4f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				ambientMuterPlugin.MuteAmbientSources();
				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 Bus _musicBus;

	private bool _busObtained;

	private void Awake()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[AmbientMuter] Loaded. Will silence map music and ambient audio.");
	}

	private void TryGetBus()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			_musicBus = RuntimeManager.GetBus("bus:/Music");
			_busObtained = true;
		}
		catch
		{
		}
	}

	private void Update()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!_busObtained)
		{
			TryGetBus();
			return;
		}
		try
		{
			((Bus)(ref _musicBus)).setVolume(0f);
		}
		catch
		{
			_busObtained = false;
		}
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		_busObtained = false;
		((MonoBehaviour)this).StartCoroutine(MuteAmbientDelayed());
	}

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

	private void MuteAmbientSources()
	{
		int num = 0;
		int num2 = 0;
		AudioSource[] array = Object.FindObjectsOfType<AudioSource>();
		foreach (AudioSource val in array)
		{
			if ((Object)(object)((Component)val).GetComponent<FVRPooledAudioSource>() != (Object)null)
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<FVRPhysicalObject>() != (Object)null)
			{
				num2++;
				continue;
			}
			if ((Object)(object)((Component)val).GetComponentInParent<Sosig>() != (Object)null)
			{
				num2++;
				continue;
			}
			val.mute = true;
			num++;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[AmbientMuter] Scene sweep done. Muted: {num}, Kept: {num2}");
	}
}