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 QuickScrollRange v1.0.0
QuickScrollRange.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("REPOJP")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("REPOJP")] [assembly: AssemblyTitle("REPOJP")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 REPOJP.QuickScrollRangeMod { [BepInPlugin("REPOJP.QuickScrollRange", "QuickScrollRange", "1.0.0")] public sealed class QuickScrollRangePlugin : BaseUnityPlugin { [HarmonyPatch(typeof(PhysGrabber), "Update")] private static class PhysGrabberUpdatePatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(QuickScrollRangePlugin), "GetForwardStep", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(QuickScrollRangePlugin), "GetBackwardStep", (Type[])null, (Type[])null); int num = 0; for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && list[i].operand is float num2 && Mathf.Abs(num2 - 0.2f) < 0.0001f) { switch (num) { case 0: list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo)); num++; i++; continue; case 1: break; default: continue; } list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); num++; i++; break; } } if (num != 2) { LogSource.LogError((object)string.Format("[{0}] Failure: PhysGrabber.Update transpiler replacement count = {1}", "QuickScrollRange", num)); } else { LogSource.LogInfo((object)"[QuickScrollRange] PhysGrabber.Update patched successfully"); } return list; } } public const string PluginGuid = "REPOJP.QuickScrollRange"; public const string PluginName = "QuickScrollRange"; public const string PluginVersion = "1.0.0"; private Harmony harmony; internal static ManualLogSource LogSource; internal static ConfigEntry<bool> EnableMod; internal static ConfigEntry<float> ForwardScrollMultiplier; internal static ConfigEntry<float> BackwardScrollMultiplier; internal static ConfigEntry<bool> DisableMultiplierWhileCrouching; internal static ConfigEntry<bool> EnableCrouchSprintSpecialMultiplier; internal static ConfigEntry<float> CrouchSprintForwardScrollMultiplier; internal static ConfigEntry<float> CrouchSprintBackwardScrollMultiplier; internal static ConfigEntry<bool> EnableDebugLog; private static readonly FieldRef<PhysGrabber, Camera> PlayerCameraRef = AccessTools.FieldRefAccess<PhysGrabber, Camera>("playerCamera"); private const float VanillaStep = 0.2f; private const float MinMultiplier = 0.01f; private const float MaxMultiplier = 10f; private void Awake() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown try { ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("[{0}] Failure: 永続化設定 {1}", "QuickScrollRange", arg)); } LogSource = ((BaseUnityPlugin)this).Logger; InitializeConfig(); harmony = new Harmony("REPOJP.QuickScrollRange"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[QuickScrollRange] Loaded"); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("[{0}] Forward={1:0.00} Backward={2:0.00} CrouchDisable={3} CrouchSprintSpecial={4} CrouchSprintForward={5:0.00} CrouchSprintBackward={6:0.00} DebugLog={7}", "QuickScrollRange", GetConfigMultiplier(ForwardScrollMultiplier), GetConfigMultiplier(BackwardScrollMultiplier), DisableMultiplierWhileCrouching.Value, EnableCrouchSprintSpecialMultiplier.Value, GetConfigMultiplier(CrouchSprintForwardScrollMultiplier), GetConfigMultiplier(CrouchSprintBackwardScrollMultiplier), EnableDebugLog.Value)); } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } } private void InitializeConfig() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "MODの有効設定"); ForwardScrollMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ForwardScrollMultiplier", 5f, new ConfigDescription("前スクロール時の倍率設定", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); BackwardScrollMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BackwardScrollMultiplier", 5f, new ConfigDescription("後ろスクロール時の倍率設定", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); DisableMultiplierWhileCrouching = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableMultiplierWhileCrouching", true, "しゃがみ押下中は通常倍率を無効化してバニラ移動量に戻す設定"); EnableCrouchSprintSpecialMultiplier = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableCrouchSprintSpecialMultiplier", true, "しゃがみ+スプリント同時押し時に専用倍率を使う設定"); CrouchSprintForwardScrollMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CrouchSprintForwardScrollMultiplier", 0.35f, new ConfigDescription("しゃがみ+スプリント同時押し時の前スクロール倍率設定", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); CrouchSprintBackwardScrollMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CrouchSprintBackwardScrollMultiplier", 0.35f, new ConfigDescription("しゃがみ+スプリント同時押し時の後ろスクロール倍率設定", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); EnableDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugLog", false, "デバッグログ出力設定"); } public static float GetForwardStep(PhysGrabber instance) { return GetResolvedStep(instance, isForward: true); } public static float GetBackwardStep(PhysGrabber instance) { return GetResolvedStep(instance, isForward: false); } private static float GetResolvedStep(PhysGrabber instance, bool isForward) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (!EnableMod.Value || (Object)(object)instance == (Object)null) { return 0.2f; } Camera val = null; try { val = PlayerCameraRef.Invoke(instance); } catch { return 0.2f; } if ((Object)(object)val == (Object)null || (Object)(object)instance.physGrabPointPuller == (Object)null) { return 0.2f; } float num = Vector3.Distance(instance.physGrabPointPuller.position, ((Component)val).transform.position); string mode; float num2 = ResolveEffectiveMultiplier(isForward, out mode); float num3 = 0.2f * num2; float num4 = ((!isForward) ? Mathf.Max(0f, num - instance.minDistanceFromPlayer) : Mathf.Max(0f, instance.grabRange - num)); float num5 = Mathf.Min(num3, num4); if (EnableDebugLog.Value) { LogSource.LogInfo((object)string.Format("[{0}] Direction={1} Mode={2} Distance={3:0.000} Multiplier={4:0.00} Vanilla={5:0.000} Desired={6:0.000} Remaining={7:0.000} Final={8:0.000}", "QuickScrollRange", isForward ? "Forward" : "Backward", mode, num, num2, 0.2f, num3, num4, num5)); } return num5; } private static float ResolveEffectiveMultiplier(bool isForward, out string mode) { bool flag = IsInputPressed((InputKey)12); bool flag2 = IsInputPressed((InputKey)15); if (EnableCrouchSprintSpecialMultiplier.Value && flag && flag2) { mode = "CrouchSprint"; return GetConfigMultiplier(isForward ? CrouchSprintForwardScrollMultiplier : CrouchSprintBackwardScrollMultiplier); } if (DisableMultiplierWhileCrouching.Value && flag) { mode = "CrouchDisabled"; return 1f; } mode = "Normal"; return GetConfigMultiplier(isForward ? ForwardScrollMultiplier : BackwardScrollMultiplier); } private static bool IsInputPressed(InputKey inputKey) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)InputManager.instance == (Object)null) { return false; } InputAction action = InputManager.instance.GetAction(inputKey); if (action == null) { return false; } return action.IsPressed(); } private static float GetConfigMultiplier(ConfigEntry<float> entry) { if (entry == null) { return 1f; } return Mathf.Clamp(entry.Value, 0.01f, 10f); } } }