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 SmallCrouchMode v1.0.1
SmallCrouchMode.dll
Decompiled 2 weeks agousing System; 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("SmallCrouchMode")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP")] [assembly: AssemblyProduct("SmallCrouchMode")] [assembly: AssemblyCopyright("Copyright © HP 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4ab92ed5-1336-45ec-8ae8-491ce552fb68")] [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 SmallCrouchMode; [BepInPlugin("TechedCrayon413.SmallCrouchMode", "Small Crouch Mode", "1.0.0")] public class SmallCrouchModePlugin : BaseUnityPlugin { public static ConfigEntry<KeyCode> CrawlKey; public static ConfigEntry<bool> ToggleMode; public static ConfigEntry<float> CrawlSpeedMultiplier; private void Awake() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown CrawlKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Crawl Key", (KeyCode)308, "Key used to crawl"); ToggleMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Crawl Key Toggle Mode", true, "If true = press to toggle, if false = hold"); CrawlSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Crawl Speed Multiplier", 1f, "Speed while crawling"); Harmony val = new Harmony("TechedCrayon413.SmallCrouchMode"); val.PatchAll(); } } public static class TinyCrawlState { public static bool IsTiny; } [HarmonyPatch] public static class Patch_PlayerController { private static FieldInfo _crouchSpeedField; private static MethodInfo _setCrawlMethod; private static PropertyInfo _isLocalPlayerProp; private static float _originalCrouchSpeed = -1f; private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PlayerController"); if (type == null) { return null; } _crouchSpeedField = AccessTools.Field(type, "CrouchSpeed"); _setCrawlMethod = AccessTools.Method(type, "SetCrawl", (Type[])null, (Type[])null); _isLocalPlayerProp = AccessTools.Property(type, "IsLocalPlayer"); return AccessTools.Method(type, "Update", (Type[])null, (Type[])null); } private static void Postfix(object __instance) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00a4: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || (_isLocalPlayerProp != null && !(bool)_isLocalPlayerProp.GetValue(__instance)) || _crouchSpeedField == null || _setCrawlMethod == null) { return; } if (_originalCrouchSpeed < 0f) { _originalCrouchSpeed = (float)_crouchSpeedField.GetValue(__instance); } KeyCode value = SmallCrouchModePlugin.CrawlKey.Value; bool keyDown = Input.GetKeyDown(value); bool key = Input.GetKey(value); if (SmallCrouchModePlugin.ToggleMode.Value) { if (keyDown) { TinyCrawlState.IsTiny = !TinyCrawlState.IsTiny; } } else { TinyCrawlState.IsTiny = key; } if (TinyCrawlState.IsTiny) { _setCrawlMethod.Invoke(__instance, null); float num = _originalCrouchSpeed * SmallCrouchModePlugin.CrawlSpeedMultiplier.Value; _crouchSpeedField.SetValue(__instance, num); } else { _crouchSpeedField.SetValue(__instance, _originalCrouchSpeed); } } }