Decompiled source of Whoopie Cushion Held Item Fart v1.0.3

plugins/WhoopieHeldItemFart/WhoopieCushionHeldItemFart_Remake.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 WhoopieHeldItemFart.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WhoopieCushionHeldItemFart_Remake")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WhoopieCushionHeldItemFart_Remake")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a0bf6b3b-b93d-4cfe-a9c3-6f04e2769b13")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WhoopieHeldItemFart
{
	[BepInPlugin("Saryahn.WhoopieHeldItemFart", "Whoopie Cushion Held Item Fart", "1.0.0")]
	public class WhoopieHeldItemFartModBase : BaseUnityPlugin
	{
		private const string modGUID = "Saryahn.WhoopieHeldItemFart";

		private const string modName = "Whoopie Cushion Held Item Fart";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Saryahn.WhoopieHeldItemFart");

		private static WhoopieHeldItemFartModBase Instance;

		private readonly ManualLogSource logger;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		public WhoopieHeldItemFartModBase()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			logger = Logger.CreateLogSource("Saryahn.WhoopieHeldItemFart");
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger.LogInfo((object)"Plugin WhoopieHeldItemFart is loaded!");
			harmony.PatchAll(typeof(WhoopieHeldItemFartModBase));
			harmony.PatchAll(typeof(WhoopieHeldItemFartPatch));
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("WhoopieCushionHeldItemFart_Remake.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "fart bundle");
			if ((Object)(object)Bundle != (Object)null)
			{
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
				logger.LogInfo((object)"Successfully loaded asset bundle");
			}
			else
			{
				logger.LogError((object)"Failed to load asset bundle");
			}
		}
	}
}
namespace WhoopieHeldItemFart.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class WhoopieHeldItemFartPatch
	{
		private static ManualLogSource logger = Logger.CreateLogSource("WhoopieHeldItemFart");

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static async void ReplaceWhoopieSFX(GrabbableObject __instance)
		{
			Item item = __instance.itemProperties;
			if (item.itemName == "Whoopie cushion")
			{
				logger.LogInfo((object)(item.itemName + " spawned"));
				item.grabSFX = WhoopieHeldItemFartModBase.SoundFX[0];
			}
		}
	}
}