Decompiled source of Bean Man Bracken v0.1.1

BeanManBracken.dll

Decompiled 7 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 BepInEx.Logging;
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("BeanManBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BeanManBracken")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fb6f69c4-c726-4b08-8825-36ada2edc736")]
[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 LethalCompanyBeanManBracken;

[BepInPlugin("com.auroralabs.beanmanbracken", "BeanManBracken", "0.1.0")]
public class BeanManBracken : BaseUnityPlugin
{
	public const string modGUID = "com.auroralabs.beanmanbracken";

	public const string modName = "BeanManBracken";

	public const string modVersion = "0.1.0";

	private readonly Harmony harmony = new Harmony("com.auroralabs.beanmanbracken");

	public static GameObject BeanManModel;

	public static AssetBundle AssetBundle { get; private set; }

	private void Awake()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		ManualLogSource val = Logger.CreateLogSource("com.auroralabs.beanmanbracken");
		val.LogMessage((object)"com.auroralabs.beanmanbracken has loaded successfully.");
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		if ((Object)AssetBundle != (Object)null)
		{
			val.LogWarning((object)"Attempted to load the asset bundle but the bundle was not null!");
			return;
		}
		AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "beanmanbundle"));
		BeanManModel = AssetBundle.LoadAsset<GameObject>("BeanMan");
		Renderer[] componentsInChildren = BeanManModel.GetComponentsInChildren<Renderer>(true);
		Renderer[] array = componentsInChildren;
		foreach (Renderer val2 in array)
		{
			((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
		}
	}
}
[HarmonyPatch(typeof(FlowermanAI))]
[HarmonyPatch("Start")]
internal class BeanMan
{
	[HarmonyPostfix]
	private static void Postfix(FlowermanAI __instance)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((Component)__instance).transform.Find("FlowermanModel");
		Transform val2 = (((Object)val != (Object)null) ? val.Find("LOD1") : null);
		SkinnedMeshRenderer val3 = (((Object)val2 != (Object)null) ? ((Component)val2).GetComponent<SkinnedMeshRenderer>() : null);
		Transform val4;
		if ((Object)val == (Object)null)
		{
			val4 = null;
		}
		else
		{
			Transform val5 = val.Find("AnimContainer");
			val4 = (((Object)val5 != (Object)null) ? val5.Find("metarig") : null);
		}
		Transform val6 = val4;
		((Renderer)val3).enabled = false;
		Renderer[] componentsInChildren = ((Component)val6).gameObject.GetComponentsInChildren<Renderer>();
		Renderer[] array = componentsInChildren;
		foreach (Renderer val7 in array)
		{
			val7.enabled = false;
		}
		GameObject val8 = Object.Instantiate<GameObject>(BeanManBracken.BeanManModel);
		val8.transform.SetParent(val);
		((EnemyAI)__instance).creatureAnimator = val8.GetComponent<Animator>();
		val8.transform.localPosition = Vector3.zero;
		val8.transform.localScale = Vector3.one * 0.2f;
	}
}