Decompiled source of BrutusBracken v1.0.0

BrutusBracken.dll

Decompiled 11 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("BrutusBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BrutusBracken")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("92c68cdd-4417-4be2-a65a-4e59f34f7a20")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BrutusBracken
{
	[BepInPlugin("BrutusBracken", "BrutusBracken", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static GameObject Visuals;

		internal static Plugin Instance;

		public static AudioClip BrutusNeckCrack;

		public static AudioClip BrutusAngered;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BrutusBracken is loaded!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "brutus.bundle"));
			Visuals = val.LoadAsset<GameObject>("assets/prefabs/brutus.prefab");
			BrutusNeckCrack = val.LoadAsset<AudioClip>("assets/prefabs/brutusneckcrack.wav");
			BrutusAngered = val.LoadAsset<AudioClip>("assets/prefabs/brutusangered.wav");
			Renderer[] componentsInChildren = Visuals.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Component val2 = (Component)(object)componentsInChildren[i];
				val2.gameObject.layer = LayerMask.NameToLayer("Enemies");
			}
		}

		internal static void LogInfo(object message)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[BRUTUS-BRACKEN]" + message));
		}

		internal static void LogWarning(object message)
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)("[BRUTUS-BRACKEN]" + message));
		}

		internal static void LogError(object message)
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)("[BRUTUS-BRACKEN]" + message));
		}
	}
}
namespace BrutusBracken.Patches
{
	[HarmonyPatch(typeof(FlowermanAI), "Start")]
	internal class FlowermanPatch
	{
		private static void Postfix(FlowermanAI __instance)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)__instance).transform.Find("FlowermanModel");
			Transform obj = ((val != null) ? val.Find("LOD1") : null);
			SkinnedMeshRenderer val2 = ((obj != null) ? ((Component)obj).GetComponent<SkinnedMeshRenderer>() : null);
			object obj2;
			if (val == null)
			{
				obj2 = null;
			}
			else
			{
				Transform obj3 = val.Find("AnimContainer");
				obj2 = ((obj3 != null) ? obj3.Find("metarig") : null);
			}
			Transform val3 = (Transform)obj2;
			((Renderer)val2).enabled = false;
			Renderer[] componentsInChildren = ((Component)val3).gameObject.GetComponentsInChildren<Renderer>();
			foreach (Renderer val4 in componentsInChildren)
			{
				val4.enabled = false;
			}
			GameObject val5 = Object.Instantiate<GameObject>(Plugin.Visuals);
			val5.transform.SetParent(val);
			val5.transform.localPosition = Vector3.zero;
			val5.transform.localRotation = Quaternion.identity;
			val5.transform.localScale = Vector3.one;
			Transform val6 = val5.transform.Find("BrutusBody");
			Transform val7 = val5.transform.Find("AnimContainer/metarig");
			val7.SetParent(val3.parent, true);
			((Component)val7).transform.localScale = ((Component)val3).transform.localScale;
			((Component)val7).transform.localRotation = ((Component)val3).transform.localRotation;
			((Component)val7).transform.localPosition = ((Component)val3).transform.localPosition;
			((Component)val6).GetComponent<SkinnedMeshRenderer>().rootBone = val7;
			((Object)val3).name = "old-metarig";
			__instance.crackNeckSFX = Plugin.BrutusNeckCrack;
			__instance.creatureAngerVoice.clip = Plugin.BrutusAngered;
			__instance.rightHandGrip = val7.Find("Torso1").Find("Torso2").Find("Torso3")
				.Find("Arm1.R")
				.Find("Arm2.R")
				.Find("Arm3.R")
				.Find("Hand1.R");
		}
	}
}