From d0c116201ba57db289ff5893d0d04e37547ae21b Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sun, 30 Jan 2022 00:43:08 -0800 Subject: [PATCH] fix TravelerToSignalName --- .../NPC/Patches/TravelerControllerPatches.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/QSB/Animation/NPC/Patches/TravelerControllerPatches.cs b/QSB/Animation/NPC/Patches/TravelerControllerPatches.cs index 13801cdb..aaae72ef 100644 --- a/QSB/Animation/NPC/Patches/TravelerControllerPatches.cs +++ b/QSB/Animation/NPC/Patches/TravelerControllerPatches.cs @@ -1,7 +1,6 @@ using HarmonyLib; using QSB.Patches; using QSB.Utility; -using System; using System.Linq; using UnityEngine; @@ -112,7 +111,7 @@ namespace QSB.Animation.NPC.Patches internal static class TravelerAudioManagerExtensions { /// bad, but works great - private static SignalName TravelerToSignalName(TravelerController traveler) + private static SignalName? TravelerToSignalName(TravelerController traveler) { var name = traveler.name; @@ -151,12 +150,17 @@ namespace QSB.Animation.NPC.Patches return SignalName.Traveler_Prisoner; } - throw new ArgumentOutOfRangeException(nameof(name), name, null); + return null; } internal static void StopTravelerAudio(this TravelerAudioManager manager, TravelerController traveler) { var signalName = TravelerToSignalName(traveler); + if (signalName == null) + { + return; + } + var signal = manager._signals.First(x => x.GetName() == signalName); signal.GetOWAudioSource().FadeOut(0.5f); @@ -165,6 +169,11 @@ namespace QSB.Animation.NPC.Patches internal static void PlayTravelerAudio(this TravelerAudioManager manager, TravelerController traveler, float audioDelay) { var signalName = TravelerToSignalName(traveler); + if (signalName == null) + { + return; + } + var signal = manager._signals.First(x => x.GetName() == signalName); manager._playAfterDelay = false;