Decompiled source of MachoFlowerman v1.0.1

LCMachoFlowerman.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LCMachoFlowerman.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LCMachoFlowerman")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCMachoFlowerman")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("57e3639e-d9f8-4771-bfea-2a71fb445ce2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCMachoFlowerman
{
	[BepInPlugin("AuthorChaos.MachoFlowerman", "MachoFlowerman", "1.0.0.0")]
	public class MachoFlowermanBase : BaseUnityPlugin
	{
		private const string modGUID = "AuthorChaos.MachoFlowerman";

		private const string modName = "MachoFlowerman";

		private const string modVersion = "1.0.0.0";

		private const string dllName = "LCMachoFlowerman.dll";

		private readonly Harmony harmony = new Harmony("AuthorChaos.MachoFlowerman");

		private static MachoFlowermanBase Instance;

		internal ManualLogSource mls;

		internal static AudioClip newAngerSFX;

		internal static AudioClip newNeckSnapSFX;

		internal static string asset_bundle = "macho_flowerman_sfx";

		internal static string anger_voice = "Assets/anger.wav";

		internal static string neck_snap = "Assets/neck_snap.wav";

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("AuthorChaos.MachoFlowerman");
			mls.LogInfo((object)"!!! MachoFlowerman has awaken !!!");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			mls.LogInfo((object)("DLL file: " + location));
			string text = location.TrimEnd("LCMachoFlowerman.dll".ToCharArray());
			mls.LogInfo((object)("Mod root directory: " + text));
			string text2 = text + asset_bundle;
			mls.LogInfo((object)("Asset Bundle: " + text2));
			AssetBundle val = LocalLoadAssetBundle(text2);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"!!! MachoFlowerman failed to load asset bundle. !!!");
				return;
			}
			mls.LogInfo((object)("Asset Bundle loaded successfully: " + (object)val));
			newAngerSFX = val.LoadAsset<AudioClip>(anger_voice);
			newNeckSnapSFX = val.LoadAsset<AudioClip>(neck_snap);
			harmony.PatchAll(typeof(MachoFlowermanBase));
			harmony.PatchAll(typeof(MachoFlowermanSoundPatch));
			mls.LogInfo((object)"!!! MachoFlowerman has loaded successfully !!! :-)");
		}

		private AssetBundle LocalLoadAssetBundle(string asset_bundle_abs_path)
		{
			return AssetBundle.LoadFromFile(asset_bundle_abs_path);
		}
	}
}
namespace LCMachoFlowerman.Patches
{
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class MachoFlowermanSoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void machoFlowermanSoundPatch(ref AudioSource ___creatureAngerVoice, ref AudioClip ___crackNeckSFX)
		{
			___creatureAngerVoice.clip = MachoFlowermanBase.newAngerSFX;
			___crackNeckSFX = MachoFlowermanBase.newNeckSnapSFX;
		}
	}
}