using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AutoSprint.Core;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Croco;
using EntityStates.FalseSon;
using EntityStates.Railgunner.Scope;
using EntityStates.Toolbot;
using EntityStates.VoidSurvivor.Weapon;
using HG.Reflection;
using HarmonyLib;
using IL.RoR2;
using IL.RoR2.CameraModes;
using IL.RoR2.UI;
using Microsoft.CodeAnalysis;
using MiscFixes.Modules;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates;
using On.RoR2;
using Rewired;
using RiskOfOptions;
using RoR2;
using RoR2.CameraModes;
using RoR2.Skills;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AutoSprint")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d1277c539b940d15dfb20938851ab9cf810f07a0")]
[assembly: AssemblyProduct("AutoSprint")]
[assembly: AssemblyTitle("AutoSprint")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[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 AutoSprint
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.score.AutoSprint", "AutoSprint", "1.4.8")]
public class AutoSprintPlugin : BaseUnityPlugin
{
public const string PluginGUID = "com.score.AutoSprint";
public const string PluginAuthor = "score";
public const string PluginName = "AutoSprint";
public const string PluginVersion = "1.4.8";
internal static bool RooInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
public static AutoSprintPlugin Instance { get; private set; }
internal string DirectoryName => Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
public void Awake()
{
Instance = this;
Log.Init(((BaseUnityPlugin)this).Logger);
PluginConfig.Init(((BaseUnityPlugin)this).Config);
Hooks.Init();
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(string data)
{
if (PluginConfig.EnableDebugMode.Value)
{
_logSource.LogDebug((object)data);
}
}
internal static void Info(string data)
{
if (PluginConfig.EnableDebugMode.Value)
{
_logSource.LogInfo((object)data);
}
}
internal static void Message(string data)
{
_logSource.LogMessage((object)data);
}
internal static void Warning(string data)
{
_logSource.LogWarning((object)data);
}
internal static void Error(string data)
{
_logSource.LogError((object)data);
}
internal static void Fatal(string data)
{
_logSource.LogFatal((object)data);
}
}
internal static class PluginConfig
{
public static ConfigEntry<bool> HoldSprintToWalk { get; set; }
public static ConfigEntry<bool> DisableSprintingCrosshair { get; set; }
public static ConfigEntry<bool> DisableSprintingSpeedLines { get; set; }
public static ConfigEntry<int> FovSlider { get; set; }
public static ConfigEntry<bool> DisableSprintingFOV { get; set; }
public static ConfigEntry<bool> ForceSprintingFOV { get; set; }
public static ConfigEntry<bool> EnableOmniSprint { get; set; }
public static ConfigEntry<bool> EnableDebugMode { get; set; }
public static ConfigEntry<int> BaseDelayTicks { get; set; }
public static ConfigEntry<int> DelayTicks { get; set; }
public static ConfigEntry<string> DisabledBodies { get; set; }
public static ConfigEntry<string> DisableSprintingCustomList { get; set; }
public static ConfigEntry<string> DisableSprintingCustomList2 { get; set; }
public static void Init(ConfigFile cfg)
{
if (AutoSprintPlugin.RooInstalled)
{
InitRoO();
}
HoldSprintToWalk = Extensions.BindOption<bool>(cfg, "General", "Hold Sprint To Walk", "Walk by holding down the sprint key. If disabled, makes the Sprint key toggle AutoSprinting functionality on and off.", true, (ConfigFlags)2);
DisableSprintingCrosshair = Extensions.BindOption<bool>(cfg, "General", "Disable Sprinting Crosshair", "Disables the special sprinting chevron crosshair.", true, (ConfigFlags)2);
DisableSprintingSpeedLines = Extensions.BindOption<bool>(cfg, "General", "Disable Sprinting Speed Lines", "Disables the speed lines on the edges of the screen when sprinting.", false, (ConfigFlags)2);
FovSlider = Extensions.BindOptionSlider<int>(cfg, "General", "Global FOV Increase", "Adds the configured value to all fov calculations. Set to 0 to disable.", 0, 0, 60, (ConfigFlags)2);
ForceSprintingFOV = Extensions.BindOption<bool>(cfg, "General", "Force Sprinting FOV", "Changes the FOV to be constantly set to the 1.3x multiplier. This overrides the \"Disable Sprinting FOV Increase\" setting. Disable both for vanilla behavior.", true, (ConfigFlags)2);
DisableSprintingFOV = Extensions.BindOption<bool>(cfg, "General", "Disable Sprinting FOV Increase", "Disables the change in FOV when sprinting. This setting requires the \"Force Sprinting FOV\" to be disabled for it to have any effect. Disable both for vanilla behavior.", false, (ConfigFlags)2);
EnableOmniSprint = Extensions.BindOption<bool>(cfg, "General", "Enable OmniSprint", "Allows sprinting in all directions. This is generally considered cheating, use with discretion.", false, (ConfigFlags)2);
EnableDebugMode = Extensions.BindOption<bool>(cfg, "Advanced", "Enable Debug Mode", "Prints every entity state that your character changes to.", false, (ConfigFlags)2);
BaseDelayTicks = Extensions.BindOptionSlider<int>(cfg, "Advanced", "Base Delay", "How long to wait, in game ticks, before sprinting. Game runs at 60hz, so 1 tick == 16ms", 5, 0, 60, (ConfigFlags)2);
DelayTicks = Extensions.BindOptionSlider<int>(cfg, "Advanced", "Skill Activation Delay", "How long to wait, in game ticks, before sprinting after beginning certain skills. Game runs at 60hz, so 1 tick == 16ms", 20, 0, 60, (ConfigFlags)2);
DisabledBodies = Extensions.BindOption<string>(cfg, "Advanced", "Disable Body", "Custom body name list, has to match body catalog name.", "", (ConfigFlags)2);
DisableSprintingCustomList = Extensions.BindOption<string>(cfg, "Advanced", "Disable Sprint Custom List", "Custom EntityState list for when a skill is cancelled by sprinting when it shouldn't, separated by commas.\r\nThe Debug Mode cfg option will print the state names to the Bepinex console/log output.\r\n\r\nExample: EntityStates.Toolbot.ToolbotDualWield", "", (ConfigFlags)2);
DisableSprintingCustomList2 = Extensions.BindOption<string>(cfg, "Advanced", "Disable Sprint With Duration List", "(typeFullName, fieldName) --or-- (typeFullName, ###)\r\n\r\nExample: (EntityStates.Toolbot.ToolbotDualWieldStart, baseDuration)\r\n --or-- (EntityStates.Toolbot.ToolbotDualWieldStart, 0.75)", "", (ConfigFlags)2);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void InitRoO()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
try
{
ModSettingsManager.SetModDescription("AutoSprint, as God intended.", "com.score.AutoSprint", "AutoSprint");
byte[] array = File.ReadAllBytes(Path.Combine(AutoSprintPlugin.Instance.DirectoryName, "icon.png"));
Texture2D val = new Texture2D(256, 256);
ImageConversion.LoadImage(val, array);
ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f)));
}
catch (Exception ex)
{
Log.Debug(ex.ToString());
}
}
}
}
namespace AutoSprint.Core
{
public static class AutoSprintManager
{
private static CharacterBody _cachedBody;
private static EntityStateMachine[] _cachedStateMachines;
private static float _delayTimer;
private static bool _enableSprintOverride = true;
public static float AnimationExitDelay => (float)PluginConfig.DelayTicks.Value * Time.fixedDeltaTime;
public static float BaseExitDelay => (float)PluginConfig.BaseDelayTicks.Value * Time.fixedDeltaTime;
public static CharacterBody CachedBody => _cachedBody;
public static void TryHandleSprint(PlayerCharacterMasterController pcmc, Player inputPlayer, bool isSprinting)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if (StateManager.DisabledBodies.Contains(pcmc.body.bodyIndex))
{
return;
}
if (PluginConfig.HoldSprintToWalk.Value)
{
_enableSprintOverride = !inputPlayer.GetButton("Sprint");
}
else if (pcmc.sprintInputPressReceived)
{
_enableSprintOverride = !_enableSprintOverride;
}
if (!_enableSprintOverride || isSprinting || pcmc.bodyInputs.moveVector == Vector3.zero)
{
_delayTimer = BaseExitDelay;
return;
}
if (!CanSprintBeEnabled(pcmc.body, out var activeDelayTimer))
{
_delayTimer = activeDelayTimer;
}
if (_delayTimer > 0f)
{
_delayTimer -= Time.fixedDeltaTime;
}
else
{
pcmc.sprintInputPressReceived = true;
}
}
private static bool CanSprintBeEnabled(CharacterBody targetBody, out float activeDelayTimer)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
activeDelayTimer = 0f;
if ((Object)(object)targetBody != (Object)(object)_cachedBody)
{
Log.Info(BodyCatalog.GetBodyName(targetBody.bodyIndex));
_cachedBody = targetBody;
_cachedStateMachines = ((Component)targetBody).GetComponents<EntityStateMachine>();
}
for (int i = 0; i < _cachedStateMachines.Length; i++)
{
EntityStateMachine val = _cachedStateMachines[i];
if (((val != null) ? val.state : null) != null)
{
EntityStateIndex stateIndex = EntityStateCatalog.GetStateIndex(((object)val.state).GetType());
if (StateManager.EntityStateDisabledSet.Contains(stateIndex))
{
activeDelayTimer = Mathf.Max(activeDelayTimer, BaseExitDelay);
}
if (StateManager.SprintStateDelayTable.ContainsKey(stateIndex))
{
activeDelayTimer = Mathf.Max(activeDelayTimer, GetDurationRemaining(val.state, stateIndex));
}
}
}
return activeDelayTimer == 0f;
}
private static float GetDurationRemaining(EntityState state, EntityStateIndex stateIndex)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (StateManager.SprintStateDelayTable[stateIndex] is float num)
{
return AnimationExitDelay + (num - state.fixedAge);
}
if (StateManager.SprintStateDelayTable[stateIndex] is FieldInfo fieldInfo && fieldInfo.FieldType == typeof(float) && fieldInfo.DeclaringType.IsAssignableFrom(((object)state).GetType()))
{
return AnimationExitDelay + ((float)fieldInfo.GetValue(state) - state.fixedAge);
}
Log.Error($"Field for {((object)state).GetType().FullName} is invalid, default is delay is {AnimationExitDelay}.");
return AnimationExitDelay - state.fixedAge;
}
}
internal class Hooks
{
[CompilerGenerated]
private static class <>O
{
public static hook_Init <0>__EntityStateCatalog_Init;
public static Manipulator <1>__PlayerCharacterMasterController_PollButtonInput;
public static Manipulator <2>__CrosshairManager_UpdateCrosshair;
public static Manipulator <3>__CameraModePlayerBasic_UpdateInternal;
public static Manipulator <4>__CameraModePlayerBasic_UpdateInternal2;
public static hook_SetParticleSystemActive <5>__CameraRigController_SetParticleSystemActive;
public static hook_SetSprintParticlesActive <6>__CameraRigController_SetSprintParticlesActive;
public static hook_OnEnter <7>__EntityState_OnEnter;
public static EventHandler <8>__UpdateDisabledStates;
public static EventHandler <9>__UpdateDelayStates;
public static Action<PlayerCharacterMasterController, Player, bool> <10>__TryHandleSprint;
}
private bool _hooksEnabled;
public static Hooks Instance { get; private set; }
public static void Init()
{
if (Instance == null)
{
Instance = new Hooks();
}
}
private Hooks()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//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_005f: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
EnableDebugMode_SettingChanged(null, null);
PluginConfig.EnableDebugMode.SettingChanged += EnableDebugMode_SettingChanged;
object obj = <>O.<0>__EntityStateCatalog_Init;
if (obj == null)
{
hook_Init val = EntityStateCatalog_Init;
<>O.<0>__EntityStateCatalog_Init = val;
obj = (object)val;
}
EntityStateCatalog.Init += (hook_Init)obj;
object obj2 = <>O.<1>__PlayerCharacterMasterController_PollButtonInput;
if (obj2 == null)
{
Manipulator val2 = PlayerCharacterMasterController_PollButtonInput;
<>O.<1>__PlayerCharacterMasterController_PollButtonInput = val2;
obj2 = (object)val2;
}
PlayerCharacterMasterController.PollButtonInput += (Manipulator)obj2;
object obj3 = <>O.<2>__CrosshairManager_UpdateCrosshair;
if (obj3 == null)
{
Manipulator val3 = CrosshairManager_UpdateCrosshair;
<>O.<2>__CrosshairManager_UpdateCrosshair = val3;
obj3 = (object)val3;
}
CrosshairManager.UpdateCrosshair += (Manipulator)obj3;
object obj4 = <>O.<3>__CameraModePlayerBasic_UpdateInternal;
if (obj4 == null)
{
Manipulator val4 = CameraModePlayerBasic_UpdateInternal;
<>O.<3>__CameraModePlayerBasic_UpdateInternal = val4;
obj4 = (object)val4;
}
CameraModePlayerBasic.UpdateInternal += (Manipulator)obj4;
object obj5 = <>O.<4>__CameraModePlayerBasic_UpdateInternal2;
if (obj5 == null)
{
Manipulator val5 = CameraModePlayerBasic_UpdateInternal2;
<>O.<4>__CameraModePlayerBasic_UpdateInternal2 = val5;
obj5 = (object)val5;
}
CameraModePlayerBasic.UpdateInternal += (Manipulator)obj5;
object obj6 = <>O.<5>__CameraRigController_SetParticleSystemActive;
if (obj6 == null)
{
hook_SetParticleSystemActive val6 = CameraRigController_SetParticleSystemActive;
<>O.<5>__CameraRigController_SetParticleSystemActive = val6;
obj6 = (object)val6;
}
CameraRigController.SetParticleSystemActive += (hook_SetParticleSystemActive)obj6;
object obj7 = <>O.<6>__CameraRigController_SetSprintParticlesActive;
if (obj7 == null)
{
hook_SetSprintParticlesActive val7 = CameraRigController_SetSprintParticlesActive;
<>O.<6>__CameraRigController_SetSprintParticlesActive = val7;
obj7 = (object)val7;
}
CameraRigController.SetSprintParticlesActive += (hook_SetSprintParticlesActive)obj7;
}
private static void CameraRigController_SetSprintParticlesActive(orig_SetSprintParticlesActive orig, CameraRigController self, bool newSprintParticlesActive)
{
newSprintParticlesActive &= !PluginConfig.DisableSprintingSpeedLines.Value;
orig.Invoke(self, newSprintParticlesActive);
}
private static void CameraRigController_SetParticleSystemActive(orig_SetParticleSystemActive orig, CameraRigController self, bool newParticlesActive, ParticleSystem particleSystem)
{
if ((Object)(object)particleSystem == (Object)(object)self.sprintingParticleSystem)
{
newParticlesActive &= !PluginConfig.DisableSprintingSpeedLines.Value;
}
orig.Invoke(self, newParticlesActive, particleSystem);
}
private void EnableDebugMode_SettingChanged(object sender, EventArgs e)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
if (_hooksEnabled == PluginConfig.EnableDebugMode.Value)
{
return;
}
_hooksEnabled = PluginConfig.EnableDebugMode.Value;
if (_hooksEnabled)
{
object obj = <>O.<7>__EntityState_OnEnter;
if (obj == null)
{
hook_OnEnter val = EntityState_OnEnter;
<>O.<7>__EntityState_OnEnter = val;
obj = (object)val;
}
EntityState.OnEnter += (hook_OnEnter)obj;
}
else
{
object obj2 = <>O.<7>__EntityState_OnEnter;
if (obj2 == null)
{
hook_OnEnter val2 = EntityState_OnEnter;
<>O.<7>__EntityState_OnEnter = val2;
obj2 = (object)val2;
}
EntityState.OnEnter -= (hook_OnEnter)obj2;
}
}
private static void EntityState_OnEnter(orig_OnEnter orig, EntityState self)
{
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)self.characterBody) && (Object)(object)self.characterBody == (Object)(object)AutoSprintManager.CachedBody)
{
Log.Info(((object)self).GetType().FullName);
}
}
private static IEnumerator EntityStateCatalog_Init(orig_Init orig)
{
yield return orig.Invoke();
for (int i = 0; i < EntityStateCatalog.stateIndexToType.Length; i++)
{
StateManager.TypeFullNameToStateIndex[EntityStateCatalog.stateIndexToType[i].FullName] = (EntityStateIndex)i;
}
yield return null;
StateManager.UpdateDisabledStates(null, null);
StateManager.UpdateDelayStates(null, null);
PluginConfig.DisableSprintingCustomList.SettingChanged += StateManager.UpdateDisabledStates;
PluginConfig.DisableSprintingCustomList2.SettingChanged += StateManager.UpdateDelayStates;
}
private static void CameraModePlayerBasic_UpdateInternal2(ILContext il)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
ILCursor[] array = null;
if (!new ILCursor(il).TryFindNext(ref array, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraInfo>(x, "baseFov"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CameraRigController>(x, "baseFov")
}))
{
Log.Error("AutoSprint IL hook for CameraModePlayerBasic_UpdateInternal Custom FOV failed");
return;
}
ILCursor obj = array[0];
int index = obj.Index;
obj.Index = index + 1;
array[0].EmitDelegate<Func<float, float>>((Func<float, float>)((float fov) => fov + (float)PluginConfig.FovSlider.Value));
ILCursor obj2 = array[1];
index = obj2.Index;
obj2.Index = index + 1;
array[1].EmitDelegate<Func<float, float>>((Func<float, float>)((float fov) => fov + (float)PluginConfig.FovSlider.Value));
}
private static void CameraModePlayerBasic_UpdateInternal(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
ILCursor[] array = null;
ILLabel noFovLabel = null;
int num = default(int);
if (val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num),
(Instruction x) => ILPatternMatchingExt.MatchLdflda<CameraModeContext>(x, "targetInfo"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<TargetInfo>(x, "isSprinting")
}) && val.TryFindNext(ref array, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref noFovLabel)
}))
{
ILCursor obj = array[0];
int index = obj.Index;
obj.Index = index + 1;
ILLabel val2 = array[0].MarkLabel();
val.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(PluginConfig), "ForceSprintingFOV"));
val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(ConfigEntry<bool>), "Value"));
val.Emit(OpCodes.Brtrue, (object)val2);
val.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(PluginConfig), "DisableSprintingFOV"));
val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(ConfigEntry<bool>), "Value"));
val.Emit(OpCodes.Brtrue, (object)noFovLabel);
}
else
{
Log.Error("AutoSprint IL hook for CameraModePlayerBasic_UpdateInternal Sprinting FOV failed");
}
}
private static void PlayerCharacterMasterController_PollButtonInput(ILContext il)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
ILCursor c = new ILCursor(il);
int playerLoc = 0;
int isSprintingLoc = 0;
int num = default(int);
if (c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(PlayerCharacterMasterController), "networkUser")),
(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref num),
(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref playerLoc)
}) && c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerCharacterMasterController>(x, "body"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "isSprinting"))
}) && c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref isSprintingLoc)
}))
{
c.Emit(OpCodes.Ldarg_0);
c.Emit(OpCodes.Ldloc, playerLoc);
c.Emit(OpCodes.Ldloc, isSprintingLoc);
c.EmitDelegate<Action<PlayerCharacterMasterController, Player, bool>>((Action<PlayerCharacterMasterController, Player, bool>)AutoSprintManager.TryHandleSprint);
}
else
{
Log.Error("AutoSprint IL hook for PlayerCharacterMasterController_PollButtonInput failed");
}
ILLabel label = null;
ILCursor[] array = default(ILCursor[]);
if (c.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerCharacterMasterController>(x, "body"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<CharacterBody>(x, "bodyFlags") && c.TryFindNext(ref array, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref label)
})
}))
{
c.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(PluginConfig), "EnableOmniSprint"));
c.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(ConfigEntry<bool>), "Value"));
c.Emit(OpCodes.Brtrue, (object)label);
}
else
{
Log.Error("AutoSprint IL hook for PlayerCharacterMasterController_PollButtonInput - Enable Omni Sprint failed");
}
}
private static void CrosshairManager_UpdateCrosshair(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
ILCursor val2 = new ILCursor(il);
if (val2.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "isSprinting"))
}))
{
val2.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)((bool val) => val && !PluginConfig.DisableSprintingCrosshair.Value));
}
else
{
Log.Error("AutoSprint IL hook for CrosshairManager_UpdateCrosshair failed");
}
}
}
public static class StateManager
{
public static readonly Dictionary<string, string> SprintDelayTypeNameValuePairs = new Dictionary<string, string>();
public static readonly Hashtable SprintStateDelayTable = new Hashtable();
public static readonly HashSet<string> SprintDisabledTypeNames = new HashSet<string>();
public static readonly HashSet<EntityStateIndex> EntityStateDisabledSet = new HashSet<EntityStateIndex>();
public static readonly HashSet<BodyIndex> DisabledBodies = new HashSet<BodyIndex>();
public static readonly Dictionary<string, EntityStateIndex> TypeFullNameToStateIndex = new Dictionary<string, EntityStateIndex>();
[SystemInitializer(new Type[] { typeof(SkillCatalog) })]
internal static void UpdateFromSkillCatalog()
{
foreach (SkillDef allSkillDef in SkillCatalog.allSkillDefs)
{
if (!Object.op_Implicit((Object)(object)allSkillDef) || allSkillDef.forceSprintDuringState)
{
continue;
}
if (allSkillDef.canceledFromSprinting)
{
Type stateType = ((SerializableEntityStateType)(ref allSkillDef.activationState)).stateType;
if (!string.IsNullOrEmpty(stateType?.FullName) && !typeof(Idle).IsAssignableFrom(stateType))
{
SprintDisabledTypeNames.Add(stateType.FullName);
}
}
else if (allSkillDef.cancelSprintingOnActivation)
{
Type stateType2 = ((SerializableEntityStateType)(ref allSkillDef.activationState)).stateType;
if (!string.IsNullOrEmpty(stateType2?.FullName) && !typeof(Idle).IsAssignableFrom(stateType2))
{
SprintDelayTypeNameValuePairs[stateType2.FullName] = "0";
}
}
}
SprintDisabledTypeNames.Add(typeof(FireNailgun).FullName);
SprintDisabledTypeNames.Add(typeof(ToolbotDualWieldBase).FullName);
SprintDisabledTypeNames.Add(typeof(FireCorruptHandBeam).FullName);
SprintDisabledTypeNames.Add(typeof(ActiveScopeHeavy).FullName);
SprintDisabledTypeNames.Add(typeof(ActiveScopeLight).FullName);
SprintDisabledTypeNames.Add(typeof(WindUpScopeHeavy).FullName);
SprintDisabledTypeNames.Add(typeof(WindUpScopeLight).FullName);
SprintDisabledTypeNames.Remove(typeof(LaserFather).FullName);
SprintDisabledTypeNames.Remove(typeof(Slash).FullName);
SprintDisabledTypeNames.Remove(typeof(Bite).FullName);
SprintDelayTypeNameValuePairs[typeof(ToolbotDualWieldStart).FullName] = "baseDuration";
SprintDelayTypeNameValuePairs[typeof(Slash).FullName] = "durationBeforeInterruptable";
SprintDelayTypeNameValuePairs[typeof(Bite).FullName] = "durationBeforeInterruptable";
}
[SystemInitializer(new Type[] { typeof(BodyCatalog) })]
internal static void UpdateFromBodyCatalog()
{
UpdateDisabledBodies(null, null);
PluginConfig.DisableSprintingCustomList.SettingChanged += UpdateDisabledBodies;
}
internal static void UpdateDisabledBodies(object _, EventArgs __)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Invalid comparison between Unknown and I4
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
DisabledBodies.Clear();
List<string> list = new List<string>(3) { "JohnnyBody", "PantheraBody", "RA2ChronoBody" };
string[] array = PluginConfig.DisabledBodies.Value.Replace(" ", string.Empty).Split(',');
foreach (string text in array)
{
if (!string.IsNullOrEmpty(text))
{
list.Add(text);
}
}
foreach (string item in list)
{
BodyIndex val = BodyCatalog.FindBodyIndex(item);
if ((int)val != -1)
{
DisabledBodies.Add(val);
Log.Message(item + " added to the disabled bodies list.");
}
else
{
Log.Warning(item + " is not a valid body, skipping...");
}
}
}
internal static void UpdateDisabledStates(object _, EventArgs __)
{
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
EntityStateDisabledSet.Clear();
HashSet<string> sprintDisabledTypeNames = SprintDisabledTypeNames;
List<string> list = new List<string>(15 + sprintDisabledTypeNames.Count);
list.AddRange(sprintDisabledTypeNames);
list.Add("LeeHyperrealMod.SkillStates.LeeHyperreal.Secondary.EnterSnipe");
list.Add("LeeHyperrealMod.SkillStates.LeeHyperreal.Secondary.Snipe");
list.Add("LeeHyperrealMod.SkillStates.LeeHyperreal.Secondary.IdleSnipe");
list.Add("LeeHyperrealMod.SkillStates.LeeHyperreal.Secondary.ExitSnipe");
list.Add("PaladinMod.States.Spell.ChannelCruelSun");
list.Add("PaladinMod.States.Spell.ChannelHealZone");
list.Add("PaladinMod.States.Spell.ChannelSmallHeal");
list.Add("PaladinMod.States.Spell.ChannelTorpor");
list.Add("PaladinMod.States.Spell.ChannelWarcry");
list.Add("PaladinMod.States.Spell.CastCruelSun");
list.Add("PaladinMod.States.Spell.CastChanneledWarcry");
list.Add("PaladinMod.States.Spell.CastChanneledTorpor");
list.Add("PaladinMod.States.Spell.CastChanneledHealZone");
list.Add("DanteMod.SkillStates.Dante.LockOn");
list.Add("DanteMod.SkillStates.Dante.Swap");
List<string> list2 = list;
string[] array = PluginConfig.DisableSprintingCustomList.Value.Replace(" ", string.Empty).Split(',');
foreach (string text in array)
{
if (!string.IsNullOrWhiteSpace(text))
{
list2.Add(text);
}
}
foreach (string item in list2)
{
if (TypeFullNameToStateIndex.TryGetValue(item, out var value))
{
EntityStateDisabledSet.Add(value);
Log.Info(item + " added to the custom entity state list.");
}
else
{
Log.Warning(item + " is not a valid entity state, skipping...");
}
}
}
internal static void UpdateDelayStates(object _, EventArgs __)
{
SprintStateDelayTable.Clear();
foreach (KeyValuePair<string, string> sprintDelayTypeNameValuePair in SprintDelayTypeNameValuePairs)
{
AddSprintDelay(sprintDelayTypeNameValuePair.Key, sprintDelayTypeNameValuePair.Value);
}
string[] array = PluginConfig.DisableSprintingCustomList2.Value.Replace(" ", string.Empty).Split(')');
foreach (string text in array)
{
if (!string.IsNullOrEmpty(text))
{
string[] array2 = text.Split(',');
if (array2.Length != 2)
{
Log.Warning(text + " is not in the valid (key, value) pair format, skipping...");
}
else
{
AddSprintDelay(array2[0].Replace("(", string.Empty), array2[1]);
}
}
}
}
public static void AddSprintDelay(string typeFullName, string value)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
if (value == null)
{
value = string.Empty;
}
if (!TypeFullNameToStateIndex.TryGetValue(typeFullName, out var value2))
{
Log.Error("Type: " + typeFullName + " | Field: " + value + " | The type does not exist in the EntityStateCatalog.");
return;
}
Type stateType = EntityStateCatalog.GetStateType(value2);
if ((object)stateType == null)
{
Log.Error("Type: " + typeFullName + " | Field: " + value + " | The state exists in the EntityStateCatalog but the type is null.");
return;
}
value = value.Replace(" ", string.Empty);
if (string.IsNullOrEmpty(value))
{
value = "0";
}
if (float.TryParse(value, out var result))
{
Log.Info($"Type: {stateType.FullName} | Value: {result} | Has been added to the custom entity state list.");
SprintStateDelayTable[value2] = result;
}
else
{
AddFieldInfo(stateType, value2, value);
}
}
public static void AddFieldInfo(Type T, EntityStateIndex index, string name)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
FieldInfo fieldInfo = AccessTools.DeclaredField(T, name);
if ((object)fieldInfo == null)
{
Log.Error("\r\nField with that name could not be found and wasnt able to parse the value as numeric. Type not added.\r\n" + T.FullName + " : " + (name ?? "NULL"));
return;
}
if (fieldInfo.FieldType != typeof(float))
{
Log.Error("\r\nField must be a float, but the field does exist. Type not added.\r\n" + T.FullName + " : " + fieldInfo.Name);
return;
}
if (SprintStateDelayTable.ContainsKey(index))
{
Log.Warning("\r\nOverwriting duplicate entry\r\n" + T.FullName + " : " + fieldInfo.Name + "\r\nold " + (SprintStateDelayTable[index]?.ToString() ?? "NULL") + " | new " + fieldInfo.Name);
}
else
{
Log.Info("Type: " + T.FullName + " | Field: " + name + " | Has been added to the custom entity state list.");
}
SprintStateDelayTable[index] = fieldInfo;
}
}
}