Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DisableBuildMenuDrag v1.0.2
DisableBuildMenuDrag.dll
Decompiled 3 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [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("DisableBuildMenuDrag")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Disables click-and-drag scrolling in Valheim's build menu")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("DisableBuildMenuDrag")] [assembly: AssemblyTitle("DisableBuildMenuDrag")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [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 DisableBuildMenuDrag { [BepInPlugin("com.babelthuap.disablebuildmenudrag", "Disable Build Menu Drag", "1.0.2")] public class DisableBuildMenuDragPlugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.babelthuap.disablebuildmenudrag"); public static bool WaitingForMouseReleaseAfterPieceSelect = false; public static readonly FieldInfo PlacePressedField = AccessTools.Field(typeof(Player), "m_placePressed"); private static readonly MethodInfo GetMouseButtonMethod = GetGetMouseButtonMethod(); private void Awake() { harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"DisableBuildMenuDrag Loaded!"); } private static MethodInfo GetGetMouseButtonMethod() { return (Type.GetType("UnityEngine.Input, UnityEngine") ?? Type.GetType("UnityEngine.Input, UnityEngine.InputLegacyModule"))?.GetMethod("GetMouseButton", new Type[1] { typeof(int) }); } public static bool IsLeftMouseHeld() { if (GetMouseButtonMethod != null) { try { return (bool)GetMouseButtonMethod.Invoke(null, new object[1] { 0 }); } catch { return false; } } return false; } } [HarmonyPatch(typeof(Selectable), "OnPointerDown")] public static class Selectable_OnPointerDown_Patch { public static void Postfix(Selectable __instance, PointerEventData eventData) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Hud.instance == (Object)null || !Hud.instance.m_buildHud.activeInHierarchy || eventData == null || (int)eventData.button != 0) { return; } Button val = (Button)(object)((__instance is Button) ? __instance : null); if (val != null) { ButtonClickedEvent onClick = val.onClick; if (onClick != null) { ((UnityEvent)onClick).Invoke(); } } } } [HarmonyPatch(typeof(Player), "SetSelectedPiece", new Type[] { typeof(Vector2Int) })] public static class Player_SetSelectedPiece_Patch { public static void Postfix(Player __instance) { DisableBuildMenuDragPlugin.WaitingForMouseReleaseAfterPieceSelect = true; if ((Object)(object)__instance != (Object)null && DisableBuildMenuDragPlugin.PlacePressedField != null) { DisableBuildMenuDragPlugin.PlacePressedField.SetValue(__instance, false); } } } [HarmonyPatch(typeof(Player), "UpdatePlacement")] public static class Player_UpdatePlacement_Patch { public static bool Prefix(Player __instance) { if (DisableBuildMenuDragPlugin.WaitingForMouseReleaseAfterPieceSelect) { if (DisableBuildMenuDragPlugin.IsLeftMouseHeld()) { DisableBuildMenuDragPlugin.PlacePressedField?.SetValue(__instance, false); return false; } DisableBuildMenuDragPlugin.WaitingForMouseReleaseAfterPieceSelect = false; } return true; } } }