Decompiled source of BrackenRKO v1.0.3

ClassLibrary1.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
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("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("916dac88-7a02-4a92-8877-1d4bba9fdad4")]
[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 ryansmod
{
	[BepInPlugin("ryansmodding", "BrackenRKO", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public readonly Harmony harmony = new Harmony("ryansmodding");

		public static Plugin Instance;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)"ryansmod MyPatchClass Patched.");
			harmony.PatchAll();
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}

		public static void Log(float message)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}

		public static void Log(Vector3 message)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}

		public static void Log(bool message)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}

		public static void Log(SelectableLevel message)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}

		public static void Log(SpawnableEnemyWithRarity message)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}

		public static void Log(List<SpawnableEnemyWithRarity> message)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
		}
	}
}
namespace ClassLibrary1.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		private static FieldRef<EnemyAI, NetworkObject> ThisNetworkObject = AccessTools.FieldRefAccess<EnemyAI, NetworkObject>("thisNetworkObject");

		private static FieldRef<EnemyAI, EnemyType> enemyType = AccessTools.FieldRefAccess<EnemyAI, EnemyType>("enemyType");

		private static FieldRef<GameNetworkManager, PlayerControllerB> LocalPlayerController = AccessTools.FieldRefAccess<GameNetworkManager, PlayerControllerB>("localPlayerController");

		private static GameNetworkManager LocalGameNetworkManager = null;

		private static EnemyType FlowermanEnemyType = null;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void EnemyAIUpdatePostPatch(EnemyAI __instance)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)enemyType.Invoke(__instance)) && Object.op_Implicit((Object)(object)ThisNetworkObject.Invoke(__instance)) && Object.op_Implicit((Object)(object)LocalGameNetworkManager) && Object.op_Implicit((Object)(object)LocalPlayerController.Invoke(LocalGameNetworkManager)) && Object.op_Implicit((Object)(object)FlowermanEnemyType) && ThisNetworkObject.Invoke(__instance).IsSpawned && !(((Component)LocalPlayerController.Invoke(LocalGameNetworkManager).thisPlayerBody).transform.position == new Vector3(9.33f, 5.2f, 1021f)) && (!(enemyType.Invoke(__instance).enemyName != "Flowerman") || !UnityInput.Current.GetKey((KeyCode)114)))
			{
				Transform transform = ((Component)LocalPlayerController.Invoke(LocalGameNetworkManager).thisPlayerBody).transform;
				Transform transform2 = ((Component)__instance).transform;
				float num = Vector3.Distance(transform.position, transform2.position);
				float num2 = Quaternion.Dot(transform.rotation, transform2.rotation);
				if (num <= 5f && num2 > 0.45f)
				{
					__instance.KillEnemyOnOwnerClient(true);
				}
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager))]
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void GameNetworkManagerStartPostPatch(GameNetworkManager __instance)
		{
			LocalGameNetworkManager = __instance;
		}

		[HarmonyPatch(typeof(RoundManager))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void RoundManagerUpdatePostPatch(RoundManager __instance)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if (!UnityInput.Current.GetKey((KeyCode)102))
			{
				return;
			}
			if ((Object)(object)FlowermanEnemyType == (Object)null)
			{
				for (int i = 0; i < __instance.currentLevel.Enemies.Count; i++)
				{
					if (__instance.currentLevel.Enemies[i].enemyType.enemyName == "Flowerman")
					{
						FlowermanEnemyType = __instance.currentLevel.Enemies[i].enemyType;
					}
				}
			}
			else
			{
				Transform transform = ((Component)LocalPlayerController.Invoke(LocalGameNetworkManager).thisPlayerBody).transform;
				__instance.SpawnEnemyGameObject(transform.position + transform.forward * 5f, transform.eulerAngles.y, -1, FlowermanEnemyType);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		private static RuntimeAnimatorController OGAnimatorController;

		private static RuntimeAnimatorController NewAnimatorController = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BrackenRKO/animatorbundle")).LoadAsset<RuntimeAnimatorController>("ZBotAC");

		private static AnimationClip RKOAnimationClip = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BrackenRKO/animationbundle")).LoadAsset<AnimationClip>("RKOAnimClip 1");

		private static FieldRef<PlayerControllerB, float> sMeterRef = AccessTools.FieldRefAccess<PlayerControllerB, float>("sprintMeter");

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void EmoteInit(PlayerControllerB __instance)
		{
			OGAnimatorController = __instance.playerBodyAnimator.runtimeAnimatorController;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Postfix(PlayerControllerB __instance)
		{
			sMeterRef.Invoke(__instance) = 1f;
			if (UnityInput.Current.GetKey((KeyCode)98) && Object.op_Implicit((Object)(object)OGAnimatorController))
			{
				if ((Object)(object)__instance.playerBodyAnimator.runtimeAnimatorController != (Object)(object)NewAnimatorController)
				{
					__instance.playerBodyAnimator.runtimeAnimatorController = NewAnimatorController;
				}
			}
			else if ((Object)(object)__instance.playerBodyAnimator.runtimeAnimatorController != (Object)(object)OGAnimatorController)
			{
				__instance.playerBodyAnimator.runtimeAnimatorController = OGAnimatorController;
			}
		}
	}
	public class NewAnimatorController : RuntimeAnimatorController
	{
	}
}