Merge branch 'killer-tornados' of https://github.com/Outer-Wilds-New-Horizons/new-horizons into killer-tornados

This commit is contained in:
Nick 2023-07-21 23:48:23 -04:00
commit 0d66d7fce5

View File

@ -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<AudioDetector>();
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;
}
}