using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using RoR2; 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("AutoFire")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AutoFire")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a1328614-8f9d-44fa-999d-08f1d7357d4a")] [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 RoR2AutoFire; public enum TargetPriority { Closest, HighestHealth, LowestHealth } [BepInPlugin("com.geminimod.autofire", "AutoFire", "2.2.0")] public class AutoFireMod : BaseUnityPlugin { public static CharacterBody currentTarget; private ConfigEntry maxTargetingRange; private ConfigEntry requireLineOfSight; private ConfigEntry pauseOnSprint; private ConfigEntry enableAutoAim; public static ConfigEntry enableTargetUI; public static ConfigEntry uiColorR; public static ConfigEntry uiColorG; public static ConfigEntry uiColorB; private ConfigEntry targetPriority; private ConfigEntry attackPrimary; private ConfigEntry attackSecondary; private ConfigEntry attackUtility; private ConfigEntry attackSpecial; private ConfigEntry enablePrimaryDelay; private ConfigEntry enableSecondaryDelay; private ConfigEntry enableUtilityDelay; private ConfigEntry enableSpecialDelay; private ConfigEntry primaryDelay; private ConfigEntry secondaryDelay; private ConfigEntry utilityDelay; private ConfigEntry specialDelay; private float lastPrimaryTime = 0f; private float lastSecondaryTime = 0f; private float lastUtilityTime = 0f; private float lastSpecialTime = 0f; private float sprintGraceTimer = 0f; private readonly Dictionary> ignoredSkillsPerCharacter = new Dictionary> { { "COMMANDO_BODY_NAME", new List { (SkillSlot)2 } }, { "HUNTRESS_BODY_NAME", new List { (SkillSlot)2 } }, { "BANDIT2_BODY_NAME", new List { (SkillSlot)2 } }, { "LOADER_BODY_NAME", new List { (SkillSlot)0, (SkillSlot)1, (SkillSlot)2 } }, { "CAPTAIN_BODY_NAME", new List() }, { "TOOLBOT_BODY_NAME", new List { (SkillSlot)2 } }, { "CROCO_BODY_NAME", new List { (SkillSlot)0, (SkillSlot)2 } }, { "MERC_BODY_NAME", new List { (SkillSlot)0, (SkillSlot)2 } }, { "VOIDSURVIVOR_BODY_NAME", new List { (SkillSlot)2 } }, { "SEEKER_BODY_NAME", new List { (SkillSlot)2 } }, { "CHEF_BODY_NAME", new List { (SkillSlot)2 } }, { "DRIFTER_BODY_NAME", new List { (SkillSlot)0 } }, { "RAILGUNNER_BODY_NAME", new List { (SkillSlot)1 } } }; public void Awake() { maxTargetingRange = ((BaseUnityPlugin)this).Config.Bind("Targeting", "MaxRange", 100f, "Max range to acquire targets."); requireLineOfSight = ((BaseUnityPlugin)this).Config.Bind("Targeting", "RequireLineOfSight", true, "Only target visible enemies."); targetPriority = ((BaseUnityPlugin)this).Config.Bind("Targeting", "Priority", TargetPriority.Closest, "How to prioritize targets within range."); enableAutoAim = ((BaseUnityPlugin)this).Config.Bind("Settings", "EnableAutoAim", true, "Global toggle for all auto-aiming."); pauseOnSprint = ((BaseUnityPlugin)this).Config.Bind("Settings", "PauseOnSprint", true, "Pause while sprinting."); enableTargetUI = ((BaseUnityPlugin)this).Config.Bind("UI Settings", "EnableTargetUI", true, "Show visual indicator on targeted enemy."); uiColorR = ((BaseUnityPlugin)this).Config.Bind("UI Settings", "ColorRed", 255, "Red value for the target UI (0-255)."); uiColorG = ((BaseUnityPlugin)this).Config.Bind("UI Settings", "ColorGreen", 0, "Green value for the target UI (0-255)."); uiColorB = ((BaseUnityPlugin)this).Config.Bind("UI Settings", "ColorBlue", 0, "Blue value for the target UI (0-255)."); attackPrimary = ((BaseUnityPlugin)this).Config.Bind("Attack Toggles", "AttackPrimary", true, "Enable auto-attack for Primary."); attackSecondary = ((BaseUnityPlugin)this).Config.Bind("Attack Toggles", "AttackSecondary", true, "Enable auto-attack for Secondary."); attackUtility = ((BaseUnityPlugin)this).Config.Bind("Attack Toggles", "AttackUtility", true, "Enable auto-attack for Utility."); attackSpecial = ((BaseUnityPlugin)this).Config.Bind("Attack Toggles", "AttackSpecial", true, "Enable auto-attack for Special."); enablePrimaryDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "EnablePrimaryDelay", true, "Enable timing delay for Primary."); enableSecondaryDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "EnableSecondaryDelay", true, "Enable timing delay for Secondary."); enableUtilityDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "EnableUtilityDelay", true, "Enable timing delay for Utility."); enableSpecialDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "EnableSpecialDelay", true, "Enable timing delay for Special."); primaryDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "PrimaryDelay", 0.12f, "Delay between primary executions."); secondaryDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "SecondaryDelay", 0.12f, "Delay between secondary executions."); utilityDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "UtilityDelay", 0.12f, "Delay between utility executions."); specialDelay = ((BaseUnityPlugin)this).Config.Bind("Timing", "SpecialDelay", 0.12f, "Delay between special executions."); ((Component)this).gameObject.AddComponent(); } public void FixedUpdate() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) if (PlayerCharacterMasterController.instances.Count == 0) { return; } CharacterMaster master = PlayerCharacterMasterController.instances[0].master; if ((Object)(object)master == (Object)null) { return; } CharacterBody body = master.GetBody(); if ((Object)(object)body == (Object)null || !body.healthComponent.alive) { return; } InputBankTest component = ((Component)body).GetComponent(); SkillLocator component2 = ((Component)body).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { return; } CharacterBody val = null; Vector3 corePosition = body.corePosition; float num = maxTargetingRange.Value * maxTargetingRange.Value; float num2 = num; float num3 = ((targetPriority.Value == TargetPriority.HighestHealth) ? float.MinValue : float.MaxValue); Vector3 val2; RaycastHit val4 = default(RaycastHit); foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { if (readOnlyInstances.teamComponent.teamIndex == body.teamComponent.teamIndex || !readOnlyInstances.healthComponent.alive) { continue; } val2 = readOnlyInstances.corePosition - corePosition; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude <= num)) { continue; } if (requireLineOfSight.Value) { Vector3 val3 = readOnlyInstances.corePosition - corePosition; float num4 = Mathf.Sqrt(sqrMagnitude); LayerIndex world = LayerIndex.world; if (Physics.Raycast(corePosition, val3, ref val4, num4, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask))) { continue; } } bool flag = false; float health = readOnlyInstances.healthComponent.health; switch (targetPriority.Value) { case TargetPriority.Closest: if (sqrMagnitude < num2) { num2 = sqrMagnitude; flag = true; } break; case TargetPriority.HighestHealth: if (health > num3) { num3 = health; flag = true; } break; case TargetPriority.LowestHealth: if (health < num3) { num3 = health; flag = true; } break; } if (flag) { val = readOnlyInstances; } } if ((Object)(object)val != (Object)null) { currentTarget = val; List list = new List(); if (ignoredSkillsPerCharacter.TryGetValue(body.baseNameToken, out var value)) { list = value; } bool flag2 = false; bool flag3 = false; if (component.sprint.down) { sprintGraceTimer = 0.25f; } if (sprintGraceTimer > 0f) { sprintGraceTimer -= Time.fixedDeltaTime; } if (pauseOnSprint.Value && (body.isSprinting || sprintGraceTimer > 0f)) { flag2 = true; flag3 = true; } if (body.baseNameToken == "RAILGUNNER_BODY_NAME" && (component.skill2.down || ((Object)(object)component2.primary.skillDef != (Object)null && (component2.primary.skillDef.skillNameToken.Contains("SNIPE") || component2.primary.skillDef.skillNameToken.Contains("RELOAD"))))) { flag2 = true; } if (!flag3 && enableAutoAim.Value) { val2 = val.corePosition - corePosition; component.aimDirection = ((Vector3)(ref val2)).normalized; } if (!flag2) { float fixedTime = Time.fixedTime; if ((Object)(object)component2.primary != (Object)null && !list.Contains((SkillSlot)0) && attackPrimary.Value && (!enablePrimaryDelay.Value || fixedTime - lastPrimaryTime >= primaryDelay.Value)) { component2.primary.ExecuteIfReady(); lastPrimaryTime = fixedTime; } if ((Object)(object)component2.secondary != (Object)null && !list.Contains((SkillSlot)1) && attackSecondary.Value && (!enableSecondaryDelay.Value || fixedTime - lastSecondaryTime >= secondaryDelay.Value)) { component2.secondary.ExecuteIfReady(); lastSecondaryTime = fixedTime; } if ((Object)(object)component2.utility != (Object)null && !list.Contains((SkillSlot)2) && attackUtility.Value && (!enableUtilityDelay.Value || fixedTime - lastUtilityTime >= utilityDelay.Value)) { component2.utility.ExecuteIfReady(); lastUtilityTime = fixedTime; } if ((Object)(object)component2.special != (Object)null && !list.Contains((SkillSlot)3) && attackSpecial.Value && (!enableSpecialDelay.Value || fixedTime - lastSpecialTime >= specialDelay.Value)) { component2.special.ExecuteIfReady(); lastSpecialTime = fixedTime; } } } else { currentTarget = null; } } } public class AutoFireUI : MonoBehaviour { private GUIStyle reticleStyle; private GUIStyle arrowStyle; private void SetupStyles() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown if (reticleStyle == null) { reticleStyle = new GUIStyle(); reticleStyle.fontSize = 20; reticleStyle.alignment = (TextAnchor)4; reticleStyle.fontStyle = (FontStyle)1; arrowStyle = new GUIStyle(); arrowStyle.fontSize = 32; arrowStyle.alignment = (TextAnchor)4; } } private Color GetConfigColor() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) float num = (float)Mathf.Clamp(AutoFireMod.uiColorR.Value, 0, 255) / 255f; float num2 = (float)Mathf.Clamp(AutoFireMod.uiColorG.Value, 0, 255) / 255f; float num3 = (float)Mathf.Clamp(AutoFireMod.uiColorB.Value, 0, 255) / 255f; return new Color(num, num2, num3); } public void OnGUI() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00a2: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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) //IL_0146: 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) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_0105: Unknown result type (might be due to invalid IL or missing references) if (AutoFireMod.enableTargetUI == null || !AutoFireMod.enableTargetUI.Value || (Object)(object)AutoFireMod.currentTarget == (Object)null) { return; } Camera val = Camera.main; if ((Object)(object)val == (Object)null && CameraRigController.readOnlyInstancesList.Count > 0) { val = CameraRigController.readOnlyInstancesList[0].sceneCam; } if ((Object)(object)val == (Object)null) { return; } SetupStyles(); Color configColor = GetConfigColor(); reticleStyle.normal.textColor = configColor; arrowStyle.normal.textColor = configColor; Vector3 corePosition = AutoFireMod.currentTarget.corePosition; Vector3 val2 = val.WorldToScreenPoint(corePosition); val2.y = (float)Screen.height - val2.y; if (!(val2.z < 0f) && !(val2.x < 0f) && !(val2.x > (float)Screen.width) && !(val2.y < 0f) && !(val2.y > (float)Screen.height)) { GUI.Label(new Rect(val2.x - 50f, val2.y - 50f, 100f, 100f), "[ ]", reticleStyle); return; } Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(val2.x - val3.x, val2.y - val3.y); if (val2.z < 0f) { val4 = -val4; } ((Vector2)(ref val4)).Normalize(); float num = (float)Mathf.Min(Screen.width, Screen.height) * 0.4f; Vector2 val5 = val3 + val4 * num; float num2 = Mathf.Atan2(val4.y, val4.x) * 57.29578f; Matrix4x4 matrix = GUI.matrix; GUIUtility.RotateAroundPivot(num2, val5); GUI.Label(new Rect(val5.x - 20f, val5.y - 20f, 40f, 40f), "►", arrowStyle); GUI.matrix = matrix; } }