Decompiled source of BlueDevilBracken v1.2.1

BlueDevilBracken.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
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("BlueDevilBracken")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod that replaces the Bracken with a PNG of the Blue Devil from UW-Stout")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("BlueDevilBracken")]
[assembly: AssemblyTitle("BlueDevilBracken")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BlueDevilBracken
{
	public static class BDLogger
	{
		private static ManualLogSource _logger;

		public static void Init()
		{
			_logger = Logger.CreateLogSource("BlueDevilBracken");
		}

		public static void Log(LogLevel logLevel, object data)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.Log(logLevel, data);
			}
		}
	}
	[HarmonyPatch(typeof(FlowermanAI), "Start")]
	public static class BlueDevilPatch
	{
		private static AssetBundle assetBundleCache;

		private const int AUDIO_COUNT = 4;

		private static T GetFromAssetBundle<T>(string name) where T : Object
		{
			if ((Object)(object)assetBundleCache == (Object)null)
			{
				assetBundleCache = Utils.LoadAssetBundle("bluedevil");
			}
			if ((Object)(object)assetBundleCache == (Object)null)
			{
				throw new Exception("Failed to load asset bundle");
			}
			return assetBundleCache.LoadAsset<T>(name);
		}

		private static AudioClip GetRandomAudio()
		{
			int num = Random.Range(1, 5);
			string name = $"assets/Lethal/bluedevil-audio{num}.mp3";
			return GetFromAssetBundle<AudioClip>(name);
		}

		public static void Postfix(FlowermanAI __instance)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			AudioClip randomAudio = GetRandomAudio();
			__instance.creatureAngerVoice.clip = GetFromAssetBundle<AudioClip>("assets/Lethal/bluedevil-megalovania.mp3");
			__instance.crackNeckSFX = randomAudio;
			__instance.crackNeckAudio.clip = randomAudio;
			Object.Destroy((Object)(object)((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel/LOD1")).gameObject.GetComponent<SkinnedMeshRenderer>());
			((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel/AnimContainer/metarig")).gameObject.SetActive(false);
			GameObject fromAssetBundle = GetFromAssetBundle<GameObject>("assets/Lethal/bluedevil-prefab.prefab");
			GameObject val = Object.Instantiate<GameObject>(fromAssetBundle, ((Component)__instance).transform);
			val.transform.localPosition = new Vector3(0f, 1.5f, 0f);
		}
	}
	[BepInPlugin("BlueDevilBracken", "BlueDevilBracken", "1.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		public Harmony harmony;

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			BDLogger.Init();
			harmony = new Harmony("BlueDevilBracken");
			harmony.PatchAll();
		}
	}
	public static class Utils
	{
		public static AssetBundle LoadAssetBundle(string name)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(name));
			using Stream stream = executingAssembly.GetManifestResourceStream(text ?? "");
			if (stream == null)
			{
				return null;
			}
			return AssetBundle.LoadFromStream(stream);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BlueDevilBracken";

		public const string PLUGIN_NAME = "BlueDevilBracken";

		public const string PLUGIN_VERSION = "1.2.1";
	}
}