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 (#1046)
## Improvements - Screen fades out faster now on system-changing black hole. Fixes #783.
This commit is contained in:
commit
2a1b2484cb
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user