Decompiled source of NoMusicDistortion v1.0.4

BepInEx/Plugins/NoMusicDistortion.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoMusicDistortion")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoMusicDistortion")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ac8035d-9eef-4312-a8a1-37a4bce84ae4")]
[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")]
namespace NoMusicDistortion
{
	[BepInPlugin("FlipMods.NoMusicDistortion", "NoMusicDistortion", "1.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static Plugin instance;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			_harmony = new Harmony("NoMusicDistortion");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"NoMusicDistortion loaded");
			instance = this;
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.NoMusicDistortion";

		public const string PLUGIN_NAME = "NoMusicDistortion";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}
namespace NoMusicDistortion.Patches
{
	[HarmonyPatch]
	internal class NoMusicDistortionPatcher
	{
		[HarmonyPatch(typeof(BoomboxItem), "__initializeVariables")]
		[HarmonyPrefix]
		public static void PatchBoombox(BoomboxItem __instance)
		{
			__instance.boomboxAudio.dopplerLevel = 0f;
		}

		[HarmonyPatch(typeof(TVScript), "__initializeVariables")]
		[HarmonyPrefix]
		public static void PatchTelevision(TVScript __instance)
		{
			__instance.tvSFX.dopplerLevel = 0f;
		}

		[HarmonyPatch(typeof(AutoParentToShip), "__initializeVariables")]
		[HarmonyPrefix]
		public static void PatchRecordPlayer(AutoParentToShip __instance)
		{
			if (((Object)__instance).name.Contains("RecordPlayer"))
			{
				Transform obj = ((Component)__instance).transform.Find("Audio");
				AudioSource val = ((obj != null) ? ((Component)obj).GetComponent<AudioSource>() : null);
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log("Failed to find audio source for RecordPlayer. You should probably call the police.");
				}
				else
				{
					val.dopplerLevel = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "__initializeVariables")]
		[HarmonyPrefix]
		public static void PatchItemDropship(ItemDropship __instance)
		{
			Transform obj = ((Component)__instance).transform.Find("Music");
			AudioSource val = ((obj != null) ? ((Component)obj).GetComponent<AudioSource>() : null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log("Failed to find audio source for ItemDropship. You should probably call the police.");
			}
			else
			{
				val.dopplerLevel = 0f;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "__initializeVariables")]
		[HarmonyPrefix]
		public static void PatchShipSpeaker()
		{
			GameObject obj = GameObject.Find("SpeakerAudio");
			AudioSource val = ((obj != null) ? obj.GetComponent<AudioSource>() : null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log("Failed to find audio source for ShipSpeaker. You should probably call the police.");
			}
			else
			{
				val.dopplerLevel = 0f;
			}
		}

		[HarmonyPatch(typeof(AudioSource), "Play", new Type[] { })]
		[HarmonyPrefix]
		public static void RemoveDopplerEffect(AudioSource __instance)
		{
			__instance.dopplerLevel = 0f;
		}

		[HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip) })]
		[HarmonyPrefix]
		public static void RemoveDopplerEffect2(AudioClip clip, AudioSource __instance)
		{
			__instance.dopplerLevel = 0f;
		}
	}
}