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 MinerSpeedFlips v1.2.0
MinerSpeedFlips.dll
Decompiled 4 days agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using HarmonyLib; using RoR2; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace MinerSpeedFlips; [BepInPlugin("binma.minerspeedflips", "Miner Speed Flips", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "binma.minerspeedflips"; internal static ConfigEntry<float> Threshold; internal static ConfigEntry<int> GoldRushThreshold; internal static ManualLogSource Log; internal static ConfigEntry<float> RefreshThreshold; private void Awake() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Threshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Flip Speed Threshold v2", 20f, "Miner only backflips when jumping with at least this much movement speed (m/s). Below it he jumps normally. For reference, Miner's base sprint speed is around 10. Gold Rush's speed bonus counts toward this."); GoldRushThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Gold Rush Stack Threshold v5", 2, "Miner also backflips when he has at least this many Gold Rush stacks, regardless of speed. 2 = he needs 2 stacks to start flipping. Set to 0 to disable."); RefreshThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Gold Rush", "Gold needed to refresh Gold Rush", 0.25f, "Gold Rush resets the timer on all its stacks whenever you gain gold. A gold gain now has to be worth at least this fraction of one Gold Rush stack to do that. 0.25 means tiny trickles (one Life Savings, a few pennies) don't keep it up on their own, but stacking more of them still does. 0 = vanilla behaviour. Small gains always count toward new stacks."); Harmony val = new Harmony("binma.minerspeedflips"); val.PatchAll(typeof(Plugin).Assembly); GoldRushFix.Apply(val); } } [HarmonyPatch(typeof(GenericCharacterMain), "TryPerformJump")] internal static class JumpPatch { private static BodyIndex minerIndex = (BodyIndex)(-1); private static BuffIndex goldRush = (BuffIndex)(-1); private static void Postfix(GenericCharacterMain __instance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) try { CharacterBody val = ((!((Object)(object)((EntityState)__instance).outer != (Object)null)) ? null : ((Component)((EntityState)__instance).outer).GetComponent<CharacterBody>()); if ((Object)(object)val == (Object)null) { return; } if ((int)minerIndex == -1) { minerIndex = BodyCatalog.FindBodyIndex("MinerBody"); } if (val.bodyIndex != minerIndex || (int)minerIndex == -1) { return; } if ((int)goldRush == -1) { goldRush = BuffCatalog.FindBuffIndex("GoldRush"); } int num = (((int)goldRush != -1) ? val.GetBuffCount(goldRush) : 0); if (val.moveSpeed >= Plugin.Threshold.Value || (Plugin.GoldRushThreshold.Value > 0 && num >= Plugin.GoldRushThreshold.Value)) { return; } ModelLocator modelLocator = val.modelLocator; Animator val2 = ((!((Object)(object)modelLocator != (Object)null) || !((Object)(object)modelLocator.modelTransform != (Object)null)) ? null : ((Component)modelLocator.modelTransform).GetComponent<Animator>()); if (!((Object)(object)val2 == (Object)null)) { int layerIndex = val2.GetLayerIndex("Body"); if (layerIndex >= 0) { val2.CrossFadeInFixedTime("AscendDescend", 0.1f, layerIndex); } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class GoldRushFix { private static FieldInfo tracker; private static bool skip; internal static void Apply(Harmony h) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00d9: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown Type type = AccessTools.TypeByName("EntityStates.Digger.DiggerMain"); tracker = ((!(type != null)) ? null : AccessTools.Field(type, "moneyTracker")); MethodInfo methodInfo = ((!(type != null)) ? null : AccessTools.Method(type, "UpdatePassiveBuff", (Type[])null, (Type[])null)); MethodInfo methodInfo2 = ((!(type != null)) ? null : AccessTools.Method(type, "RefreshExistingStacks", (Type[])null, (Type[])null)); if (tracker == null || methodInfo == null || methodInfo2 == null) { Plugin.Log.LogWarning((object)"Miner's Gold Rush code not found; small-gold fix off."); return; } h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(GoldRushFix), "UpdatePrefix", (Type[])null), new HarmonyMethod(typeof(GoldRushFix), "UpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(GoldRushFix), "RefreshPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void UpdatePrefix(EntityState __instance) { skip = false; try { if (Plugin.RefreshThreshold.Value <= 0f || (Object)(object)Run.instance == (Object)null) { return; } CharacterBody val = ((!((Object)(object)__instance.outer != (Object)null)) ? null : ((Component)__instance.outer).GetComponent<CharacterBody>()); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.master == (Object)null)) { double num = val.master.money; double num2 = Convert.ToDouble(tracker.GetValue(__instance)); double num3 = num - num2; if (!(num3 <= 0.0)) { double num4 = num3 / Math.Pow(Run.instance.difficultyCoefficient, 1.25) / 5.0; skip = num4 < (double)Plugin.RefreshThreshold.Value; } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private static void UpdatePostfix() { skip = false; } private static bool RefreshPrefix() { return !skip; } }