using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
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: AssemblyCompany("me.loaforc.soundapi.repo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+48466f205a331bbfbabb327827601bfd154e03d3")]
[assembly: AssemblyProduct("loaforcsSoundAPI.REPO")]
[assembly: AssemblyTitle("me.loaforc.soundapi.repo")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace loaforcsSoundAPI.REPO
{
[BepInPlugin("me.loaforc.soundapi.repo", "loaforcsSoundAPI.REPO", "1.0.1")]
public class SoundAPIREPO : BaseUnityPlugin
{
public static SoundAPIREPO Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = Logger.CreateLogSource("me.loaforc.soundapi.repo");
Instance = this;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "me.loaforc.soundapi.repo");
Logger.LogInfo((object)"me.loaforc.soundapi.repo has loaded :3");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "me.loaforc.soundapi.repo";
public const string PLUGIN_NAME = "loaforcsSoundAPI.REPO";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace loaforcsSoundAPI.REPO.Patches
{
[HarmonyPatch(typeof(Sound))]
internal static class SoundPatch
{
[HarmonyTranspiler]
[HarmonyPatch("PlayLoop")]
private static IEnumerable<CodeInstruction> FixLoopingSounds(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[5]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Sound), "Source"), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Sound), "LoopClip"), (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(AudioSource), "clip"), (string)null)
}).Insert((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldc_I4_1, (object)null),
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(Sound), "AudioInfoFetched"))
}).InstructionEnumeration();
}
[HarmonyPrefix]
[HarmonyPatch("PlayLoop")]
private static void ResetAudioInfoFetched(Sound __instance)
{
if (!Object.op_Implicit((Object)(object)__instance.Source.clip))
{
__instance.AudioInfoFetched = false;
}
}
}
}