using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Mono.Cecil.Cil;
using MonoMod.Cil;
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("ControllerAimer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ControllerAimer")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("17665fc7-b7f3-448d-b85b-22506f488236")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ControllerAimer;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("kleirof.etg.controlleraimer", "Controller Aimer", "1.1.2")]
public class AimerModule : BaseUnityPlugin
{
public class AimerPatches
{
[HarmonyILManipulator]
[HarmonyPatch(typeof(GuidedBulletsPassiveItem), "PreMoveProjectileModifier")]
public static void HandleKnockbackPatch(ILContext ctx)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(ctx);
if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 3),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 2),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 4),
(Instruction x) => ILPatternMatchingExt.MatchCall(x, "BraveTime", "get_DeltaTime"),
(Instruction x) => ILPatternMatchingExt.MatchMul(x)
}))
{
return;
}
val.Index += 2;
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldarg_1);
val.Emit(OpCodes.Ldloc_0);
val.Emit(OpCodes.Ldloc_1);
val.EmitDelegate<Func<float, GuidedBulletsPassiveItem, Projectile, BraveInput, Vector2, float>>((Func<float, GuidedBulletsPassiveItem, Projectile, BraveInput, Vector2, float>)delegate(float target, GuidedBulletsPassiveItem self, Projectile p, BraveInput instanceForPlayer, Vector2 vector)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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)
if (!instanceForPlayer.IsKeyboardAndMouse(false) && instanceForPlayer.ActiveActions != null && vector == Vector2.zero)
{
float num = 0f;
AIActor nearestEnemy = ((PassiveItem)self).Owner.CurrentRoom.GetNearestEnemy(((GameActor)((PassiveItem)self).Owner).CenterPosition, ref num, true, false);
if (Object.op_Implicit((Object)(object)nearestEnemy))
{
vector = ((GameActor)nearestEnemy).CenterPosition - ((BraveBehaviour)p).specRigidbody.UnitCenter;
return Vector2Extensions.ToAngle(vector);
}
return ((PassiveItem)self).Owner.m_currentGunAngle;
}
return target;
});
}
[HarmonyILManipulator]
[HarmonyPatch(typeof(InputGuidedProjectile), "Move")]
public static void MovePatch(ILContext ctx)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(ctx);
if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[6]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 4),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 3),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<InputGuidedProjectile>(x, "trackingSpeed"),
(Instruction x) => ILPatternMatchingExt.MatchCall(x, "BraveTime", "get_DeltaTime"),
(Instruction x) => ILPatternMatchingExt.MatchMul(x)
}))
{
return;
}
val.Index += 2;
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc_1);
val.Emit(OpCodes.Ldloc_2);
val.EmitDelegate<Func<float, InputGuidedProjectile, BraveInput, Vector2, float>>((Func<float, InputGuidedProjectile, BraveInput, Vector2, float>)delegate(float target, InputGuidedProjectile self, BraveInput instanceForPlayer, Vector2 vector)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
if (!instanceForPlayer.IsKeyboardAndMouse(false) && instanceForPlayer.ActiveActions != null && vector == Vector2.zero)
{
float num = 0f;
GameActor owner = ((Projectile)self).Owner;
AIActor nearestEnemy = ((PlayerController)((owner is PlayerController) ? owner : null)).CurrentRoom.GetNearestEnemy(((Projectile)self).Owner.CenterPosition, ref num, true, false);
if (Object.op_Implicit((Object)(object)nearestEnemy))
{
vector = ((GameActor)nearestEnemy).CenterPosition - ((BraveBehaviour)self).specRigidbody.UnitCenter;
return Vector2Extensions.ToAngle(vector);
}
GameActor owner2 = ((Projectile)self).Owner;
return ((PlayerController)((owner2 is PlayerController) ? owner2 : null)).m_currentGunAngle;
}
return target;
});
}
}
public const string GUID = "kleirof.etg.controlleraimer";
public const string NAME = "Controller Aimer";
public const string VERSION = "1.1.2";
public const string TEXT_COLOR = "#FF7F50";
public void Start()
{
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
}
public void GMStart(GameManager g)
{
Log("Controller Aimer v1.1.2 started successfully.", "#FF7F50");
Harmony.CreateAndPatchAll(typeof(AimerPatches), (string)null);
}
public static void Log(string text, string color = "FFFFFF")
{
ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
}
}