using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using NAudio.CoreAudioApi; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("com.n4pstr.hitstopmusicsync", "Hitstop Music Sync (Supersonic)", "1.0.0")] public class hitstopmusicsync : BaseUnityPlugin { private Harmony harmony; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony = new Harmony("com.n4pstr.hitstopmusicsync"); harmony.PatchAll(); } } public static class SupersonicMuter { private static float previousVolume = -1f; private static bool isMuted = false; public static void Toggle() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown Process process = Process.GetProcessesByName("Supersonic").FirstOrDefault(); if (process == null) { ManualLogSource val = Logger.CreateLogSource("HitstopMusicSync"); val.LogError((object)"Supersonic not found! Is it open?"); return; } MMDeviceEnumerator val2 = new MMDeviceEnumerator(); SessionCollection sessions = val2.GetDefaultAudioEndpoint((DataFlow)0, (Role)1).AudioSessionManager.Sessions; for (int i = 0; i < sessions.Count; i++) { AudioSessionControl val3 = sessions[i]; if (val3.GetProcessID == process.Id) { if (!isMuted) { previousVolume = val3.SimpleAudioVolume.Volume; val3.SimpleAudioVolume.Volume = 0f; isMuted = true; } else { val3.SimpleAudioVolume.Volume = previousVolume; isMuted = false; } break; } } } } public static class MusicState { public static bool PausedByMod; } [HarmonyPatch(typeof(TimeController), "TrueStop")] public static class HitstopStartPatch { [HarmonyPrefix] private static void Prefix(float length) { if (!MusicState.PausedByMod) { SupersonicMuter.Toggle(); MusicState.PausedByMod = true; } } } [HarmonyPatch(typeof(TimeController), "ContinueTime")] public static class HitstopEndPatch { [HarmonyPostfix] private static void Postfix(float length, bool trueStop) { if (MusicState.PausedByMod) { SupersonicMuter.Toggle(); MusicState.PausedByMod = false; } } }