Decompiled source of BeezBracken v1.0.0

BeezBracken.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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("BeezBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BeezBracken")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3e5933d6-d351-4fdb-82f4-90f0c82d5a70")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BeezBracken
{
	[BepInPlugin("mussolenguini.beezBracken", "Beez Bracken", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "mussolenguini.beezBracken";

		private const string NAME = "Beez Bracken";

		private const string VERSION = "0.0.1";

		public static Plugin instance;

		public static GameObject BeezBracken;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "beezbracken");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			BeezBracken = val.LoadAsset<GameObject>("assets/Beez.prefab");
			SkinnedMeshRenderer[] componentsInChildren = BeezBracken.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val2 in array)
			{
				((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "mussolenguini.beezBracken");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched Beez Bracken");
		}
	}
}
namespace BeezBracken.Patches
{
	[HarmonyPatch(typeof(FlowermanAI), "Start")]
	internal class FlowermanPatch
	{
		private static void Postfix(FlowermanAI __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Plugin.BeezBracken == (Object)null)
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("FlowermanModel");
			object obj;
			if (val == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val.Find("LOD1");
				obj = ((obj2 != null) ? ((Component)obj2).GetComponent<SkinnedMeshRenderer>() : null);
			}
			SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)obj;
			object obj3;
			if (val == null)
			{
				obj3 = null;
			}
			else
			{
				Transform obj4 = val.Find("AnimContainer");
				obj3 = ((obj4 != null) ? obj4.Find("metarig") : null);
			}
			Transform val3 = (Transform)obj3;
			((Component)((Component)__instance).transform.Find("ScanNode")).GetComponent<ScanNodeProperties>().headerText = "Beez Bracken";
			if (!((Object)(object)val2 == (Object)null) && ((Renderer)val2).enabled)
			{
				((Renderer)val2).enabled = false;
				Renderer[] componentsInChildren = ((Component)val3).gameObject.GetComponentsInChildren<Renderer>();
				Renderer[] array = componentsInChildren;
				foreach (Renderer val4 in array)
				{
					val4.enabled = false;
				}
				GameObject val5 = Object.Instantiate<GameObject>(Plugin.BeezBracken);
				val5.transform.SetParent(val);
				val5.transform.localPosition = new Vector3(0f, 1.5f, 0f);
				val5.transform.localRotation = Quaternion.identity;
				val5.transform.Rotate(90f, 0f, 0f, (Space)1);
				Transform val6 = val5.transform.Find("Body");
				Transform val7 = val5.transform.Find("Hips");
				Transform val8 = val5.transform.Find("MohawkHair");
				Transform val9 = val5.transform.Find("Tail2");
				val7.SetParent(val3.parent, true);
				((Component)val7).transform.localPosition = ((Component)val3).transform.localPosition;
				SkinnedMeshRenderer component = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
				SkinnedMeshRenderer component2 = ((Component)val8).GetComponent<SkinnedMeshRenderer>();
				SkinnedMeshRenderer component3 = ((Component)val9).GetComponent<SkinnedMeshRenderer>();
				component.rootBone = val7;
				component2.rootBone = val7;
				component3.rootBone = val7;
				((Object)val3).name = "old-metarig";
				__instance.rightHandGrip = val7.Find("Spine").Find("Chest").Find("shouler.R")
					.Find("upper_arm.R")
					.Find("forearm.R")
					.Find("hand.R")
					.Find("HandGripPosition");
			}
		}
	}
}