mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
86 lines
3.2 KiB
C#
86 lines
3.2 KiB
C#
using NewHorizons.External.Modules.Volumes;
|
|
using NewHorizons.Handlers;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using Logger = NewHorizons.Utility.Logger;
|
|
|
|
namespace NewHorizons.Components.Volumes
|
|
{
|
|
internal class LoadCreditsVolume : BaseVolume
|
|
{
|
|
public CreditsType creditsType = CreditsType.Fast;
|
|
|
|
public string gameOverText;
|
|
public DeathType deathType = DeathType.Default;
|
|
|
|
private GameOverController _gameOverController;
|
|
private PlayerCameraEffectController _playerCameraEffectController;
|
|
|
|
public void Start()
|
|
{
|
|
_gameOverController = GameObject.FindObjectOfType<GameOverController>();
|
|
_playerCameraEffectController = GameObject.FindObjectOfType<PlayerCameraEffectController>();
|
|
}
|
|
|
|
public override void OnTriggerVolumeEntry(GameObject hitObj)
|
|
{
|
|
if (hitObj.CompareTag("PlayerDetector") && enabled)
|
|
{
|
|
// Have to run it off the mod behaviour since the game over controller disables everything
|
|
Main.Instance.StartCoroutine(GameOver());
|
|
}
|
|
}
|
|
|
|
private IEnumerator GameOver()
|
|
{
|
|
OWInput.ChangeInputMode(InputMode.None);
|
|
ReticleController.Hide();
|
|
Locator.GetPromptManager().SetPromptsVisible(false);
|
|
Locator.GetPauseCommandListener().AddPauseCommandLock();
|
|
|
|
// The PlayerCameraEffectController is what actually kills us, so convince it we're already dead
|
|
Locator.GetDeathManager()._isDead = true;
|
|
|
|
_playerCameraEffectController.OnPlayerDeath(deathType);
|
|
|
|
yield return new WaitForSeconds(_playerCameraEffectController._deathFadeLength);
|
|
|
|
if (!string.IsNullOrEmpty(gameOverText) && _gameOverController != null)
|
|
{
|
|
_gameOverController._deathText.text = TranslationHandler.GetTranslation(gameOverText, TranslationHandler.TextType.UI);
|
|
_gameOverController.SetupGameOverScreen(5f);
|
|
|
|
// We set this to true to stop it from loading the credits scene, so we can do it ourselves
|
|
_gameOverController._loading = true;
|
|
|
|
yield return new WaitUntil(ReadytoLoadCreditsScene);
|
|
}
|
|
|
|
LoadCreditsScene();
|
|
}
|
|
|
|
private bool ReadytoLoadCreditsScene() => _gameOverController._fadedOutText && _gameOverController._textAnimator.IsComplete();
|
|
|
|
public override void OnTriggerVolumeExit(GameObject hitObj) { }
|
|
|
|
private void LoadCreditsScene()
|
|
{
|
|
Logger.LogVerbose($"Load credits {creditsType}");
|
|
|
|
switch (creditsType)
|
|
{
|
|
case CreditsType.Fast:
|
|
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
|
|
break;
|
|
case CreditsType.Final:
|
|
LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack);
|
|
break;
|
|
case CreditsType.Kazoo:
|
|
TimelineObliterationController.s_hasRealityEnded = true;
|
|
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|