Decompiled source of CustomBoomboxSound v1.0.0

BepInEx/plugins/CustomBoomboxSound/CustomBoomboxSound.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CustomBoomboxSound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomBoomboxSound")]
[assembly: AssemblyTitle("CustomBoomboxSound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 CustomBoomboxSound
{
	[BepInPlugin("com.masterxolos.customboomboxsound", "Custom Boombox Sound", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ValuableBoombox), "Start")]
		public class PatchBoomboxStart
		{
			private static void Postfix(ValuableBoombox __instance)
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.soundBoomboxMusic != null && (Object)(object)customClip != (Object)null)
				{
					__instance.soundBoomboxMusic.Sounds = (AudioClip[])(object)new AudioClip[1] { customClip };
					__instance.soundBoomboxMusic.Stop();
					__instance.soundBoomboxMusic.Play(((Component)__instance).transform.position, 1f, 1f, 1f, 1f);
					Logger.LogInfo((object)"Replaced boombox music with custom sound!");
				}
				else
				{
					Logger.LogWarning((object)"Failed to replace boombox music: missing reference.");
				}
			}
		}

		internal static ManualLogSource Logger;

		internal static AudioClip customClip;

		private void Awake()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Invalid comparison between Unknown and I4
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Custom Boombox Sound plugin loaded!");
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "custom.ogg");
			if (!File.Exists(text))
			{
				Logger.LogError((object)"custom.ogg not found in plugin folder! Please add your .ogg file.");
				return;
			}
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)14);
			UnityWebRequestAsyncOperation val = audioClip.SendWebRequest();
			while (!((AsyncOperation)val).isDone)
			{
			}
			if ((int)audioClip.result == 1)
			{
				customClip = DownloadHandlerAudioClip.GetContent(audioClip);
				Logger.LogInfo((object)"Successfully loaded custom.ogg");
				Harmony val2 = new Harmony("com.masterxolos.customboomboxsound");
				val2.PatchAll();
			}
			else
			{
				Logger.LogError((object)"Failed to load custom.ogg");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CustomBoomboxSound";

		public const string PLUGIN_NAME = "CustomBoomboxSound";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}