Decompiled source of ZennHorn v1.0.1

ZennHorn.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 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("ModLethalCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModLethalCompany")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("04e71039-6bee-4c32-80c8-39af37a8fcea")]
[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 ModLethalCompany;

[BepInPlugin("ZennHorn", "ZennHorn", "1.0.0")]
public class ZennHorn : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class PipePatch
	{
		private static List<string> audios = new List<string> { "ZennCrie.mp3" };

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

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

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void AudioPatch(GrabbableObject __instance)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			ManualLogSource val = Logger.CreateLogSource("ZennHorn");
			for (int i = 0; i < audios.Count; i++)
			{
				LoadAudioClip(uPath + audios[i]);
			}
			if ((Object)__instance != (Object)null && (Object)((Component)__instance).GetComponent<NoisemakerProp>() != (Object)null && ((Object)__instance.itemProperties).name == "Airhorn")
			{
				val.LogMessage((object)"We found an Airhorn!!");
				((Component)__instance).GetComponent<NoisemakerProp>().noiseSFX[0] = clips[0];
				((Component)__instance).GetComponent<NoisemakerProp>().noiseSFXFar[0] = clips[1];
				val.LogMessage((object)((Object)((Component)__instance).GetComponent<NoisemakerProp>().noiseSFX[0]).name);
				val.LogMessage((object)((Object)((Component)__instance).GetComponent<NoisemakerProp>().noiseSFXFar[0]).name);
			}
		}

		private static void LoadAudioClip(string filepath)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Invalid comparison between Unknown and I4
			ManualLogSource val = Logger.CreateLogSource("ZennHorn");
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(filepath, (AudioType)13);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			if (audioClip.error != null)
			{
				val.LogError((object)("Error loading sounds: " + filepath + "\n" + audioClip.error));
			}
			AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
			if (Object.op_Implicit(Object.Instantiate((Object)content)) && (int)content.loadState == 2)
			{
				val.LogInfo((object)("Loaded " + filepath));
				((Object)content).name = Path.GetFileName(filepath);
				clips.Add(content);
			}
		}
	}

	private const string modGUID = "ZennHorn";

	private const string modVersion = "1.0.0";

	private const string modName = "ZennHorn";

	private readonly Harmony harmony = new Harmony("ZennHorn");

	private static ZennHorn Instance;

	internal ManualLogSource mls;

	private void Awake()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		mls = Logger.CreateLogSource("ZennHorn");
		mls.LogInfo((object)"The ZennHorn is Loading");
		if ((Object)Instance == (Object)null)
		{
			Instance = this;
		}
		harmony.PatchAll();
		mls.LogInfo((object)"Loaded The ZennHorn Successfully");
	}
}