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 AdvancedREPO API Stamina v1.0.1
BepInEx/patchers/AdvancedREPO.API.Stamina.Prepatcher.dll
Decompiled a year 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 AdvancedREPO.Patcher; using Microsoft.CodeAnalysis; using Mono.Cecil; [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: AssemblyCompany("AdvancedREPO.API.Stamina.Prepatcher")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Better stamina for REPO")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+91089561413fedaed7f28d429c4a3c83beb72026")] [assembly: AssemblyProduct("AdvancedREPO.API.Stamina.Prepatcher")] [assembly: AssemblyTitle("AdvancedREPO.API.Stamina.Prepatcher")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 AdvancedREPO.Stamina { public class Patcher : Patcher { public static IEnumerable<string> TargetDLLs => Patcher.TargetDLLs; public static void Patch(AssemblyDefinition assembly) { Patcher.Patch(assembly); } } } namespace AdvancedREPO.Stamina.Patches { public class PlayerController { private static FieldDefinition? IsJumpingField; [Patch("PlayerController")] public static void AddField(TypeDefinition type) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown Patcher.Log.LogInfo((object)"Adding IsJumping field to PlayerController..."); IsJumpingField = new FieldDefinition("IsJumping", (FieldAttributes)1, ((MemberReference)type).Module.TypeSystem.Boolean); type.Fields.Add(IsJumpingField); } } }
BepInEx/plugins/AdvancedREPO.API.Stamina.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AdvancedREPO.API.Patches; using AdvancedREPO.Utils; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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 = ".NET Standard 2.1")] [assembly: AssemblyCompany("AdvancedREPO.API.Stamina")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("API for better stamina for REPO")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+0094371ba253767c33d147da943ade3e91f03ccb")] [assembly: AssemblyProduct("AdvancedREPO.API.Stamina")] [assembly: AssemblyTitle("AdvancedREPO.API.Stamina")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 AdvancedREPO.API { [BepInPlugin("potatoepet.advancedrepo.api.stamina", "AdvancedREPO.API.Stamina", "1.0.0")] public class Stamina : BaseUnityPlugin { public static ManualLogSource? Log; private static Dictionary<string, bool> NoStaminaDrainDuringJumpValues = new Dictionary<string, bool>(); private static bool _NoStaminaDrainDuringJump = false; private static Dictionary<string, bool> NoSlowdownDuringJumpValues = new Dictionary<string, bool>(); private static bool _NoSlowdownDuringJump = false; private static Dictionary<string, bool> NoAccelerationDuringJumpValues = new Dictionary<string, bool>(); private static bool _NoAccelerationDuringJump = false; private static Dictionary<string, int> JumpStaminaCostValues = new Dictionary<string, int>(); private static int _JumpStaminaCost = 0; private static Dictionary<string, bool> JumpStaminaPreventValues = new Dictionary<string, bool>(); private static bool _JumpStaminaPrevent = false; private static Dictionary<string, float> StaminaSprintDrainRateValues = new Dictionary<string, float>(); private static float _StaminaSprintDrainRate = 1f; private static Dictionary<string, float> StaminaRechargeRateValues = new Dictionary<string, float>(); private static float _StaminaRechargeRate = 1f; private static Dictionary<string, float> StaminaStandingRechargeMultiplierValues = new Dictionary<string, float>(); private static float _StaminaStandingRechargeMultiplier = 1f; private static Dictionary<string, float> StaminaCrouchingRechargeMultiplierValues = new Dictionary<string, float>(); private static float _StaminaCrouchingRechargeMultiplier = 1f; private static Dictionary<string, int> StartingStaminaValues = new Dictionary<string, int>(); private static int _StartingStamina = 40; private static Dictionary<string, int> StaminaPerUpgradeValues = new Dictionary<string, int>(); private static int _StaminaPerUpgrade = 10; private static Dictionary<string, int> SlideStaminaCostValues = new Dictionary<string, int>(); private static int _SlideStaminaCost = 5; public static bool NoStaminaDrainDuringJump { get { return _NoStaminaDrainDuringJump; } internal set { _NoStaminaDrainDuringJump = value; } } public static bool NoSlowdownDuringJump { get { return _NoSlowdownDuringJump; } internal set { _NoSlowdownDuringJump = value; } } public static bool NoAccelerationDuringJump { get { return _NoAccelerationDuringJump; } internal set { _NoAccelerationDuringJump = value; } } public static int JumpStaminaCost { get { return _JumpStaminaCost; } internal set { _JumpStaminaCost = value; } } public static bool JumpStaminaPrevent { get { return _JumpStaminaPrevent; } internal set { _JumpStaminaPrevent = value; } } public static float StaminaSprintDrainRate { get { return _StaminaSprintDrainRate; } internal set { _StaminaSprintDrainRate = value; } } public static float StaminaRechargeRate { get { return _StaminaRechargeRate; } internal set { _StaminaRechargeRate = value; } } public static float StaminaStandingRechargeMultiplier { get { return _StaminaStandingRechargeMultiplier; } internal set { _StaminaStandingRechargeMultiplier = value; } } public static float StaminaCrouchingRechargeMultiplier { get { return _StaminaCrouchingRechargeMultiplier; } internal set { _StaminaCrouchingRechargeMultiplier = value; } } public static int StartingStamina { get { return _StartingStamina; } internal set { _StartingStamina = value; } } public static int StaminaPerUpgrade { get { return _StaminaPerUpgrade; } internal set { _StaminaPerUpgrade = value; } } public static int SlideStaminaCost { get { return _SlideStaminaCost; } internal set { _SlideStaminaCost = value; } } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Applying AdvancedREPO.API.Stamina..."); PlayerControllerPatches.ApplyPatches(); PunManagerPatches.ApplyPatches(); Log.LogInfo((object)"AdvancedREPO.API.Stamina applied!"); } public static void SetNoStaminaDrainDuringJump(bool? status, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (status.HasValue) { NoStaminaDrainDuringJumpValues[modName + key] = status.Value; NoStaminaDrainDuringJump = status.Value || NoStaminaDrainDuringJumpValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } else { NoStaminaDrainDuringJumpValues.Remove(modName + key); NoStaminaDrainDuringJump = NoStaminaDrainDuringJumpValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set no stamina drain during jump for key {key} to {status}. New value is {NoStaminaDrainDuringJump}"); } } public static void SetNoSlowdownDuringJump(bool? status, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (status.HasValue) { NoSlowdownDuringJumpValues[modName + key] = status.Value; NoSlowdownDuringJump = status.Value || NoSlowdownDuringJumpValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } else { NoSlowdownDuringJumpValues.Remove(modName + key); NoSlowdownDuringJump = NoSlowdownDuringJumpValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set no slowdown during jump for key {key} to {status}. New value is {NoSlowdownDuringJump}"); } } public static void SetNoAccelerationDuringJump(bool? status, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (status.HasValue) { NoAccelerationDuringJumpValues[modName + key] = status.Value; NoAccelerationDuringJump = status.Value || NoAccelerationDuringJumpValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } else { NoAccelerationDuringJumpValues.Remove(modName + key); NoAccelerationDuringJump = NoAccelerationDuringJumpValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set no acceleration during jump for key {key} to {status}. New value is {NoAccelerationDuringJump}"); } } public static void AddJumpStaminaCost(int? cost, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (cost.HasValue) { JumpStaminaCostValues[modName + key] = cost.Value; } else { JumpStaminaCostValues.Remove(modName + key); } JumpStaminaCost = JumpStaminaCostValues.Sum<KeyValuePair<string, int>>((KeyValuePair<string, int> x) => x.Value); ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set added jump stamina cost for key {key} to {cost}. New value is {JumpStaminaCost}"); } } public static void SetJumpStaminaPrevent(bool? status, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (status.HasValue) { JumpStaminaPreventValues[modName + key] = status.Value; JumpStaminaPrevent = status.Value || JumpStaminaPreventValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } else { JumpStaminaPreventValues.Remove(modName + key); JumpStaminaPrevent = JumpStaminaPreventValues.Any<KeyValuePair<string, bool>>((KeyValuePair<string, bool> x) => x.Value); } ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set jump stamina prevent for key {key} to {status}. New value is {JumpStaminaPrevent}"); } } public static void SetStaminaSprintDrainRate(float? value, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (value.HasValue) { StaminaSprintDrainRateValues[modName + key] = value.Value; } else { StaminaSprintDrainRateValues.Remove(modName + key); } float num = 1f; foreach (KeyValuePair<string, float> staminaSprintDrainRateValue in StaminaSprintDrainRateValues) { num *= staminaSprintDrainRateValue.Value; } StaminaSprintDrainRate = num; ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set stamina sprint drain rate for key {key} to {value}. New value is {StaminaSprintDrainRate}"); } } public static void SetStaminaRechargeRate(float? value, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (value.HasValue) { StaminaRechargeRateValues[modName + key] = value.Value; } else { StaminaRechargeRateValues.Remove(modName + key); } float num = 1f; foreach (KeyValuePair<string, float> staminaRechargeRateValue in StaminaRechargeRateValues) { num *= staminaRechargeRateValue.Value; } StaminaRechargeRate = num; ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set stamina recharge rate for key {key} to {value}. New value is {StaminaRechargeRate}"); } } public static void SetStandingStaminaRechargeMultiplier(float? value, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (value.HasValue) { StaminaStandingRechargeMultiplierValues[modName + key] = value.Value; } else { StaminaStandingRechargeMultiplierValues.Remove(modName + key); } float num = 1f; foreach (KeyValuePair<string, float> staminaStandingRechargeMultiplierValue in StaminaStandingRechargeMultiplierValues) { num *= staminaStandingRechargeMultiplierValue.Value; } StaminaStandingRechargeMultiplier = num; ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set standing stamina recharge multiplier for key {key} to {value}. New value is {StaminaStandingRechargeMultiplier}"); } } public static void SetCrouchingStaminaRechargeMultiplier(float? value, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (value.HasValue) { StaminaCrouchingRechargeMultiplierValues[modName + key] = value.Value; } else { StaminaCrouchingRechargeMultiplierValues.Remove(modName + key); } float num = 1f; foreach (KeyValuePair<string, float> staminaCrouchingRechargeMultiplierValue in StaminaCrouchingRechargeMultiplierValues) { num *= staminaCrouchingRechargeMultiplierValue.Value; } StaminaCrouchingRechargeMultiplier = num; ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set crouching stamina recharge multiplier for key {key} to {value}. New value is {StaminaCrouchingRechargeMultiplier}"); } } public static void AddStartStamina(int? value, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (value.HasValue) { StartingStaminaValues[modName + key] = value.Value; } else { StartingStaminaValues.Remove(modName + key); } StartingStamina = 40 + StartingStaminaValues.Sum<KeyValuePair<string, int>>((KeyValuePair<string, int> x) => x.Value); ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set added starting stamina for key {key} to {value}. New value is {StartingStamina}"); } } public static void AddStaminaPerUpgrade(int? value, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (value.HasValue) { StaminaPerUpgradeValues[modName + key] = value.Value; } else { StaminaPerUpgradeValues.Remove(modName + key); } StaminaPerUpgrade = 10 + StaminaPerUpgradeValues.Sum<KeyValuePair<string, int>>((KeyValuePair<string, int> x) => x.Value); ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set added stamina per upgrade for key {key} to {value}. New value is {StaminaPerUpgrade}"); } } public static void AddSlideStaminaCost(int? cost, string modName = null, string key = null) { if (modName == null) { modName = Assembly.GetCallingAssembly()?.GetName()?.Name ?? ""; } if (cost.HasValue) { SlideStaminaCostValues[modName + key] = cost.Value; } else { SlideStaminaCostValues.Remove(modName + key); } SlideStaminaCost = 5 + SlideStaminaCostValues.Sum<KeyValuePair<string, int>>((KeyValuePair<string, int> x) => x.Value); ManualLogSource? log = Log; if (log != null) { log.LogDebug((object)$"Mod {modName} set added slide stamina cost for key {key} to {cost}. New value is {SlideStaminaCost}"); } } public static float GetStaminaRechargeMultiplier(PlayerController playerController) { return StaminaRechargeRate * (playerController.moving ? 1f : StaminaStandingRechargeMultiplier) * (playerController.Crouching ? StaminaCrouchingRechargeMultiplier : 1f); } public static bool IsStaminaEnoughForSprint(PlayerController playerController) { return playerController.EnergyCurrent >= 1f || (NoSlowdownDuringJump && (PlayerControllerPatches.IsJumpingField?.GetValue(playerController) ?? false)); } public static float GetSprintLerpChange(PlayerController playerController) { float result; if (NoAccelerationDuringJump) { Field<PlayerController, bool>? isJumpingField = PlayerControllerPatches.IsJumpingField; if (isJumpingField != null && isJumpingField.GetValue(playerController)) { result = 0f; goto IL_002f; } } result = playerController.SprintAcceleration * Time.fixedDeltaTime; goto IL_002f; IL_002f: return result; } public static float GetStaminaDrainMultiplier(PlayerController playerController) { float result; if (NoStaminaDrainDuringJump) { Field<PlayerController, bool>? isJumpingField = PlayerControllerPatches.IsJumpingField; if (isJumpingField != null && isJumpingField.GetValue(playerController)) { result = 0f; goto IL_0028; } } result = StaminaSprintDrainRate; goto IL_0028; IL_0028: return result; } public static float GetStartStamina() { return StartingStamina; } public static float GetStaminaPerUpgrade() { return StaminaPerUpgrade; } public static float GetSlideStaminaCost() { return SlideStaminaCost; } } } namespace AdvancedREPO.API.Patches { public class PlayerControllerPatches { internal static Field<PlayerController, bool>? IsJumpingField; internal static Field<PlayerController, bool>? JumpImpulseField; internal static Field<PlayerCollisionGrounded, bool>? GroundedField; public static void ApplyPatches() { IsJumpingField = new Field<PlayerController, bool>((from e in typeof(PlayerController).GetFields(BindingFlags.Instance | BindingFlags.NonPublic) where e.Name == "IsJumping" select e).First()); JumpImpulseField = new Field<PlayerController, bool>((from e in typeof(PlayerController).GetFields(BindingFlags.Instance | BindingFlags.NonPublic) where e.Name == "JumpImpulse" select e).First()); GroundedField = new Field<PlayerCollisionGrounded, bool>((from e in typeof(PlayerCollisionGrounded).GetFields(BindingFlags.Instance | BindingFlags.NonPublic) where e.Name == "Grounded" select e).First()); ManualLogSource? log = Stamina.Log; if (log != null) { log.LogInfo((object)"Patching PlayerController..."); } Harmony.CreateAndPatchAll(typeof(PlayerControllerPatches), (string)null); ManualLogSource? log2 = Stamina.Log; if (log2 != null) { log2.LogInfo((object)"Patched PlayerController!"); } } public static void FixedUpdate(PlayerController playerController) { playerController.SprintSpeed = 5f; Field<PlayerCollisionGrounded, bool>? groundedField = GroundedField; if (groundedField != null && groundedField.GetValue(playerController.CollisionGrounded)) { IsJumpingField?.SetValue(playerController, false); } Field<PlayerController, bool>? jumpImpulseField = JumpImpulseField; if (jumpImpulseField == null || !jumpImpulseField.GetValue(playerController)) { return; } if (Stamina.JumpStaminaCost != 0) { if (!Stamina.JumpStaminaPrevent || playerController.EnergyCurrent >= (float)Stamina.JumpStaminaCost) { playerController.EnergyCurrent = Mathf.Min(playerController.EnergyStart, Mathf.Max(0f, playerController.EnergyCurrent - (float)Stamina.JumpStaminaCost)); } else if (Stamina.JumpStaminaPrevent) { JumpImpulseField?.SetValue(playerController, false); } } IsJumpingField?.SetValue(playerController, true); } [HarmonyPatch(typeof(PlayerController), "FixedUpdate")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> PatchFixedUpdate(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Expected O, but got Unknown //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Expected O, but got Unknown //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Expected O, but got Unknown //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Expected O, but got Unknown //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Expected O, but got Unknown //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Expected O, but got Unknown ManualLogSource? log = Stamina.Log; if (log != null) { log.LogMessage((object)"Patching PlayerController->FixedUpdate..."); } MethodInfo methodInfo = (from e in typeof(PlayerControllerPatches).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "FixedUpdate" select e).First(); MethodInfo methodInfo2 = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "IsStaminaEnoughForSprint" select e).First(); MethodInfo methodInfo3 = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "GetSprintLerpChange" select e).First(); MethodInfo methodInfo4 = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "GetStaminaDrainMultiplier" select e).First(); MethodInfo methodInfo5 = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "GetSlideStaminaCost" select e).First(); List<CodeInstruction> list = new List<CodeInstruction>(instructions); bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; bool flag5 = false; for (int i = 0; i < list.Count; i++) { if (!flag && list[i].opcode == OpCodes.Call && list[i].operand is MethodInfo methodInfo6 && methodInfo6.Name == "OverrideSpeedTick") { list.Insert(i - 2, new CodeInstruction(OpCodes.Call, (object)methodInfo)); list.Insert(i - 2, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); flag = true; } if (!flag2 && i < list.Count - 2 && list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo fieldInfo && fieldInfo.Name == "EnergyCurrent" && list[i + 2].opcode == OpCodes.Blt_Un) { list[i] = new CodeInstruction(OpCodes.Call, (object)methodInfo2); list.RemoveAt(i + 1); list[i + 1].opcode = OpCodes.Brfalse; flag2 = true; } if (!flag3 && i > 0 && list[i - 1].opcode == OpCodes.Add && list[i].opcode == OpCodes.Stfld && list[i].operand is FieldInfo fieldInfo2 && fieldInfo2.Name == "SprintSpeedLerp") { list.RemoveAt(i - 2); list.RemoveAt(i - 4); list.RemoveAt(i - 4); list.Insert(i - 4, new CodeInstruction(OpCodes.Call, (object)methodInfo3)); i -= 2; flag3 = true; } if (!flag4 && i < list.Count - 3 && list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo fieldInfo3 && fieldInfo3.Name == "EnergyCurrent" && list[i + 2].opcode == OpCodes.Call && list[i + 2].operand is MethodInfo methodInfo7 && methodInfo7.Name == "get_fixedDeltaTime" && list[i + 3].opcode == OpCodes.Mul) { list.Insert(i + 4, new CodeInstruction(OpCodes.Mul, (object)null)); list.Insert(i + 4, new CodeInstruction(OpCodes.Call, (object)methodInfo4)); list.Insert(i + 4, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); flag4 = true; } if (!flag5 && list[i].opcode == OpCodes.Ldc_R4 && list[i].operand is float num && num == 5f && list[i - 1].opcode == OpCodes.Ldfld && list[i - 1].operand is FieldInfo fieldInfo4 && fieldInfo4.Name == "EnergyCurrent") { list[i] = new CodeInstruction(OpCodes.Call, (object)methodInfo5); flag5 = true; } if (flag && flag2 && flag3 && flag4 && flag5) { break; } } int num2 = (flag ? 1 : 0) + (flag2 ? 1 : 0) + (flag3 ? 1 : 0) + (flag4 ? 1 : 0) + (flag5 ? 1 : 0); if (num2 == 5) { ManualLogSource? log2 = Stamina.Log; if (log2 != null) { log2.LogMessage((object)"Patched PlayerController->FixedUpdate!"); } } else { ManualLogSource? log3 = Stamina.Log; if (log3 != null) { log3.LogError((object)$"Failed to patch PlayerController->FixedUpdate! ({num2}/5 patches applied)"); } } return list.AsEnumerable(); } [HarmonyPatch(typeof(PlayerController), "Update")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> PatchUpdate(IEnumerable<CodeInstruction> instructions) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown ManualLogSource? log = Stamina.Log; if (log != null) { log.LogMessage((object)"Patching PlayerController->Update..."); } MethodInfo methodInfo = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "GetStaminaRechargeMultiplier" select e).First(); List<CodeInstruction> list = new List<CodeInstruction>(instructions); bool flag = false; for (int i = 0; i < list.Count - 3; i++) { if (list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo fieldInfo && fieldInfo.Name == "EnergyCurrent" && list[i + 1].opcode == OpCodes.Ldloc_0 && list[i + 3].opcode == OpCodes.Mul) { list.Insert(i + 3, new CodeInstruction(OpCodes.Mul, (object)null)); list.Insert(i + 3, new CodeInstruction(OpCodes.Call, (object)methodInfo)); list.Insert(i + 3, new CodeInstruction(OpCodes.Ldarg_0, (object)methodInfo)); flag = true; break; } } if (flag) { ManualLogSource? log2 = Stamina.Log; if (log2 != null) { log2.LogMessage((object)"Patched PlayerController->Update!"); } } else { ManualLogSource? log3 = Stamina.Log; if (log3 != null) { log3.LogError((object)"Failed to patch PlayerController->Update!"); } } return list.AsEnumerable(); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> PatchLateStart(IEnumerable<CodeInstruction> instructions) { //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown ManualLogSource? log = Stamina.Log; if (log != null) { log.LogMessage((object)"Patching PlayerController->LateStart..."); } FieldInfo fieldInfo = (from e in typeof(PlayerController).GetFields(BindingFlags.Instance | BindingFlags.Public) where e.Name == "EnergyStart" select e).First(); MethodInfo methodInfo = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "GetStaminaPerUpgrade" select e).First(); MethodInfo methodInfo2 = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "GetStartStamina" select e).First(); List<CodeInstruction> list = new List<CodeInstruction>(instructions); bool flag = false; bool flag2 = false; for (int i = 0; i < list.Count; i++) { if (!flag && i < list.Count - 1 && list[i].opcode == OpCodes.Ldsfld && list[i].operand is FieldInfo fieldInfo2 && fieldInfo2.Name == "instance" && list[i + 1].opcode == OpCodes.Ldfld && list[i + 1].operand is FieldInfo fieldInfo3 && fieldInfo3.Name == "playerUpgradeStamina") { list.Insert(i, new CodeInstruction(OpCodes.Stfld, (object)fieldInfo)); list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); list.Insert(i, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); flag = true; } if (!flag2 && i < list.Count - 1 && list[i].opcode == OpCodes.Ldc_R4 && list[i].operand is float num && num == 10f && list[i + 1].opcode == OpCodes.Mul) { list.RemoveAt(i); list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); flag2 = true; } if (flag && flag2) { break; } } int num2 = (flag ? 1 : 0) + (flag2 ? 1 : 0); if (num2 == 2) { ManualLogSource? log2 = Stamina.Log; if (log2 != null) { log2.LogMessage((object)"Patched PlayerController->LateStart!"); } } else { ManualLogSource? log3 = Stamina.Log; if (log3 != null) { log3.LogError((object)$"Failed to patch PlayerController->LateStart! ({num2}/3 patches applied)"); } } return list.AsEnumerable(); } } public class PunManagerPatches { public static void ApplyPatches() { ManualLogSource? log = Stamina.Log; if (log != null) { log.LogInfo((object)"Patching PunManager..."); } Harmony.CreateAndPatchAll(typeof(PunManagerPatches), (string)null); ManualLogSource? log2 = Stamina.Log; if (log2 != null) { log2.LogInfo((object)"Patched PunManager!"); } } [HarmonyPatch(typeof(PunManager), "UpdateEnergyRightAway")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> PatchUpdateEnergyRightAway(IEnumerable<CodeInstruction> instructions) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown ManualLogSource? log = Stamina.Log; if (log != null) { log.LogMessage((object)"Patching PunManager->UpdateEnergyRightAway..."); } MethodInfo methodInfo = (from e in typeof(Stamina).GetMethods(BindingFlags.Static | BindingFlags.Public) where e.Name == "GetStaminaPerUpgrade" select e).First(); List<CodeInstruction> list = new List<CodeInstruction>(instructions); bool flag = false; for (int i = 0; i < list.Count - 3; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && list[i].operand is float num && num == 10f) { list.RemoveAt(i); list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); flag = true; break; } } if (flag) { ManualLogSource? log2 = Stamina.Log; if (log2 != null) { log2.LogMessage((object)"Patched PunManager->UpdateEnergyRightAway!"); } } else { ManualLogSource? log3 = Stamina.Log; if (log3 != null) { log3.LogError((object)"Failed to patch PunManager->UpdateEnergyRightAway!"); } } return list.AsEnumerable(); } } }