using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using AutoNudge; using BTD_Mod_Helper; using BTD_Mod_Helper.Api; using BTD_Mod_Helper.Api.ModOptions; using BTD_Mod_Helper.Extensions; using Il2Cpp; using Il2CppAssets.Scripts.Unity.Bridge; using Il2CppAssets.Scripts.Unity.UI_New.InGame; using Il2CppGeom; using MelonLoader; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(AutoNudgeMod), "Auto Nudge", "1.0.3", "doombubbles", null)] [assembly: MelonGame("Ninja Kiwi", "BloonsTD6")] [assembly: MelonGame("Ninja Kiwi", "BloonsTD6-Epic")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("AutoNudge")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+fb2b10c85d5926d78d406239e909381010e30de3")] [assembly: AssemblyProduct("AutoNudge")] [assembly: AssemblyTitle("AutoNudge")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [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 AutoNudge { public class AutoNudgeMod : BloonsTD6Mod { public static readonly ModSettingHotkey AutoNudgeHotkey = new ModSettingHotkey((KeyCode)9, (HotkeyModifier)0) { description = "HotKey that will automatically nudge towers to the closest valid spot while placing them.", icon = ModContent.GetTextureGUID("Icon") }; public static readonly ModSettingHotkey NudgeLeft = new ModSettingHotkey((KeyCode)276, (HotkeyModifier)0) { icon = "Gamepad[PS4_Dpad_Left]" }; public static readonly ModSettingHotkey NudgeRight = new ModSettingHotkey((KeyCode)275, (HotkeyModifier)0) { icon = "Gamepad[PS4_Dpad_Right]" }; public static readonly ModSettingHotkey NudgeUp = new ModSettingHotkey((KeyCode)273, (HotkeyModifier)0) { icon = "Gamepad[PS4_Dpad_Up]" }; public static readonly ModSettingHotkey NudgeDown = new ModSettingHotkey((KeyCode)274, (HotkeyModifier)0) { icon = "Gamepad[PS4_Dpad_Down]" }; public static readonly ModSettingHotkey ConfirmPlacement = new ModSettingHotkey((KeyCode)13, (HotkeyModifier)0) { icon = "Ui[SelectedTick]" }; public static Instance MelonLogger => Melon.Logger; public override void OnUpdate() { AutoNudgeUtility.Update(); } } public class AutoNudgeUtility { private static ModSettingHotkey NudgeToClosest => AutoNudgeMod.AutoNudgeHotkey; public static void Update() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)InGame.instance) || InGame.Bridge == null || InGame.instance.ReviewMapMode || InGame.Bridge.IsSpectatorMode) { return; } InputManager inputManager = InGameExt[InGame.instance]; if (!inputManager.IsInPlacementMode) { return; } if (NudgeToClosest.JustPressed()) { NudgeClosest(); if (AutoNudgeMod.ConfirmPlacement.IsPressed()) { TaskScheduler.ScheduleTask((Action)delegate { inputManager.TryPlace(); }, (Func)null); } } else { Vector2 val = Vector2.zero; if (AutoNudgeMod.NudgeLeft.IsPressed()) { val += new Vector2(-1f, 0f); } if (AutoNudgeMod.NudgeRight.IsPressed()) { val += new Vector2(1f, 0f); } if (AutoNudgeMod.NudgeUp.IsPressed()) { val += new Vector2(0f, 1f); } if (AutoNudgeMod.NudgeDown.IsPressed()) { val += new Vector2(0f, -1f); } if (val != Vector2.zero) { NudgeDirection(val); } } if (AutoNudgeMod.ConfirmPlacement.JustPressed()) { inputManager.TryPlace(); } } private static void NudgeClosest() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) Vector2 val = InputSystemController.MousePosition; int num = 0; while (!CanPlace(val)) { val = InputSystemController.MousePosition + GeomExtensions.Rotate(Vector2.up, (float)(num * 10)) * (float)num / 10f; ((Vector2)(ref val))..ctor((float)(int)val.x, (float)(int)val.y); if (num++ > 20000) { AutoNudgeMod.MelonLogger.Msg("No spot found"); return; } } Mouse.current.WarpCursorPosition(val); } private static bool CanPlace(Vector2 realCursorPos) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) InputManager val = InGameExt[InGame.instance]; UnityToSimulation bridge = InGame.instance.bridge; Vector2 worldFromPointer = InGame.instance.GetWorldFromPointer(realCursorPos); return bridge.CanPlaceTowerAt(worldFromPointer, val.placementModel, bridge.MyPlayerNumber, val.placementEntityId); } private static void NudgeDirection(Vector2 dir) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) int width = Screen.width; float num = (float)width / 1000f; if (Input.GetKey((KeyCode)306)) { num *= 5f; } int num2 = ((Random.Shared.NextSingle() < num - (float)(int)num) ? 1 : 0); int num3 = (int)num + num2; Vector2 mousePosition = InputSystemController.MousePosition; Mouse.current.WarpCursorPosition(mousePosition + dir * (float)num3); } } public static class ModHelperData { public const string WorksOnVersion = "52.0"; public const string Version = "1.0.3"; public const string Name = "Auto Nudge"; public const string Description = "When placing a tower, you can press the Auto Nudge hotkey (default Tab) to automatically move your mouse / the tower to the closest valid spot for placement.\n\nFor best results, make sure you've got Nudge Mode Disabled in the default game's settings."; public const string RepoOwner = "doombubbles"; public const string PrevRepoName = "auto-nudge"; public const string RepoName = "AutoNudge"; } }