diff --git a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs index 70093cc4..d9927566 100644 --- a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs @@ -13,7 +13,7 @@ namespace NewHorizons.Builder.Volumes volume.creditsType = info.creditsType; volume.gameOverText = info.gameOverText; - volume.deathType = EnumUtils.Parse(info.deathType.ToString(), DeathType.Default); + volume.deathType = info.deathType == null ? null : EnumUtils.Parse(info.deathType.ToString(), DeathType.Default); return volume; } diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index 18edcbd1..9f098113 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -10,10 +10,10 @@ namespace NewHorizons.Components.Volumes { internal class LoadCreditsVolume : BaseVolume { - public NHCreditsType creditsType = NHCreditsType.Fast; + public NHCreditsType creditsType = NHCreditsType.None; public string gameOverText; - public DeathType deathType = DeathType.Default; + public DeathType? deathType = DeathType.Default; private GameOverController _gameOverController; private PlayerCameraEffectController _playerCameraEffectController; @@ -43,15 +43,28 @@ namespace NewHorizons.Components.Volumes // The PlayerCameraEffectController is what actually kills us, so convince it we're already dead Locator.GetDeathManager()._isDead = true; - _playerCameraEffectController.OnPlayerDeath(deathType); + var fadeLength = 2f; + + if (deathType is DeathType nonNullDeathType) + { + _playerCameraEffectController.OnPlayerDeath(nonNullDeathType); + fadeLength = _playerCameraEffectController._deathFadeLength; + } + else + { + FadeHandler.FadeOut(fadeLength); + } - yield return new WaitForSeconds(_playerCameraEffectController._deathFadeLength); + yield return new WaitForSeconds(fadeLength); if (!string.IsNullOrEmpty(gameOverText) && _gameOverController != null) { _gameOverController._deathText.text = TranslationHandler.GetTranslation(gameOverText, TranslationHandler.TextType.UI); _gameOverController.SetupGameOverScreen(5f); + // Make sure the fade handler is off now + FadeHandler.FadeIn(0f); + // We set this to true to stop it from loading the credits scene, so we can do it ourselves _gameOverController._loading = true; @@ -81,6 +94,9 @@ namespace NewHorizons.Components.Volumes TimelineObliterationController.s_hasRealityEnded = true; LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); break; + default: + GlobalMessenger.FireEvent("TriggerFlashback"); + break; } } } diff --git a/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs index 60be21d5..ca89806c 100644 --- a/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs +++ b/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs @@ -7,7 +7,7 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos [JsonObject] public class LoadCreditsVolumeInfo : VolumeInfo { - [DefaultValue("fast")] public NHCreditsType creditsType = NHCreditsType.Fast; + [DefaultValue("none")] public NHCreditsType creditsType = NHCreditsType.None; /// /// Text displayed in orange on game over. For localization, put translations under UI. @@ -15,8 +15,8 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos public string gameOverText; /// - /// The type of death the player will have if they enter this volume. + /// The type of death the player will have if they enter this volume. Don't set to have the camera just fade out. /// - [DefaultValue("default")] public NHDeathType deathType = NHDeathType.Default; + [DefaultValue("default")] public NHDeathType? deathType = null; } } diff --git a/NewHorizons/External/SerializableEnums/NHCreditsType.cs b/NewHorizons/External/SerializableEnums/NHCreditsType.cs index fe4d08be..83c1dc51 100644 --- a/NewHorizons/External/SerializableEnums/NHCreditsType.cs +++ b/NewHorizons/External/SerializableEnums/NHCreditsType.cs @@ -11,6 +11,8 @@ namespace NewHorizons.External.SerializableEnums [EnumMember(Value = @"final")] Final = 1, - [EnumMember(Value = @"kazoo")] Kazoo = 2 + [EnumMember(Value = @"kazoo")] Kazoo = 2, + + [EnumMember(Value = @"none")] None = 3 } } diff --git a/NewHorizons/Handlers/FadeHandler.cs b/NewHorizons/Handlers/FadeHandler.cs index fbaa0b5b..41453488 100644 --- a/NewHorizons/Handlers/FadeHandler.cs +++ b/NewHorizons/Handlers/FadeHandler.cs @@ -9,6 +9,8 @@ namespace NewHorizons.Handlers { public static void FadeOut(float length) => Delay.StartCoroutine(FadeOutCoroutine(length)); + public static void FadeIn(float length) => Delay.StartCoroutine(FadeInCoroutine(length)); + private static IEnumerator FadeOutCoroutine(float length) { LoadManager.s_instance._fadeCanvas.enabled = true; @@ -25,6 +27,23 @@ namespace NewHorizons.Handlers yield return new WaitForEndOfFrame(); } + private static IEnumerator FadeInCoroutine(float length) + { + float startTime = Time.unscaledTime; + float endTime = Time.unscaledTime + length; + + while (Time.unscaledTime < endTime) + { + LoadManager.s_instance._fadeImage.color = Color.Lerp(Color.black, Color.clear, (Time.unscaledTime - startTime) / length); + yield return new WaitForEndOfFrame(); + } + + LoadManager.s_instance._fadeCanvas.enabled = false; + LoadManager.s_instance._fadeImage.color = Color.clear; + + yield return new WaitForEndOfFrame(); + } + public static void FadeThen(float length, Action action) => Delay.StartCoroutine(FadeThenCoroutine(length, action)); private static IEnumerator FadeThenCoroutine(float length, Action action)