From 33b4bbb86bb1b2c0fd3401dcf65ac449e9cb6bd4 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 21 Jul 2023 19:42:47 -0700 Subject: [PATCH 1/2] dont play bramble music if in another audio volume --- .../Patches/GlobalMusicControllerPatches.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 NewHorizons/Patches/GlobalMusicControllerPatches.cs diff --git a/NewHorizons/Patches/GlobalMusicControllerPatches.cs b/NewHorizons/Patches/GlobalMusicControllerPatches.cs new file mode 100644 index 00000000..1bff3dba --- /dev/null +++ b/NewHorizons/Patches/GlobalMusicControllerPatches.cs @@ -0,0 +1,38 @@ +using HarmonyLib; +using UnityEngine; + +namespace NewHorizons.Patches; + +[HarmonyPatch(typeof(GlobalMusicController))] +public class GlobalMusicControllerPatches +{ + private static AudioDetector _audioDetector; + + [HarmonyPrefix] + [HarmonyPatch(nameof(GlobalMusicController.UpdateBrambleMusic))] + public static bool GlobalMusicController_UpdateBrambleMusic(GlobalMusicController __instance) + { + // is this too hacky? + if (_audioDetector == null) _audioDetector = Object.FindObjectOfType(); + + + var shouldBePlaying = Locator.GetPlayerSectorDetector().InBrambleDimension() && + !Locator.GetPlayerSectorDetector().InVesselDimension() && + PlayerState.AtFlightConsole() && + !PlayerState.IsHullBreached() && + !__instance._playingFinalEndTimes && + _audioDetector._activeVolumes.Count > 0; // change - don't play if in another audio volume + var playing = __instance._darkBrambleSource.isPlaying && + !__instance._darkBrambleSource.IsFadingOut(); + if (shouldBePlaying && !playing) + { + __instance._darkBrambleSource.FadeIn(5f); + } + else if (!shouldBePlaying && playing) + { + __instance._darkBrambleSource.FadeOut(5f); + } + + return false; + } +} From 3df28f4eded94cc103b3ccfed2ab837e2c5b1005 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 21 Jul 2023 19:44:34 -0700 Subject: [PATCH 2/2] me very stupid --- NewHorizons/Patches/GlobalMusicControllerPatches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Patches/GlobalMusicControllerPatches.cs b/NewHorizons/Patches/GlobalMusicControllerPatches.cs index 1bff3dba..776cb8e8 100644 --- a/NewHorizons/Patches/GlobalMusicControllerPatches.cs +++ b/NewHorizons/Patches/GlobalMusicControllerPatches.cs @@ -21,7 +21,7 @@ public class GlobalMusicControllerPatches PlayerState.AtFlightConsole() && !PlayerState.IsHullBreached() && !__instance._playingFinalEndTimes && - _audioDetector._activeVolumes.Count > 0; // change - don't play if in another audio volume + _audioDetector._activeVolumes.Count == 0; // change - don't play if in another audio volume var playing = __instance._darkBrambleSource.isPlaying && !__instance._darkBrambleSource.IsFadingOut(); if (shouldBePlaying && !playing)