Decompiled source of MineMineMine v1.0.1

MineMineMine.dll

Decompiled a year ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MineMineMine.Patches;
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: AssemblyTitle("MineMineMine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MineMineMine")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7ad9ed72-13f7-4029-8f2a-3bd6a540e2fb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MineMineMine
{
	[BepInPlugin("mattplays.MineMineMine", "MineMineMine", "1.0.0")]
	public class MineMineMine : BaseUnityPlugin
	{
		private const string modGUID = "mattplays.MineMineMine";

		private const string modName = "MineMineMine";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("mattplays.MineMineMine");

		private static string audioFile = "mine.mp3";

		private static List<AudioClip> clips = new List<AudioClip>();

		private static string uPath = Path.Combine(Paths.PluginPath + "\\mattplays-MineMineMine\\");

		private static MineMineMine instance;

		internal ManualLogSource mls;

		internal static AudioClip[] newSFX;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("mattplays.MineMineMine");
			mls.LogInfo((object)"MineMineMine is loading...");
			LoadAudioClip(uPath + audioFile);
			newSFX = clips.ToArray();
			harmony.PatchAll(typeof(HoardingBugAudioPatch));
			mls.LogInfo((object)"MineMineMine has loaded! Mine!");
		}

		private static void LoadAudioClip(string filepath)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			ManualLogSource val = Logger.CreateLogSource("mattplays.MineMineMine");
			val.LogInfo((object)("Loading audio clip from " + filepath));
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(filepath, (AudioType)13);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			if (audioClip.error != null)
			{
				val.LogError((object)"Failed to load audio clip");
			}
			AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
			if (Object.op_Implicit((Object)(object)content) && (int)content.loadState == 2)
			{
				val.LogInfo((object)"Loaded audio clip successfully!");
				clips.Add(content);
			}
		}
	}
}
namespace MineMineMine.Patches
{
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoardingBugAudioPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void chitterSFXPatch(ref AudioClip[] ___chitterSFX)
		{
			AudioClip[] newSFX = MineMineMine.newSFX;
			___chitterSFX = newSFX;
		}
	}
}