using 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.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace SmallCrouchMode; [BepInPlugin("TechedCrayon413.SmallCrouchMode", "Small Crouch Mode", "1.0.3")] public class SmallCrouchModePlugin : BaseUnityPlugin { public static ConfigEntry CrawlKey; public static ConfigEntry ToggleMode; public static ConfigEntry 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("Controls", "Crawl Key", (KeyCode)308, "Key used to crawl"); ToggleMode = ((BaseUnityPlugin)this).Config.Bind("General", "Crawl Key Toggle Mode", true, "If true = press to toggle, if false = hold"); CrawlSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("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 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); return AccessTools.Method(type, "Update", (Type[])null, (Type[])null); } private static void Postfix(object __instance) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || _crouchSpeedField == null || _setCrawlMethod == null) { return; } if (_originalCrouchSpeed < 0f) { _originalCrouchSpeed = (float)_crouchSpeedField.GetValue(__instance); } KeyCode value = SmallCrouchModePlugin.CrawlKey.Value; if (SmallCrouchModePlugin.ToggleMode.Value) { if (Input.GetKeyDown(value)) { TinyCrawlState.IsTiny = !TinyCrawlState.IsTiny; } } else { TinyCrawlState.IsTiny = Input.GetKey(value); } if (TinyCrawlState.IsTiny) { _setCrawlMethod.Invoke(__instance, null); float num = _originalCrouchSpeed * SmallCrouchModePlugin.CrawlSpeedMultiplier.Value; _crouchSpeedField.SetValue(__instance, num); } else { _crouchSpeedField.SetValue(__instance, _originalCrouchSpeed); } } }