Decompiled source of BrackenMinaj v1.1.3

BrackenMinaj.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BrackenMinaj.Patching;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("BrackenMinaj")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A horrible idea inspired by @Antoine_Delak. May God have mercy on my soul. I'm going to lose sleep over this.")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("BrackenMinaj")]
[assembly: AssemblyTitle("BrackenMinaj")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 BrackenMinaj
{
	[BepInPlugin("BrackenMinaj", "BrackenMinaj", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony Harmony = new Harmony("BrackenMinaj.BrackenMinaj");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BrackenMinaj is loaded!");
			MinajAssets.LoadAssets();
			Harmony.PatchAll(typeof(BrackenMinajPatcher));
		}
	}
	internal static class MinajAssets
	{
		private static AssetBundle brackenMinajBundle;

		private static GameObject nickiObj;

		private static List<AudioClip> angerSounds = new List<AudioClip>();

		private static List<AudioClip> crackNeckSounds = new List<AudioClip>();

		private static List<AudioClip> stunSounds = new List<AudioClip>();

		public static void LoadAssets()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Debug.Log((object)("Attempting to load BrackenMinaj from location \"" + directoryName + "\\brackenminajbundle\""));
			brackenMinajBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "brackenminajbundle"));
			if ((Object)(object)brackenMinajBundle != (Object)null)
			{
				Debug.Log((object)"Bundle loaded.");
				nickiObj = brackenMinajBundle.LoadAsset<GameObject>("Nicki");
				angerSounds.Add(brackenMinajBundle.LoadAsset<AudioClip>("nicki_angered"));
				angerSounds.Add(brackenMinajBundle.LoadAsset<AudioClip>("nicki_angered_2"));
				crackNeckSounds.Add(brackenMinajBundle.LoadAsset<AudioClip>("nicki_crackneck"));
				stunSounds.Add(brackenMinajBundle.LoadAsset<AudioClip>("nicki_stun"));
				stunSounds.Add(brackenMinajBundle.LoadAsset<AudioClip>("nicki_stun_2"));
				Debug.Log((object)"Successfully loaded BrackenMinaj. Suffer.");
			}
			else
			{
				Debug.LogError((object)"Could not load brackenminajbundle. Please ensure the bundle file is next to the .dll for the mod.");
				Debug.LogError((object)"Skipping BrackenMinaj load...");
			}
		}

		public static GameObject GetNickiModel()
		{
			return nickiObj;
		}

		public static AudioClip GetRandomAngerSound()
		{
			if (angerSounds.Count > 0)
			{
				return angerSounds[Random.RandomRangeInt(0, angerSounds.Count)];
			}
			return null;
		}

		public static AudioClip GetRandomCrackNeckSound()
		{
			if (crackNeckSounds.Count > 0)
			{
				return crackNeckSounds[Random.RandomRangeInt(0, crackNeckSounds.Count)];
			}
			return null;
		}

		public static AudioClip GetRandomStunSound()
		{
			if (stunSounds.Count > 0)
			{
				return stunSounds[Random.RandomRangeInt(0, stunSounds.Count)];
			}
			return null;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BrackenMinaj";

		public const string PLUGIN_NAME = "BrackenMinaj";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace BrackenMinaj.Patching
{
	[HarmonyPatch]
	internal class BrackenMinajPatcher
	{
		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		public static void CreateNicki(FlowermanAI __instance)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			Debug.Log((object)"Aah.");
			GameObject nickiModel = MinajAssets.GetNickiModel();
			if ((Object)(object)nickiModel != (Object)null)
			{
				Renderer[] componentsInChildren = ((Component)((Component)__instance).transform.Find("FlowermanModel")).GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = false;
				}
				GameObject val = Object.Instantiate<GameObject>(nickiModel, ((Component)__instance).gameObject.transform);
				val.transform.localPosition = Vector3.zero;
				val.transform.localScale = new Vector3(1.8f, 1.8f, 1.8f);
				((Object)val).name = "BrackenMinaj";
				Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>();
				Material material = componentsInChildren[0].material;
				Renderer[] array = componentsInChildren2;
				foreach (Renderer val2 in array)
				{
					List<Material> list = new List<Material>();
					Material[] materials = val2.materials;
					foreach (Material val3 in materials)
					{
						Material val4 = new Material(material);
						val4.mainTexture = val3.mainTexture;
						list.Add(val4);
					}
					val2.SetMaterials(list);
				}
				Transform val5 = ((Component)__instance).transform.Find("ScanNode");
				ScanNodeProperties component = ((Component)val5).GetComponent<ScanNodeProperties>();
				component.headerText = "Nicki Minaj COD MW2";
				__instance.creatureAngerVoice.clip = MinajAssets.GetRandomAngerSound();
				__instance.crackNeckSFX = MinajAssets.GetRandomCrackNeckSound();
				__instance.crackNeckAudio.clip = __instance.crackNeckSFX;
				((EnemyAI)__instance).enemyType.stunSFX = MinajAssets.GetRandomStunSound();
			}
			else
			{
				Debug.LogError((object)"BrackenMinaj bundle not loaded, defaulting to normal Bracken assets... REPORT THIS!");
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Update")]
		[HarmonyPostfix]
		public static void CheckForAnger(FlowermanAI __instance)
		{
		}

		[HarmonyPatch(typeof(EnemyAI), "SetEnemyStunned")]
		[HarmonyPrefix]
		public static void CheckForStun(FlowermanAI __instance)
		{
			((EnemyAI)__instance).creatureVoice.clip = ((EnemyAI)__instance).enemyType.stunSFX;
			Debug.Log((object)"I'M STUNNED");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}