diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs
index a939a456..86cc9c2b 100644
--- a/NewHorizons/External/Configs/StarSystemConfig.cs
+++ b/NewHorizons/External/Configs/StarSystemConfig.cs
@@ -51,6 +51,16 @@ namespace NewHorizons.External.Configs
///
public bool startHere;
+ ///
+ /// Name of an existing AudioClip in the game that will play when travelling in space.
+ ///
+ public string travelAudioClip;
+
+ ///
+ /// Relative filepath to the .wav file to use as the audio. Mutually exclusive with travelAudioClip.
+ ///
+ public string travelAudioFilePath;
+
public class NomaiCoordinates
{
public int[] x;
diff --git a/NewHorizons/Handlers/SystemCreationHandler.cs b/NewHorizons/Handlers/SystemCreationHandler.cs
index 473cb372..f4c0ca99 100644
--- a/NewHorizons/Handlers/SystemCreationHandler.cs
+++ b/NewHorizons/Handlers/SystemCreationHandler.cs
@@ -26,6 +26,30 @@ namespace NewHorizons.Handlers
var timeLoopController = new GameObject("TimeLoopController");
timeLoopController.AddComponent();
}
+
+ AudioClip clip = null;
+ if (system.Config.travelAudioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName(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;
+ }
}
}
}
diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json
index 13ae6ecc..1a4076a5 100644
--- a/NewHorizons/Schemas/star_system_schema.json
+++ b/NewHorizons/Schemas/star_system_schema.json
@@ -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"