Decompiled source of NoWorldSounds v1.0.0

SoundMute.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using MelonLoader;
using Microsoft.CodeAnalysis;
using NoWorldSounds;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "No World Sounds", "1.0.0", "JohnAlamont", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SoundMute")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SoundMute")]
[assembly: AssemblyTitle("SoundMute")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 NoWorldSounds
{
	public class Core : MelonMod
	{
		private bool noWorldSounds = false;

		private Page menuPage;

		public override void OnInitializeMelon()
		{
			//IL_001d: 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)
			((MelonBase)this).LoggerInstance.Msg("No World Sounds loaded!");
			menuPage = Page.Root.CreatePage("No World Sounds", Color.cyan, 0, true);
			menuPage.CreateBool("Mute World Sounds", Color.cyan, noWorldSounds, (Action<bool>)delegate(bool value)
			{
				noWorldSounds = value;
				((MelonBase)this).LoggerInstance.Msg("World Sounds: " + (noWorldSounds ? "OFF" : "ON"));
				if (!noWorldSounds)
				{
					RestoreWorldSounds();
				}
			});
		}

		public override void OnUpdate()
		{
			if (noWorldSounds)
			{
				MuteWorldSounds();
			}
		}

		private void MuteWorldSounds()
		{
			if ((Object)(object)Player.ControllerRig == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)Player.ControllerRig).transform;
			Transform val = null;
			try
			{
				PhysicsRig physicsRig = Player.GetPhysicsRig();
				if ((Object)(object)physicsRig != (Object)null)
				{
					val = ((Component)physicsRig).transform;
				}
			}
			catch
			{
			}
			AudioSource[] array = Il2CppArrayBase<AudioSource>.op_Implicit(Object.FindObjectsOfType<AudioSource>());
			AudioSource[] array2 = array;
			foreach (AudioSource val2 in array2)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					Transform transform2 = ((Component)val2).transform;
					bool flag = false;
					if ((Object)(object)transform2 == (Object)(object)transform || transform2.IsChildOf(transform))
					{
						flag = true;
					}
					if ((Object)(object)val != (Object)null && ((Object)(object)transform2 == (Object)(object)val || transform2.IsChildOf(val)))
					{
						flag = true;
					}
					val2.mute = !flag;
				}
			}
		}

		private void RestoreWorldSounds()
		{
			AudioSource[] array = Il2CppArrayBase<AudioSource>.op_Implicit(Object.FindObjectsOfType<AudioSource>());
			AudioSource[] array2 = array;
			foreach (AudioSource val in array2)
			{
				if (!((Object)(object)val == (Object)null))
				{
					val.mute = false;
				}
			}
		}
	}
}