Do the thing where the screen fades out on black holes only

This commit is contained in:
xen-42 2025-02-15 01:43:38 -05:00
parent 698e35733a
commit 93a61da2f8
2 changed files with 32 additions and 15 deletions

View File

@ -21,6 +21,7 @@ namespace NewHorizons.Components.Volumes
public override void VanishPlayer(OWRigidbody playerBody, RelativeLocationData entryLocation) public override void VanishPlayer(OWRigidbody playerBody, RelativeLocationData entryLocation)
{ {
Locator.GetPlayerAudioController().PlayOneShotInternal(AudioType.BH_BlackHoleEmission); Locator.GetPlayerAudioController().PlayOneShotInternal(AudioType.BH_BlackHoleEmission);
FadeHandler.FadeOut(0.2f, false);
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole()); Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
PlayerSpawnHandler.TargetSpawnID = TargetSpawnID; PlayerSpawnHandler.TargetSpawnID = TargetSpawnID;
} }

View File

@ -11,11 +11,16 @@ namespace NewHorizons.Handlers
/// </summary> /// </summary>
public static class FadeHandler public static class FadeHandler
{ {
public static void FadeOut(float length) => Delay.StartCoroutine(FadeOutCoroutine(length)); public static void FadeOut(float length) => Delay.StartCoroutine(FadeOutCoroutine(length, true));
public static void FadeOut(float length, bool fadeSound) => Delay.StartCoroutine(FadeOutCoroutine(length, fadeSound));
public static void FadeIn(float length) => Delay.StartCoroutine(FadeInCoroutine(length)); public static void FadeIn(float length) => Delay.StartCoroutine(FadeInCoroutine(length));
private static IEnumerator FadeOutCoroutine(float length) private static IEnumerator FadeOutCoroutine(float length, bool fadeSound)
{
// Make sure its not already faded
if (!LoadManager.s_instance._fadeCanvas.enabled)
{ {
LoadManager.s_instance._fadeCanvas.enabled = true; LoadManager.s_instance._fadeCanvas.enabled = true;
float startTime = Time.unscaledTime; float startTime = Time.unscaledTime;
@ -25,14 +30,25 @@ namespace NewHorizons.Handlers
{ {
var t = Mathf.Clamp01((Time.unscaledTime - startTime) / length); var t = Mathf.Clamp01((Time.unscaledTime - startTime) / length);
LoadManager.s_instance._fadeImage.color = Color.Lerp(Color.clear, Color.black, t); LoadManager.s_instance._fadeImage.color = Color.Lerp(Color.clear, Color.black, t);
if (fadeSound)
{
AudioListener.volume = 1f - t; AudioListener.volume = 1f - t;
}
yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame();
} }
LoadManager.s_instance._fadeImage.color = Color.black; LoadManager.s_instance._fadeImage.color = Color.black;
if (fadeSound)
{
AudioListener.volume = 0; AudioListener.volume = 0;
}
yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame();
} }
else
{
yield return new WaitForSeconds(length);
}
}
private static IEnumerator FadeInCoroutine(float length) private static IEnumerator FadeInCoroutine(float length)
{ {
@ -58,7 +74,7 @@ namespace NewHorizons.Handlers
private static IEnumerator FadeThenCoroutine(float length, Action action) private static IEnumerator FadeThenCoroutine(float length, Action action)
{ {
yield return FadeOutCoroutine(length); yield return FadeOutCoroutine(length, true);
action?.Invoke(); action?.Invoke();
} }