using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; 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("CloserGrabDistance")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP")] [assembly: AssemblyProduct("CloserGrabDistance")] [assembly: AssemblyCopyright("Copyright © HP 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d3aede3f-b982-4690-bf07-01e6c781b00a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace CloserGrabDistance; [BepInPlugin("TechedCrayon413.CloserGrabDistance", "CloserGrabDistance", "1.0.0")] public class CloserGrabDistance : BaseUnityPlugin { public static ConfigEntry ModEnabledSwitchConfig; public static ConfigEntry CloserGrabDistanceConfig; public static FieldInfo pullerDistanceField; public static FieldInfo minDistanceFromPlayerOriginalField; public static float? VanillaCloseGrabDistance; private void Awake() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) ModEnabledSwitchConfig = ((BaseUnityPlugin)this).Config.Bind("Mod On/Off Switch", "On/Off", true, "Set false to set the grab beam distance to normal (vanilla REPO value is 1.0)"); CloserGrabDistanceConfig = ((BaseUnityPlugin)this).Config.Bind("Grab Distance", "Close Grab Distance", 0.1f, "How close you can hold things. (vanilla REPO is 1.0)"); pullerDistanceField = AccessTools.Field(typeof(PhysGrabber), "pullerDistance"); minDistanceFromPlayerOriginalField = AccessTools.Field(typeof(PhysGrabber), "minDistanceFromPlayerOriginal"); new Harmony("TechedCrayon413.CloserGrabDistance").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CloserGrabDistance v1.0.0 loaded successfully"); } } [HarmonyPatch(typeof(PhysGrabber), "Update")] public class PhysGrabberPatch { private static void Postfix(PhysGrabber __instance) { if (!__instance.isLocal) { return; } if (!CloserGrabDistance.VanillaCloseGrabDistance.HasValue) { CloserGrabDistance.VanillaCloseGrabDistance = (float?)CloserGrabDistance.minDistanceFromPlayerOriginalField?.GetValue(__instance); } StatsManager instance = StatsManager.instance; string text = SemiFunc.PlayerGetSteamID(__instance.playerAvatar); if ((Object)(object)instance != (Object)null && instance.playerUpgradeRange != null && !string.IsNullOrEmpty(text) && instance.playerUpgradeRange.ContainsKey(text)) { float num = instance.playerUpgradeRange[text]; __instance.grabRange = 4f + num; } __instance.maxDistanceFromPlayer = __instance.grabRange; float num2 = (__instance.minDistanceFromPlayer = (CloserGrabDistance.ModEnabledSwitchConfig.Value ? CloserGrabDistance.CloserGrabDistanceConfig.Value : CloserGrabDistance.VanillaCloseGrabDistance.GetValueOrDefault(1f))); CloserGrabDistance.minDistanceFromPlayerOriginalField?.SetValue(__instance, num2); if (!CloserGrabDistance.ModEnabledSwitchConfig.Value || !__instance.grabbed || !(CloserGrabDistance.pullerDistanceField != null)) { return; } object value = CloserGrabDistance.pullerDistanceField.GetValue(__instance); if (value is float) { float num3 = (float)value; if (num3 < num2) { CloserGrabDistance.pullerDistanceField.SetValue(__instance, num2); } } } }