diff --git a/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs index 738f30f6..b2ed1ce1 100644 --- a/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/DayNightAudioVolumeBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.Components.Volumes; using NewHorizons.External.Modules.Volumes.VolumeInfos; +using NewHorizons.Utility; using NewHorizons.Utility.OuterWilds; using OWML.Common; using UnityEngine; @@ -21,6 +22,7 @@ namespace NewHorizons.Builder.Volumes audioVolume.nightAudio = info.nightAudio; audioVolume.modBehaviour = mod; audioVolume.volume = info.volume; + audioVolume.SetTrack(info.track.ConvertToOW()); var shape = go.AddComponent(); shape.radius = info.radius; diff --git a/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs b/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs index 709c31d5..77f8febb 100644 --- a/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs +++ b/NewHorizons/Components/Volumes/NHDayNightAudioVolume.cs @@ -16,6 +16,7 @@ namespace NewHorizons.Components.Volumes private OWAudioSource _daySource; private OWAudioSource _nightSource; + private OWAudioMixer.TrackName _track; private Transform _planetTransform; private Transform _sunTransform; @@ -63,6 +64,8 @@ namespace NewHorizons.Components.Volumes _daySource.spread = 180f; _daySource.dopplerLevel = 0f; _daySource.SetMaxVolume(volume); + _daySource.SetTrack(_track); + _daySource.loop = true; AudioUtilities.SetAudioClip(_daySource, dayAudio, modBehaviour); } @@ -77,6 +80,8 @@ namespace NewHorizons.Components.Volumes _nightSource.spread = 180f; _nightSource.dopplerLevel = 0f; _nightSource.SetMaxVolume(volume); + _nightSource.SetTrack(_track); + _nightSource.loop = true; AudioUtilities.SetAudioClip(_nightSource, nightAudio, modBehaviour); } } @@ -138,5 +143,12 @@ namespace NewHorizons.Components.Volumes { return Vector3.Angle(_planetTransform.position - Locator.GetPlayerTransform().position, Locator.GetPlayerTransform().position - _sunTransform.position) < dayWindow * 0.5f; } + + public void SetTrack(OWAudioMixer.TrackName track) + { + _track = track; + _nightSource?.SetTrack(track); + _daySource?.SetTrack(track); + } } } diff --git a/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs index 25f71870..1e6717ff 100644 --- a/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs +++ b/NewHorizons/External/Modules/Volumes/VolumeInfos/DayNightAudioVolumeInfo.cs @@ -1,3 +1,4 @@ +using NewHorizons.External.SerializableEnums; using Newtonsoft.Json; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -35,5 +36,11 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos [Range(0f, 1f)] [DefaultValue(1f)] public float volume = 1f; + + /// + /// The audio track of this audio volume. + /// Most of the time you'll use environment (the default) for sound effects and music for music. + /// + [DefaultValue("environment")] public NHAudioMixerTrackName track = NHAudioMixerTrackName.Environment; } }