mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fixed undefined behaviour when custom credits attributes aren't specified
This commit is contained in:
parent
53d20525bd
commit
0b65c852d2
@ -165,7 +165,14 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
// Patch new music clip
|
// Patch new music clip
|
||||||
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.
|
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.
|
||||||
AudioUtilities.SetAudioClip(musicSource, gameOver.audio, mod);
|
if (gameOver.audio != string.Empty) // string.Empty is default value for "audio" in GameOverModule, means no audio is specified.
|
||||||
|
{
|
||||||
|
AudioUtilities.SetAudioClip(musicSource, gameOver.audio, mod); // Load audio if specified
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
musicSource.AssignAudioLibraryClip(AudioType.PLACEHOLDER); // Otherwise default custom credits are silent
|
||||||
|
}
|
||||||
|
|
||||||
musicSource.loop = gameOver.audioLooping;
|
musicSource.loop = gameOver.audioLooping;
|
||||||
musicSource._maxSourceVolume = gameOver.audioVolume;
|
musicSource._maxSourceVolume = gameOver.audioVolume;
|
||||||
|
|||||||
11
NewHorizons/External/Modules/GameOverModule.cs
vendored
11
NewHorizons/External/Modules/GameOverModule.cs
vendored
@ -28,28 +28,25 @@ namespace NewHorizons.External.Modules
|
|||||||
/// Path to the audio file to use as custom music for the credits.
|
/// Path to the audio file to use as custom music for the credits.
|
||||||
/// Note: only applies when creditsType is set to "custom".
|
/// Note: only applies when creditsType is set to "custom".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string audio;
|
public string audio = string.Empty; // Explicitly declaring this for condition in NHGameOverManager
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the fade in and out for the credits music.
|
/// The length of the fade in and out for the credits music.
|
||||||
/// Note: only applies when creditsType is set to "custom".
|
/// Note: only applies when creditsType is set to "custom".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(1f)]
|
[DefaultValue(1f)] public float audioVolume = 1f;
|
||||||
public float audioVolume;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the credits music should loop.
|
/// Determines if the credits music should loop.
|
||||||
/// Note: only applies when creditsType is set to "custom".
|
/// Note: only applies when creditsType is set to "custom".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)] public bool audioLooping = false;
|
||||||
public bool audioLooping;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Duration of the credits scroll in seconds.
|
/// Duration of the credits scroll in seconds.
|
||||||
/// Note: only applies when creditsType is set to "custom".
|
/// Note: only applies when creditsType is set to "custom".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(120f)]
|
[DefaultValue(120f)] public float length = 120f;
|
||||||
public float length;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of credits that will run after the game over message is shown
|
/// The type of credits that will run after the game over message is shown
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user