Decompiled source of MineMineMineMod v1.1.0

HoarderBugMine.dll

Decompiled 11 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HoarderBugMine")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A plugin for BepInEx that replaces the standard sound of hoarding bugs with \"mine\"")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c5a0e00407c44d7d5172666b6eca5a641f1e294c")]
[assembly: AssemblyProduct("HoarderBugMine")]
[assembly: AssemblyTitle("HoarderBugMine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HoarderBugMine
{
	[BepInPlugin("HoarderBugMine", "HoarderBugMine", "1.0.0")]
	public class MineMineMineBase : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(HoarderBugAI))]
		internal class HoarderBugAudioPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			public static void PatchAudio(HoarderBugAI __instance)
			{
				__instance.chitterSFX = Assets.SeagullSound;
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI))]
		internal class HoarderBugModelPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			public static void PatchModel(HoarderBugAI __instance)
			{
				Renderer[] componentsInChildren = ((Component)((Component)__instance).transform.Find("HoarderBugModel")).GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = false;
				}
				((Object)Object.Instantiate<GameObject>(Assets.SeagullPrefab, ((Component)__instance).gameObject.transform)).name = "SeagullModel";
			}
		}

		private class Assets
		{
			private static AssetBundle _audioBundle;

			private static AssetBundle _seagullBundle;

			internal static AudioClip[] SeagullSound;

			internal static GameObject SeagullPrefab;

			internal static void LoadAssets()
			{
				string text = ((BaseUnityPlugin)_instance).Info.Location.TrimEnd(Assembly.GetExecutingAssembly().FullName.ToCharArray());
				_audioBundle = AssetBundle.LoadFromFile(text + "minemine");
				SeagullSound = _audioBundle.LoadAssetWithSubAssets<AudioClip>("Assets/mineMineMine.mp3");
				_seagullBundle = AssetBundle.LoadFromFile(text + "seagull");
				SeagullPrefab = _seagullBundle.LoadAsset<GameObject>("Assets/meeuw3d2 Variant.prefab");
				if ((Object)(object)_audioBundle == (Object)null || (Object)(object)_seagullBundle == (Object)null)
				{
					mls.LogError((object)"Failed to load bundles");
				}
				if (SeagullSound == null || (Object)(object)SeagullPrefab == (Object)null)
				{
					mls.LogError((object)"Failed to load assets");
				}
			}
		}

		private readonly Harmony _harmony = new Harmony("HoarderBugMine");

		private static MineMineMineBase? _instance;

		private static ManualLogSource? mls;

		private void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			mls = Logger.CreateLogSource("HoarderBugMine mod");
			mls.LogInfo((object)"Plugin HoarderBugMine is loading");
			mls.LogInfo((object)"loading assets");
			Assets.LoadAssets();
			mls.LogInfo((object)"assets loaded");
			_harmony.PatchAll(typeof(MineMineMineBase));
			_harmony.PatchAll(typeof(HoarderBugAudioPatch));
			_harmony.PatchAll(typeof(HoarderBugModelPatch));
			mls.LogInfo((object)"HoarderBugMine is now loaded");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HoarderBugMine";

		public const string PLUGIN_NAME = "HoarderBugMine";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}