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 SoundAPI Repo Fix v1.1.0
SoundApiRepoFix.dll
Decompiled 2 months agousing System; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("SoundApiRepoFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SoundApiRepoFix")] [assembly: AssemblyTitle("SoundApiRepoFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 SoundApiRepoFix { [BepInPlugin("themorningstar.soundapirepofix", "SoundAPI REPO Fix", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "themorningstar.soundapirepofix"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; PatchResetAudioInfoFetched(); RepatchSoundApiRepo(); } private void PatchResetAudioInfoFetched() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method("loaforcsSoundAPI.REPO.Patches.SoundPatch:ResetAudioInfoFetched", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogWarning((object)"SoundApiRepoFix: SoundPatch.ResetAudioInfoFetched not found - skipping null-guard (mod version changed?)."); return; } new Harmony("themorningstar.soundapirepofix").Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Patch).GetMethod("SafeReset")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"SoundApiRepoFix: null-guarded SoundPatch.ResetAudioInfoFetched."); } catch (Exception ex) { Log.LogError((object)("SoundApiRepoFix: null-guard patch failed: " + ex)); } } private void RepatchSoundApiRepo() { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_01f5: 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_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) try { Assembly assembly = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { if (assembly2.GetName().Name == "loaforcsSoundAPI.REPO") { assembly = assembly2; break; } } if (assembly == null) { Log.LogWarning((object)"SoundApiRepoFix: loaforcsSoundAPI.REPO assembly not found; can't re-apply its patches."); return; } MethodInfo methodInfo = AccessTools.Method(typeof(Sound), "PlayLoop", new Type[5] { typeof(bool), typeof(float), typeof(float), typeof(float), typeof(float) }, (Type[])null); Harmony val = new Harmony("me.loaforc.soundapi.repo"); val.UnpatchSelf(); Log.LogInfo((object)"SoundApiRepoFix: cleared partial loaforcsSoundAPI_REPO patches; re-applying all."); int num = 0; int num2 = 0; int num3 = 0; Type[] types = assembly.GetTypes(); Unsafe.SkipInit(out object obj2); foreach (Type type in types) { if (!type.IsClass || type.IsAbstract) { continue; } try { new PatchClassProcessor(val, type).Patch(); num++; } catch (object obj) when (((Func<bool>)delegate { // Could not convert BlockContainer to single expression obj2 = ((obj is HarmonyException) ? obj : null); return obj2 != null && ((Exception)obj2).InnerException is AmbiguousMatchException; }).Invoke()) { if (methodInfo == null) { num3++; continue; } try { MethodInfo methodInfo2 = null; MethodInfo methodInfo3 = null; MethodInfo methodInfo4 = null; MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo5 in methods) { if (((MemberInfo)methodInfo5).GetCustomAttribute<HarmonyPrefix>() != null) { methodInfo2 = methodInfo5; } else if (((MemberInfo)methodInfo5).GetCustomAttribute<HarmonyPostfix>() != null) { methodInfo3 = methodInfo5; } else if (((MemberInfo)methodInfo5).GetCustomAttribute<HarmonyTranspiler>() != null) { methodInfo4 = methodInfo5; } } if (methodInfo2 == null && methodInfo3 == null && methodInfo4 == null) { num3++; continue; } val.Patch((MethodBase)methodInfo, (!(methodInfo2 != null)) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo2), (!(methodInfo3 != null)) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo3), (!(methodInfo4 != null)) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null); num2++; Log.LogInfo((object)("SoundApiRepoFix: applied ambiguous " + type.Name + " manually to 5-arg Sound.PlayLoop (prefix=" + (methodInfo2?.Name ?? "none") + ", transpiler=" + (methodInfo4?.Name ?? "none") + ").")); } catch (Exception ex) { Log.LogWarning((object)("SoundApiRepoFix: failed to manually patch " + type.Name + ": " + ex.Message)); num3++; } } catch (Exception) { num3++; } } Log.LogInfo((object)$"SoundApiRepoFix: re-applied loaforcsSoundAPI_REPO patches: {num} normal, {num2} PlayLoop-explicit, {num3} skipped."); } catch (Exception ex3) { Log.LogError((object)("SoundApiRepoFix: RepatchSoundApiRepo failed: " + ex3)); } } } internal static class Patch { public static bool SafeReset(Sound __instance) { if (__instance != null && (Object)(object)__instance.Source != (Object)null && (Object)(object)__instance.Source.clip == (Object)null) { __instance.AudioInfoFetched = false; } return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }