Decompiled source of BrackenFavRoom v0.2.2

BrackenFavRoom.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[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("BrackenFavRoom")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Change the brackes favorite spot to the Backrooms")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2")]
[assembly: AssemblyProduct("BrackenFavRoom")]
[assembly: AssemblyTitle("BrackenFavRoom")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.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 BrackenFavRoom
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		private static GameObject smallRoom;

		private static Vector3 mainEntrancePosition = Vector3.zero;

		private static bool errorSend = false;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(EnemyAI __instance)
		{
			if (__instance is FlowermanAI)
			{
				smallRoom = GameObject.Find("SmallRoom2(Clone)");
			}
		}

		[HarmonyPatch("ChooseFarthestNodeFromPosition")]
		[HarmonyPostfix]
		private static void ChooseFarthestNodeFromPositionPatch(EnemyAI __instance, ref Transform __result)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			if (!(__instance is FlowermanAI) || !((NetworkBehaviour)__instance).IsOwner)
			{
				return;
			}
			if ((Object)(object)smallRoom == (Object)null)
			{
				if (!errorSend)
				{
					Debug.LogWarning((object)"BrackenFavRoom: No Backroom room found!");
				}
				errorSend = true;
				return;
			}
			Vector3 position = smallRoom.transform.position;
			float num = -7f;
			Vector3 val = smallRoom.transform.forward * num;
			Vector3 val2 = position + val;
			if ((Object)(object)__instance.favoriteSpot != (Object)null && Vector3.Distance(__instance.favoriteSpot.position, val2) < 0.5f)
			{
				return;
			}
			if (!CheckForPath(val2, __instance))
			{
				if (!errorSend)
				{
					Debug.LogWarning((object)"BrackenFavRoom: No path to the Backrooms from the Brackens current position");
					errorSend = true;
					return;
				}
				if (__instance.favoriteSpot.position != mainEntrancePosition)
				{
					Debug.Log((object)"BrackenFavPos: Choosing new favorite spot...");
					mainEntrancePosition = RoundManager.FindMainEntrancePosition(false, false);
					__instance.ChooseFarthestNodeFromPosition(mainEntrancePosition, false, 0, false);
					errorSend = false;
				}
			}
			if ((Object)(object)__instance.favoriteSpot != (Object)null)
			{
				Debug.Log((object)$"BrackenFavRoom: Brackens favorite was X:{((Component)__instance.favoriteSpot).transform.position.x}, Y:{((Component)__instance.favoriteSpot).transform.position.y}, Z:{((Component)__instance.favoriteSpot).transform.position.z}");
			}
			Debug.Log((object)$"BrackenFavRoom: Changed Brackens favorite spot to X:{val2.x}, Y:{val2.y}, Z:{smallRoom.transform.position.z}");
			__result.position = val2;
		}

		private static bool CheckForPath(Vector3 favoriteSpotPos, EnemyAI __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(favoriteSpotPos, RoundManager.Instance.navHit, 1.75f, -1);
			NavMeshPath val = new NavMeshPath();
			return __instance.agent.CalculatePath(navMeshPosition, val);
		}
	}
	[BepInPlugin("BrackenFavRoom", "BrackenFavRoom", "0.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("micki.plugin.BrackenFavRoom");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BrackenFavRoom is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BrackenFavRoom";

		public const string PLUGIN_NAME = "BrackenFavRoom";

		public const string PLUGIN_VERSION = "0.2.2";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}