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 BetterSonLaserAnimFix v1.0.0
BetterSonLaserAnimFix.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using EntityStates; using HarmonyLib; using RoR2; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace BetterSonLaserAnimFix; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("binma.bettersonlaser.animfix", "Better Son Laser Anim Fix", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static Type chargeT; internal static Type fireT; internal static FieldInfo cancelF; internal static readonly HashSet<EntityState> fullBody = new HashSet<EntityState>(); private void Awake() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown chargeT = AccessTools.TypeByName("BetterSonLaser.BetterLaserCharge"); fireT = AccessTools.TypeByName("BetterSonLaser.BetterLaserFire"); if (chargeT == null || fireT == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"BetterSonLaser states not found; nothing to fix."); return; } cancelF = AccessTools.Field(chargeT, "cancellingAttack"); Harmony val = new Harmony("binma.bettersonlaser.animfix"); HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin), "Remap", (Type[])null); MethodInfo[] methods = typeof(EntityState).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "PlayAnimation") || !(methodInfo.Name != "PlayCrossfade")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length >= 2 && !(parameters[0].ParameterType != typeof(string)) && !(parameters[1].ParameterType != typeof(string))) { val.Patch((MethodBase)methodInfo, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } MethodInfo methodInfo2 = AccessTools.Method(chargeT, "OnEnter", (Type[])null, (Type[])null); HarmonyMethod val3 = new HarmonyMethod(typeof(Plugin), "LaserOn", (Type[])null); val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo2 = AccessTools.Method(fireT, "OnEnter", (Type[])null, (Type[])null); val3 = new HarmonyMethod(typeof(Plugin), "LaserOn", (Type[])null); val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo2 = AccessTools.Method(chargeT, "OnExit", (Type[])null, (Type[])null); val3 = new HarmonyMethod(typeof(Plugin), "ChargeExit", (Type[])null); val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo2 = AccessTools.Method(fireT, "OnExit", (Type[])null, (Type[])null); val3 = new HarmonyMethod(typeof(Plugin), "FireExit", (Type[])null); val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } internal static Animator Anim(EntityState s) { ModelLocator val = ((!Object.op_Implicit((Object)(object)s.outer)) ? null : ((Component)s.outer).GetComponent<ModelLocator>()); return (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.modelTransform)) ? null : ((Component)val.modelTransform).GetComponent<Animator>(); } private static bool StandingStill(Animator a) { return Object.op_Implicit((Object)(object)a) && !a.GetBool("isMoving") && a.GetBool("isGrounded"); } private static bool Remap(EntityState __instance, ref string __0, string __1) { if (__instance == null) { return true; } Type type = ((object)__instance).GetType(); bool flag = type == chargeT; bool flag2 = type == fireT; if (!flag && !flag2) { return true; } bool flag3 = flag && cancelF != null && (bool)cancelF.GetValue(__instance); if (__0 != null) { if (__0 == "Gesture, Head, Override") { if (__1 == "Buffer Empty") { return false; } __0 = "Gesture, Override"; return true; } if (__0 == "Gesture, Head, Additive") { switch (__1) { case "LaserChargeIntro": case "FireLaserLoop": if (!StandingStill(Anim(__instance))) { return false; } fullBody.Add(__instance); __0 = "FullBody, Override"; return true; case "FireLaserLoopEnd": { Animator val = Anim(__instance); bool flag4 = fullBody.Remove(__instance); bool flag5 = Object.op_Implicit((Object)(object)val) && val.GetBool("LaserLoopOverrideEndedEarly"); if (!flag4 || flag5) { return false; } __0 = "FullBody, Override"; return true; } default: return false; } } if (__0 == "Gesture, Additive" || __0 == "Gesture, Override") { if (flag && __1 == "Empty" && !flag3) { return false; } return true; } } return true; } private static void LaserOn(EntityState __instance) { Animator val = Anim(__instance); if (Object.op_Implicit((Object)(object)val)) { val.SetBool("isLasering", true); } } private static void ChargeExit(EntityState __instance) { fullBody.Remove(__instance); if (cancelF != null && (bool)cancelF.GetValue(__instance)) { Animator val = Anim(__instance); if (Object.op_Implicit((Object)(object)val)) { val.SetBool("isLasering", false); } } } private static void FireExit(EntityState __instance) { fullBody.Remove(__instance); Animator val = Anim(__instance); if (Object.op_Implicit((Object)(object)val)) { val.SetBool("LaserLoopOverrideEndedEarly", false); val.SetBool("isLasering", false); } } }