Decompiled source of TauntAggroFix v1.0.1

TauntAggroFix.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TauntAggroFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("TauntAggroFix")]
[assembly: AssemblyTitle("TauntAggroFix")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 TauntAggroFix
{
	[BepInPlugin("com.Personal.TauntAggroFix", "TauntAggroFix", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string guid = "com.Personal.TauntAggroFix";

		public const string modName = "TauntAggroFix";

		public const string version = "1.0.1";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.Personal.TauntAggroFix").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"TauntAggroFix loaded. Taunt and Enrage now redirect currentEnemy.");
		}
	}
	[HarmonyPatch(typeof(BaseAI), "ManagedFixedUpdate")]
	internal static class TauntAggroPatch
	{
		private static void Postfix(BaseAI __instance)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			CharacterBody body = __instance.body;
			if (!Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			bool flag = body.HasBuff(Buffs.Taunted);
			bool flag2 = body.HasBuff(Buffs.TearGasBerserk);
			if (!flag && !flag2)
			{
				return;
			}
			object obj;
			if (!flag)
			{
				obj = null;
			}
			else
			{
				Target customTarget = __instance.customTarget;
				obj = ((customTarget != null) ? customTarget.gameObject : null);
			}
			GameObject val = (GameObject)obj;
			if (!Object.op_Implicit((Object)(object)val) && flag2)
			{
				Target currentEnemy = __instance.currentEnemy;
				val = ((currentEnemy != null) ? currentEnemy.gameObject : null);
			}
			if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val == (Object)(object)((Component)body).gameObject)
			{
				return;
			}
			ProjectileController component = val.GetComponent<ProjectileController>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.owner))
			{
				val = component.owner;
			}
			TeamComponent component2 = val.GetComponent<TeamComponent>();
			TeamComponent teamComponent = body.teamComponent;
			if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)teamComponent) && component2.teamIndex != teamComponent.teamIndex && (int)component2.teamIndex != 0)
			{
				if ((Object)(object)__instance.currentEnemy.gameObject != (Object)(object)val)
				{
					__instance.currentEnemy.gameObject = val;
				}
				__instance.enemyAttention = __instance.enemyAttentionDuration;
			}
		}
	}
}