Decompiled source of PoppinBottles v0.0.2

PoppinBottles.dll

Decompiled 5 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PoppinBottles;
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("PoppinBottles")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PoppinBottles")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bfd1e6d8-cfdb-4f53-9bf6-82e6172064e1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(GrabbableObject))]
internal class PopBottlesPatch
{
	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static async void PatchBottleAudio(GrabbableObject __instance)
	{
		if (!((Object)__instance == (Object)null))
		{
			Item item = __instance.itemProperties;
			if (!((Object)(object)item == (Object)null) && !(((Object)item).name != "BottleBin") && (Object)(object)Plugin.BottlesClip != (Object)null)
			{
				__instance.itemProperties.grabSFX = Plugin.BottlesClip;
			}
		}
	}
}
namespace PoppinBottles;

[BepInPlugin("com.github.jh0823.PopBottles", "PoppinBottles", "0.0.0.1")]
[BepInProcess("Lethal Company.exe")]
public class Plugin : BaseUnityPlugin
{
	private readonly Harmony _harmony = new Harmony("com.github.jh0823.PopBottles");

	private static Plugin _instance;

	public static AudioClip BottlesClip;

	private static ManualLogSource Log;

	private const string FileName = "bottles.mp3";

	public Plugin()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		_instance = this;
	}

	private async void Awake()
	{
		if ((Object)(object)_instance == (Object)null)
		{
			_instance = this;
		}
		Log = Logger.CreateLogSource("com.github.jh0823.PopBottles");
		_harmony.PatchAll();
		Log.LogInfo((object)"PoppinBottles has been loaded");
		LoadBottlesClip();
		Log.LogInfo((object)"Finding audio file");
	}

	private async void LoadBottlesClip()
	{
		string fullFileName = GetPath();
		UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(fullFileName, (AudioType)13);
		audioClip.SendWebRequest();
		while (!audioClip.isDone)
		{
			await Task.Delay(10);
		}
		if ((int)audioClip.result == 1)
		{
			BottlesClip = DownloadHandlerAudioClip.GetContent(audioClip);
			Log.LogInfo((object)"Audio clip found");
		}
		else
		{
			Log.LogError((object)"Could not find audio clip");
		}
	}

	private static string GetPath()
	{
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string path = Path.Combine(directoryName, ".\\bottles.mp3");
		return Path.GetFullPath(path);
	}
}
public static class PluginProperties
{
	public const string MODGUID = "com.github.jh0823.PopBottles";

	public const string MODNAME = "PoppinBottles";

	public const string MODVERSION = "0.0.0.1";
}