Neatened up NHGameOverManager.LoadCustomCreditsScene() and added some comments to explain things

This commit is contained in:
josshmot 2025-04-08 17:01:06 +10:00
parent 6d77b0b1d1
commit 0e6555d933

View File

@ -148,13 +148,12 @@ namespace NewHorizons.Components
LoadManager.LoadScene(toScene, LoadManager.FadeType.ToBlack); LoadManager.LoadScene(toScene, LoadManager.FadeType.ToBlack);
// We need to do this so we can unsubscribe from within the lambda. // Unfortunately we can't make this a private method, as LoadManager.SceneLoadEvent enforces the (fromScene, toScene) parameters, which prevents us from passing in gameOver and mod, which we need.
LoadManager.SceneLoadEvent completeCreditsLoad = null; LoadManager.SceneLoadEvent completeCreditsLoad = null; // needs to be done so we can unsubscribe from within the lambda.
completeCreditsLoad = (fromScene, toScene) => completeCreditsLoad = (fromScene, toScene) =>
{ {
// Patch new music clip // Patch new music clip
var musicSource = Locator.FindObjectsOfType<OWAudioSource>().Where(x => x.name == "AudioSource").Single(); var musicSource = Locator.FindObjectsOfType<OWAudioSource>().Where(x => x.name == "AudioSource").Single(); // AudioSource that plays the credits music is literally called "AudioSource", luckily it's the only one called that. Lazy OW devs do be lazy.
if (mod is not null) if (mod is not null)
{ {
AudioUtilities.SetAudioClip(musicSource, gameOver.audio, mod); AudioUtilities.SetAudioClip(musicSource, gameOver.audio, mod);