Fix inactive signals being used with signalscope strongest signal method (#918)

## Bug fixes

- Fix inactive signals being used with signalscope strongest signal
method. This bug prevented some vanilla frequencies from showing up in
custom systems.
This commit is contained in:
xen-42 2024-07-11 19:22:54 -04:00 committed by GitHub
commit d4a50374e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,6 @@
using HarmonyLib; using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
@ -108,5 +110,12 @@ namespace NewHorizons.Patches
_mapSatellite = null; _mapSatellite = null;
_sunStation = null; _sunStation = null;
} }
[HarmonyPostfix]
[HarmonyPatch(nameof(Locator.GetAudioSignals))]
public static void Locator_GetAudioSignals(ref List<AudioSignal> __result)
{
__result = __result.Where(signal => signal.IsActive()).ToList();
}
} }
} }

View File

@ -11,6 +11,13 @@ namespace NewHorizons.Patches.SignalPatches
[HarmonyPatch(typeof(AudioSignal))] [HarmonyPatch(typeof(AudioSignal))]
public static class AudioSignalPatches public static class AudioSignalPatches
{ {
[HarmonyPostfix]
[HarmonyPatch(nameof(AudioSignal.IsActive))]
public static void AudioSignal_IsActive(AudioSignal __instance, ref bool __result)
{
__result = __result && __instance.gameObject.activeInHierarchy;
}
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(nameof(AudioSignal.SignalNameToString))] [HarmonyPatch(nameof(AudioSignal.SignalNameToString))]
public static bool AudioSignal_SignalNameToString(SignalName name, ref string __result) public static bool AudioSignal_SignalNameToString(SignalName name, ref string __result)