mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Customizable Travel Audio (#31)
This commit is contained in:
parent
96e9294ef0
commit
c66804da55
10
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
10
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
@ -51,6 +51,16 @@ namespace NewHorizons.External.Configs
|
||||
/// </summary>
|
||||
public bool startHere;
|
||||
|
||||
/// <summary>
|
||||
/// Name of an existing AudioClip in the game that will play when travelling in space.
|
||||
/// </summary>
|
||||
public string travelAudioClip;
|
||||
|
||||
/// <summary>
|
||||
/// Relative filepath to the .wav file to use as the audio. Mutually exclusive with travelAudioClip.
|
||||
/// </summary>
|
||||
public string travelAudioFilePath;
|
||||
|
||||
public class NomaiCoordinates
|
||||
{
|
||||
public int[] x;
|
||||
|
||||
@ -26,6 +26,30 @@ namespace NewHorizons.Handlers
|
||||
var timeLoopController = new GameObject("TimeLoopController");
|
||||
timeLoopController.AddComponent<TimeLoopController>();
|
||||
}
|
||||
|
||||
AudioClip clip = null;
|
||||
if (system.Config.travelAudioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(system.Config.travelAudioClip);
|
||||
else if (system.Config.travelAudioFilePath != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
clip = AudioUtilities.LoadAudio(system.Mod.ModHelper.Manifest.ModFolderPath + "/" + system.Config.travelAudioFilePath);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Utility.Logger.LogError($"Couldn't load audio file {system.Config.travelAudioFilePath} : {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
if (clip != null)
|
||||
{
|
||||
var travelSource = Locator.GetGlobalMusicController()._travelSource;
|
||||
travelSource._audioLibraryClip = AudioType.None;
|
||||
travelSource._clipArrayIndex = 0;
|
||||
travelSource._clipArrayLength = 0;
|
||||
travelSource._clipSelectionOnPlay = OWAudioSource.ClipSelectionOnPlay.MANUAL;
|
||||
travelSource.clip = clip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,14 @@
|
||||
"type": "boolean",
|
||||
"description": "Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star\nsystem."
|
||||
},
|
||||
"travelAudioClip": {
|
||||
"type": "string",
|
||||
"description": "Name of an existing AudioClip in the game that will play when travelling in space."
|
||||
},
|
||||
"travelAudioFilePath": {
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the .wav file to use as the audio. Mutually exclusive with travelAudioClip."
|
||||
},
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"description": "The schema to validate with"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user