Decompiled source of BobombLethalField v1.0.3

Bob-omb Lethal Field.dll

Decompiled 11 months ago
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 Bob_omb_Lethal_Field.Patches;
using HarmonyLib;
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("Bob-omb Lethal Field")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Bob-omb Lethal Field")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c1bd1757-fc91-4e5c-b8c8-4f406e6d7f53")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Bob_omb_Lethal_Field
{
	[BepInPlugin("mattplays-BobombLethalField", "Bob-omb Lethal Field", "1.0.0")]
	public class Bob_omb_Lethal_Field : BaseUnityPlugin
	{
		private const string modGUID = "mattplays-BobombLethalField";

		private const string modName = "Bob-omb Lethal Field";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("mattplays-BobombLethalField");

		private static string audioFile = "trigger.mp3";

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

		private static Bob_omb_Lethal_Field instance;

		internal ManualLogSource mls;

		internal static AudioClip newSFX;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("mattplays-BobombLethalField");
			mls.LogInfo((object)"Bob-omb Lethal Field loding...");
			newSFX = LoadAudioClip(uPath + audioFile);
			if ((Object)(object)newSFX == (Object)null)
			{
				mls.LogError((object)"Failed to load audio clip");
			}
			harmony.PatchAll(typeof(LandmineTriggerPatch));
			mls.LogInfo((object)"Bob-omb Lethal Field loaded!");
		}

		private static AudioClip 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-BobombLethalField");
			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!");
				return content;
			}
			return null;
		}
	}
}
namespace Bob_omb_Lethal_Field.Patches
{
	[HarmonyPatch(typeof(Landmine))]
	internal class LandmineTriggerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void TriggerPatch(ref AudioClip ___mineTrigger)
		{
			AudioClip newSFX = Bob_omb_Lethal_Field.newSFX;
			___mineTrigger = newSFX;
		}
	}
}