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.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("com.fiction.hitstopmusicsync", "Hitstop Music Sync (Winamp v5.666)", "1.0.0")] public class Hitstopmusicsync : BaseUnityPlugin { private Harmony harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown harmony = new Harmony("com.fiction.hitstopmusicsync"); harmony.PatchAll(); } } public static class WinampMuter { private static float previousVolume = -1f; private static bool isMuted = false; public static void Toggle() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) Process process = Process.GetProcessesByName("Winamp").FirstOrDefault(); if (process == null) { Logger.CreateLogSource("HitstopMusicSync").LogError((object)"Winamp not found! Is it open?"); return; } SessionCollection sessions = new MMDeviceEnumerator().GetDefaultAudioEndpoint((DataFlow)0, (Role)1).AudioSessionManager.Sessions; for (int i = 0; i < sessions.Count; i++) { AudioSessionControl val = sessions[i]; if (val.GetProcessID == process.Id) { if (!isMuted) { previousVolume = val.SimpleAudioVolume.Volume; val.SimpleAudioVolume.Volume = 0f; isMuted = true; } else { val.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) { WinampMuter.Toggle(); MusicState.PausedByMod = true; } } } [HarmonyPatch(typeof(TimeController), "ContinueTime")] public static class HitstopEndPatch { [HarmonyPostfix] private static void Postfix(float length, bool trueStop) { if (MusicState.PausedByMod) { WinampMuter.Toggle(); MusicState.PausedByMod = false; } } }