Fixed coroutine

This commit is contained in:
Nick 2023-03-18 17:38:55 -04:00
parent bd61a87cf6
commit 8d985fe169

View File

@ -2,6 +2,7 @@ using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using System.Collections; using System.Collections;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Components.Volumes namespace NewHorizons.Components.Volumes
{ {
@ -25,7 +26,8 @@ namespace NewHorizons.Components.Volumes
{ {
if (hitObj.CompareTag("PlayerDetector") && enabled) if (hitObj.CompareTag("PlayerDetector") && enabled)
{ {
StartCoroutine(GameOver()); // Have to run it off the mod behaviour since the game over controller disables everything
Main.Instance.StartCoroutine(GameOver());
} }
} }
@ -36,6 +38,9 @@ namespace NewHorizons.Components.Volumes
Locator.GetPromptManager().SetPromptsVisible(false); Locator.GetPromptManager().SetPromptsVisible(false);
Locator.GetPauseCommandListener().AddPauseCommandLock(); Locator.GetPauseCommandListener().AddPauseCommandLock();
// The PlayerCameraEffectController is what actually kills us, so convince it we're already dead
Locator.GetDeathManager()._isDead = true;
_playerCameraEffectController.OnPlayerDeath(deathType); _playerCameraEffectController.OnPlayerDeath(deathType);
yield return new WaitForSeconds(_playerCameraEffectController._deathFadeLength); yield return new WaitForSeconds(_playerCameraEffectController._deathFadeLength);
@ -49,14 +54,10 @@ namespace NewHorizons.Components.Volumes
_gameOverController._loading = true; _gameOverController._loading = true;
yield return new WaitUntil(ReadytoLoadCreditsScene); yield return new WaitUntil(ReadytoLoadCreditsScene);
}
LoadCreditsScene(); LoadCreditsScene();
} }
else
{
LoadCreditsScene();
}
}
private bool ReadytoLoadCreditsScene() => _gameOverController._fadedOutText && _gameOverController._textAnimator.IsComplete(); private bool ReadytoLoadCreditsScene() => _gameOverController._fadedOutText && _gameOverController._textAnimator.IsComplete();
@ -64,6 +65,8 @@ namespace NewHorizons.Components.Volumes
private void LoadCreditsScene() private void LoadCreditsScene()
{ {
Logger.LogVerbose($"Load credits {creditsType}");
switch (creditsType) switch (creditsType)
{ {
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast: case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast: