mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge branch 'killer-tornados' of https://github.com/Outer-Wilds-New-Horizons/new-horizons into killer-tornados
This commit is contained in:
commit
0d66d7fce5
38
NewHorizons/Patches/GlobalMusicControllerPatches.cs
Normal file
38
NewHorizons/Patches/GlobalMusicControllerPatches.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user