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 RTAutoSprintEx v2.2.3
RTAutoSprintEx.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using EntityStates; using IL.RoR2.CameraModes; using IL.RoR2.UI; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using Rewired; using RoR2; using UnityEngine; [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 = "")] [assembly: AssemblyCompany("RTAutoSprintEx")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RTAutoSprintEx")] [assembly: AssemblyTitle("RTAutoSprintEx")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace RTAutoSprintEx; [BepInPlugin("com.johnedwa.RTAutoSprintEx", "RTAutoSprintEx", "2.2.3")] public class RTAutoSprintEx : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<Instruction, bool> <>9__10_4; public static Manipulator <>9__10_2; public static Func<Instruction, bool> <>9__10_5; internal void <Awake>b__10_2(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.Index = 0; val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1.3f) }); val.Next.Operand = (float)SprintFOVMultiplier.Value; } internal bool <Awake>b__10_4(Instruction x) { return ILPatternMatchingExt.MatchLdcR4(x, 1.3f); } internal bool <Awake>b__10_5(Instruction x) { return ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_isSprinting"); } } private static bool RT_enabled = true; private static bool RT_visuals = true; internal HashSet<string> stateSprintDisableList = new HashSet<string>(); internal HashSet<string> stateAnimationDelayList = new HashSet<string>(); public static ConfigFile conf; public static ConfigEntry<bool> SprintInAnyDirection { get; set; } public static ConfigEntry<bool> HoldSprintToWalk { get; set; } public static ConfigEntry<bool> HoldToSprint { get; set; } public static ConfigEntry<bool> DisableSprintingCrosshair { get; set; } public static ConfigEntry<bool> DisableFOVChange { get; set; } public static ConfigEntry<bool> DisableSpeedlines { get; set; } public static ConfigEntry<int> CustomFOV { get; set; } public static ConfigEntry<double> SprintFOVMultiplier { get; set; } public static ConfigEntry<bool> DisableAutoSprinting { get; set; } public static ConfigEntry<bool> DisableVisualChanges { get; set; } public static ConfigEntry<string> EntityStatesSprintingDisabled { get; set; } public static ConfigEntry<string> EntityStatesSprintingDelay { get; set; } public void RT_SprintDisableMessage(string state) { stateSprintDisableList.Add(state); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Received RT_SprintDisableMessage for " + state)); } public void RT_AnimationDelayMessage(string state) { stateAnimationDelayList.Add(state); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Received RT_AnimationDelayMessage for " + state)); } private bool RT_RegisterAnimationDelay(string state) { return stateAnimationDelayList.Add(state); } private bool RT_RegisterSprintDisable(string state) { return stateSprintDisableList.Add(state); } private double SprintDelayTime(CharacterBody targetBody) { float num = 0f; EntityStateMachine[] components = ((Component)targetBody).GetComponents<EntityStateMachine>(); EntityStateMachine[] array = components; foreach (EntityStateMachine val in array) { EntityState state = val.state; if (state == null) { return num; } if (stateAnimationDelayList.Contains(((object)state).ToString())) { try { num = state.GetInstanceField<float>("duration"); } catch { } return num; } } return num; } private bool ShouldSprintBeDisabledOnThisBody(CharacterBody targetBody) { EntityStateMachine[] components = ((Component)targetBody).GetComponents<EntityStateMachine>(); bool result = false; EntityStateMachine[] array = components; foreach (EntityStateMachine val in array) { EntityState state = val.state; if (state == null) { return false; } if (stateSprintDisableList.Contains(((object)state).ToString())) { result = true; } } return result; } public void Awake() { //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown double RT_timer = 0.0; double RT_animationCancelDelay = 0.15; bool RT_isSprinting = false; bool RT_animationCancel = false; SetupConfiguration(); RT_RegisterSprintDisable("EntityStates.Toolbot.ToolbotDualWield"); RT_RegisterSprintDisable("EntityStates.Toolbot.ToolbotDualWieldBase"); RT_RegisterSprintDisable("EntityStates.Toolbot.ToolbotDualWieldStart"); RT_RegisterSprintDisable("EntityStates.Toolbot.FireNailgun"); RT_RegisterSprintDisable("EntityStates.Toolbot.AimStunDrone"); RT_RegisterAnimationDelay("EntityStates.Toolbot.FireGrenadeLauncher"); RT_RegisterSprintDisable("EntityStates.Mage.Weapon.Flamethrower"); RT_RegisterSprintDisable("EntityStates.Mage.Weapon.PrepWall"); RT_RegisterAnimationDelay("EntityStates.Mage.Weapon.FireFireBolt"); RT_RegisterAnimationDelay("EntityStates.Mage.Weapon.FireLaserbolt"); RT_RegisterSprintDisable("EntityStates.Bandit2.Weapon.BasePrepSidearmRevolverState"); RT_RegisterSprintDisable("EntityStates.Bandit2.Weapon.PrepSidearmResetRevolver"); RT_RegisterSprintDisable("EntityStates.Bandit2.Weapon.PrepSidearmSkullRevolver"); RT_RegisterAnimationDelay("EntityStates.Bandit2.Weapon.Bandit2FirePrimaryBase"); RT_RegisterAnimationDelay("EntityStates.Bandit2.Weapon.FireShotgun2"); RT_RegisterAnimationDelay("EntityStates.Bandit2.Weapon.Bandit2FireRifle"); RT_RegisterSprintDisable("EntityStates.Engi.EngiMissilePainter.Paint"); RT_RegisterAnimationDelay("EntityStates.Engi.EngiWeapon.FireMines"); RT_RegisterAnimationDelay("EntityStates.Engi.EngiWeapon.FireSeekerGrenades"); RT_RegisterSprintDisable("EntityStates.Treebot.Weapon.AimMortar"); RT_RegisterSprintDisable("EntityStates.Treebot.Weapon.AimMortar2"); RT_RegisterSprintDisable("EntityStates.Treebot.Weapon.AimMortarRain"); RT_RegisterAnimationDelay("EntityStates.Treebot.Weapon.FireSyringe"); RT_RegisterSprintDisable("EntityStates.Captain.Weapon.SetupAirstrike"); RT_RegisterSprintDisable("EntityStates.Captain.Weapon.SetupAirstrikeAlt"); RT_RegisterSprintDisable("EntityStates.Captain.Weapon.SetupSupplyDrop"); RT_RegisterAnimationDelay("EntityStates.Croco.Slash"); RT_RegisterAnimationDelay("EntityStates.Commando.CommandoWeapon.FirePistol2"); RT_RegisterAnimationDelay("EntityStates.Loader.SwingComboFist"); RT_RegisterAnimationDelay("EntityStates.VoidSurvivor.Weapon.FireHandBeam"); RT_RegisterAnimationDelay("EntityStates.VoidSurvivor.Weapon.ChargeCorruptHandBeam"); RT_RegisterSprintDisable("EntityStates.VoidSurvivor.Weapon.FireCorruptHandBeam"); RT_RegisterAnimationDelay("EntityStates.Railgunner.Weapon.FirePistol"); RT_RegisterSprintDisable("EntityStates.Railgunner.Scope.WindUpScopeLight"); RT_RegisterSprintDisable("EntityStates.Railgunner.Scope.ActiveScopeLight"); RT_RegisterSprintDisable("EntityStates.Railgunner.Scope.WindUpScopeHeavy"); RT_RegisterSprintDisable("EntityStates.Railgunner.Scope.ActiveScopeHeavy"); if (RT_enabled) { PlayerCharacterMasterController.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, PlayerCharacterMasterController self) { //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); InputBankTest bodyInputs = self.bodyInputs; if (Object.op_Implicit((Object)(object)bodyInputs) && Object.op_Implicit((Object)(object)self.networkUser) && self.networkUser.localUser != null && !self.networkUser.localUser.isUIFocused) { CharacterBody body = self.body; if (Object.op_Implicit((Object)(object)body)) { bool flag = ShouldSprintBeDisabledOnThisBody(body); Player inputPlayer = self.networkUser.localUser.inputPlayer; RT_isSprinting = body.isSprinting; if (!RT_isSprinting) { RT_timer += Time.deltaTime; if (RT_timer >= 0.05) { if (!RT_animationCancel) { RT_timer = 0.0 - SprintDelayTime(body); } if (RT_timer >= 0.0) { RT_isSprinting = !flag; RT_animationCancel = false; RT_timer = 0.0; } } } else { RT_timer = 0.0; } bool value = HoldSprintToWalk.Value; bool value2 = HoldToSprint.Value; bool button = (button = inputPlayer.GetButton("Sprint")); if (button) { if (RT_isSprinting && value) { RT_isSprinting = false; } if (!RT_isSprinting && flag) { RT_isSprinting = true; } RT_timer = 0.0; } if (!value && value2 && !flag) { RT_isSprinting = button; } if (!RT_animationCancel && RT_timer < 0.0 - RT_animationCancelDelay && !inputPlayer.GetButton("PrimarySkill") && !inputPlayer.GetButton("SecondarySkill") && !inputPlayer.GetButton("SpecialSkill") && !inputPlayer.GetButton("UtilitySkill")) { RT_timer = 0.0 - RT_animationCancelDelay; RT_animationCancel = true; } if (RT_isSprinting && !SprintInAnyDirection.Value) { Vector3 aimDirection = bodyInputs.aimDirection; aimDirection.y = 0f; ((Vector3)(ref aimDirection)).Normalize(); Vector3 moveVector = bodyInputs.moveVector; moveVector.y = 0f; ((Vector3)(ref moveVector)).Normalize(); if ((body.bodyFlags & 0x20) == 0 && Vector3.Dot(aimDirection, moveVector) < PlayerCharacterMasterController.sprintMinAimMoveDot) { RT_isSprinting = false; } } ((ButtonState)(ref bodyInputs.sprint)).PushState(RT_isSprinting); } } }; } CameraRigController.LateUpdate += (hook_LateUpdate)delegate(orig_LateUpdate orig, CameraRigController self) { orig.Invoke(self); if (RT_visuals) { if (CustomFOV.Value >= 1 && CustomFOV.Value <= 180) { self.baseFov = CustomFOV.Value; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"CustomFOV value out of range!"); } if (DisableSpeedlines.Value && Object.op_Implicit((Object)(object)self.sprintingParticleSystem)) { ((Component)self.sprintingParticleSystem).gameObject.SetActive(false); } } }; object obj = <>c.<>9__10_2; if (obj == null) { Manipulator val = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val3 = new ILCursor(il); val3.Index = 0; val3.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1.3f) }); val3.Next.Operand = (float)SprintFOVMultiplier.Value; }; <>c.<>9__10_2 = val; obj = (object)val; } CameraModePlayerBasic.UpdateInternal += (Manipulator)obj; CrosshairManager.UpdateCrosshair += (Manipulator)delegate(ILContext il) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (RT_visuals) { ILCursor val2 = new ILCursor(il); if (DisableSprintingCrosshair.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Disabling sprinting crosshair:"); try { val2.Index = 0; val2.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_isSprinting") }); val2.Emit(OpCodes.Ldc_I4, 0); val2.Emit(OpCodes.And); } catch (Exception ex) { Debug.LogError((object)ex); } } } }; } private void SetupConfiguration() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown string text = Paths.ConfigPath + "\\com.johnedwa.RTAutoSprintEx.cfg"; conf = new ConfigFile(text, true); HoldSprintToWalk = conf.Bind<bool>("1) Movement", "HoldSprintToWalk", true, new ConfigDescription("Walk by holding down the sprint key. If disabled, makes the Sprint key toggle AutoSprinting functionality on and off.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); HoldToSprint = conf.Bind<bool>("1) Movement", "HoldToSprint", false, new ConfigDescription("Sprint by holding down the sprint key. Only works if HoldSprintToWalk is disabled.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); SprintInAnyDirection = conf.Bind<bool>("1) Movement", "SprintInAnyDirection", false, new ConfigDescription("Cheat, Allows you to sprint in any direction. Please don't use in multiplayer.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); DisableSprintingCrosshair = conf.Bind<bool>("2) Visual", "DisableSprintingCrosshair", true, new ConfigDescription("Disables the useless special sprinting chevron crosshair.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); CustomFOV = conf.Bind<int>("2) Visual", "FOVValue", 60, new ConfigDescription("Sets a custom (vertical) FOV. Game default 60V is roughly 90H.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 180), Array.Empty<object>())); SprintFOVMultiplier = conf.Bind<double>("2) Visual", "SprintFOVMultiplier", 1.3, new ConfigDescription("Sets the sprinting FOV multiplier. Set to 1 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.1, 2.0), Array.Empty<object>())); DisableSpeedlines = conf.Bind<bool>("2) Visual", "DisableSpeedlines", false, new ConfigDescription("Disables the speedlines effect shown when sprinting.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); DisableAutoSprinting = conf.Bind<bool>("3) Misc", "DisabledAutoSprinting", false, new ConfigDescription("Disable the AutoSprinting part of the mod.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); DisableVisualChanges = conf.Bind<bool>("3) Misc", "DisableVisualChanges", false, new ConfigDescription("Disable the FOV and visual changes of the mod.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { true, false }), Array.Empty<object>())); RT_enabled = !DisableAutoSprinting.Value; RT_visuals = !DisableVisualChanges.Value; if (!RT_enabled && !RT_visuals) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"DisabledAutoSprinting and DisableVisualChanges both True, the mod literally does nothing now."); } } } public static class Utils { internal static bool TryParseBool(string input, out bool result) { if (bool.TryParse(input, out result)) { return true; } if (int.TryParse(input, out var result2)) { result = result2 > 0; return true; } return false; } internal static T GetInstanceField<T>(this object instance, string fieldName) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = instance.GetType().GetField(fieldName, bindingAttr); return (T)field.GetValue(instance); } internal static void SetInstanceField<T>(this object instance, string fieldName, T value) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = instance.GetType().GetField(fieldName, bindingAttr); field.SetValue(instance, value); } }