mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Do the thing where the screen fades out on black holes only
This commit is contained in:
parent
698e35733a
commit
93a61da2f8
@ -21,6 +21,7 @@ namespace NewHorizons.Components.Volumes
|
||||
public override void VanishPlayer(OWRigidbody playerBody, RelativeLocationData entryLocation)
|
||||
{
|
||||
Locator.GetPlayerAudioController().PlayOneShotInternal(AudioType.BH_BlackHoleEmission);
|
||||
FadeHandler.FadeOut(0.2f, false);
|
||||
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
|
||||
PlayerSpawnHandler.TargetSpawnID = TargetSpawnID;
|
||||
}
|
||||
|
||||
@ -11,11 +11,16 @@ namespace NewHorizons.Handlers
|
||||
/// </summary>
|
||||
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));
|
||||
|
||||
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;
|
||||
float startTime = Time.unscaledTime;
|
||||
@ -25,14 +30,25 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
var t = Mathf.Clamp01((Time.unscaledTime - startTime) / length);
|
||||
LoadManager.s_instance._fadeImage.color = Color.Lerp(Color.clear, Color.black, t);
|
||||
if (fadeSound)
|
||||
{
|
||||
AudioListener.volume = 1f - t;
|
||||
}
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
LoadManager.s_instance._fadeImage.color = Color.black;
|
||||
if (fadeSound)
|
||||
{
|
||||
AudioListener.volume = 0;
|
||||
}
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new WaitForSeconds(length);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerator FadeInCoroutine(float length)
|
||||
{
|
||||
@ -58,7 +74,7 @@ namespace NewHorizons.Handlers
|
||||
|
||||
private static IEnumerator FadeThenCoroutine(float length, Action action)
|
||||
{
|
||||
yield return FadeOutCoroutine(length);
|
||||
yield return FadeOutCoroutine(length, true);
|
||||
|
||||
action?.Invoke();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user