Decompiled source of Smokin v1.0.0

Smokin.dll

Decompiled a year 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 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("Smokin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Smokin")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d8b7f80d-a23c-47f8-9120-65f13695aab2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Smokin;

[HarmonyPatch(typeof(GrabbableObject))]
internal class HauntedMaskItemPatch
{
	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static void hauntedMaskItemPostfix(ref GrabbableObject __instance)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		AudioClip newSFX = Smokin.newSFX;
		ManualLogSource val = Logger.CreateLogSource("mattplays-smokin");
		if ((Object)__instance != (Object)null && (Object)((Component)__instance).GetComponent<HauntedMaskItem>() != (Object)null)
		{
			((Component)__instance).GetComponent<HauntedMaskItem>().maskAttachAudio = newSFX;
			((Component)__instance).GetComponent<HauntedMaskItem>().maskAttachAudioLocal = newSFX;
			val.LogMessage((object)((Object)((Component)__instance).GetComponent<HauntedMaskItem>().maskAttachAudio).name);
			val.LogMessage((object)((Object)((Component)__instance).GetComponent<HauntedMaskItem>().maskAttachAudioLocal).name);
		}
	}
}
[BepInPlugin("mattplays.smokin", "Smokin", "1.0.0")]
public class Smokin : BaseUnityPlugin
{
	private const string modGUID = "mattplays.smokin";

	private const string modName = "Smokin";

	private const string modVersion = "1.0.0";

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

	private static string audioFile = "smokin.mp3";

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

	private static Smokin instance;

	internal ManualLogSource mls;

	internal static AudioClip newSFX;

	private void Awake()
	{
		if ((Object)(object)instance == (Object)null)
		{
			instance = this;
		}
		mls = Logger.CreateLogSource("mattplays.smokin");
		mls.LogInfo((object)"Smokin is loading...");
		newSFX = LoadAudioClip(uPath + audioFile);
		if ((Object)(object)newSFX == (Object)null)
		{
			mls.LogError((object)"Failed to load audio clip");
		}
		harmony.PatchAll(typeof(HauntedMaskItemPatch));
		mls.LogInfo((object)"Smokin has loaded! Smokin!");
	}

	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.smokin");
		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;
	}
}