Use new audio setting method for signals, unify audioClip and audioFilePath

This commit is contained in:
Nick 2022-07-13 20:22:05 -04:00
parent 2a3ffcc268
commit 5a4f5ac207
2 changed files with 13 additions and 28 deletions

View File

@ -153,23 +153,6 @@ namespace NewHorizons.Builder.Props
var frequency = StringToFrequency(info.frequency);
var name = StringToSignalName(info.name);
AudioClip clip = null;
if (!string.IsNullOrEmpty(info.audioClip)) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(info.audioClip);
else if (!string.IsNullOrEmpty(info.audioFilePath))
{
try
{
clip = AudioUtilities.LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + info.audioFilePath);
}
catch { }
}
if (clip == null)
{
Logger.LogError($"Couldn't find AudioClip {info.audioClip} or AudioFile {info.audioFilePath}");
return null;
}
audioSignal.SetSector(sector);
if (name == SignalName.Default) audioSignal._preventIdentification = true;
@ -183,7 +166,6 @@ namespace NewHorizons.Builder.Props
audioSignal._canBePickedUpByScope = true;
audioSignal._outerFogWarpVolume = planetGO.GetComponentInChildren<OuterFogWarpVolume>(); // shouldn't break non-bramble signals
source.clip = clip;
source.loop = true;
source.minDistance = 0;
source.maxDistance = 30;
@ -201,6 +183,7 @@ namespace NewHorizons.Builder.Props
source.dopplerLevel = 0;
owAudioSource.SetTrack(OWAudioMixer.TrackName.Signal);
AudioUtilities.SetAudioClip(owAudioSource, info.audio, mod);
// Frequency detection trigger volume

View File

@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using NewHorizons.Utility;
using Newtonsoft.Json;
@ -16,16 +17,17 @@ namespace NewHorizons.External.Modules
[JsonObject]
public class SignalInfo
{
/// <summary>
/// Name of an existing AudioClip in the game that will player over the signal.
/// </summary>
[Obsolete("audioClip is deprecated, please use RemoveChildren instead")]
public string audioClip;
/// <summary>
/// Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip.
/// </summary>
[Obsolete("audioFilePath is deprecated, please use RemoveChildren instead")]
public string audioFilePath;
/// <summary>
/// The audio to use. Can be a path to a .wav or .ogg file, or taken from the AudioClip list.
/// </summary>
public string audio;
/// <summary>
/// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected"
/// notification.