Decompiled source of TauntAggroFix v1.0.0

TauntAggroFix.dll

Decompiled 15 hours 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.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TauntAggroFix")]
[assembly: AssemblyTitle("TauntAggroFix")]
[assembly: AssemblyVersion("1.0.0.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.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string guid = "com.Personal.TauntAggroFix";

		public const string modName = "TauntAggroFix";

		public const string version = "1.0.0";

		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 now redirects currentEnemy.");
		}
	}
	[HarmonyPatch(typeof(BaseAI), "ManagedFixedUpdate")]
	internal static class TauntAggroPatch
	{
		private static void Postfix(BaseAI __instance)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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) || !body.HasBuff(Buffs.Taunted))
			{
				return;
			}
			Target customTarget = __instance.customTarget;
			GameObject val = ((customTarget != null) ? customTarget.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;
			}
		}
	}
}