mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Give DayNightAudioVolume track setting, make them loop
This commit is contained in:
parent
37032ca222
commit
5908cc1fe6
@ -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<SphereShape>();
|
||||
shape.radius = info.radius;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// The audio track of this audio volume.
|
||||
/// Most of the time you'll use environment (the default) for sound effects and music for music.
|
||||
/// </summary>
|
||||
[DefaultValue("environment")] public NHAudioMixerTrackName track = NHAudioMixerTrackName.Environment;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user