diff --git a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs index 02e3a8be..c5c591e2 100644 --- a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs +++ b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs @@ -16,9 +16,9 @@ namespace NewHorizons.Patches.CameraPatches // These layers were left on because it doesnt come up in base game (Dreamworld is inactive, player is far away) __instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("DreamSimulation")); - __instance._camera.mainCamera.cullingMask &= ~(1 < __result) + public static bool PlayerData_GetNewlyRevealedFactIDs_Prefix(ref List __result) { var newHorizonsNewlyRevealedFactIDs = NewHorizonsData.GetNewlyRevealedFactIDs(); if (newHorizonsNewlyRevealedFactIDs != null) @@ -110,35 +106,30 @@ namespace NewHorizons.Patches.PlayerPatches __result = PlayerData._currentGameSave.newlyRevealedFactIDs.Concat(newHorizonsNewlyRevealedFactIDs).ToList(); return false; } - else - { - Logger.LogError("Newly Revealed Fact IDs is null!"); - return true; - } - } - - [HarmonyPrefix] - [HarmonyPatch(nameof(PlayerData.ClearNewlyRevealedFactIDs))] - public static bool OnPlayerDataClearNewlyRevealedFactIDs() - { - PlayerData._currentGameSave.newlyRevealedFactIDs.Clear(); - NewHorizonsData.ClearNewlyRevealedFactIDs(); - return false; - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(PlayerData.ResetGame))] - public static void OnPlayerDataResetGame() - { - NewHorizonsData.Reset(); + Logger.LogError("Newly Revealed Fact IDs is null!"); + return true; } [HarmonyPostfix] [HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))] - public static void PlayerData_GetNewlyRevealedFactIDs(ref List __result) + public static void PlayerData_GetNewlyRevealedFactIDs_Postfix(ref List __result) { - ShipLogManager manager = Locator.GetShipLogManager(); - __result = __result.Where(e => manager.GetFact(e) != null).ToList(); + var manager = Locator.GetShipLogManager(); + __result = __result.Where(id => manager.GetFact(id) != null).ToList(); + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(PlayerData.ClearNewlyRevealedFactIDs))] + public static void PlayerData_ClearNewlyRevealedFactIDs() + { + NewHorizonsData.ClearNewlyRevealedFactIDs(); + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(PlayerData.ResetGame))] + public static void PlayerData_ResetGame() + { + NewHorizonsData.Reset(); } } } diff --git a/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs b/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs index be44f036..7941299f 100644 --- a/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs +++ b/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs @@ -9,15 +9,15 @@ namespace NewHorizons.Patches.ShipLogPatches { [HarmonyPrefix] [HarmonyPatch(nameof(UIStyleManager.GetCuriosityColor))] - public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result) + public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName curiosityName, bool highlight, ref Color __result) { - if ((int)__0 < 7) + if ((int)curiosityName < 7) { return true; } else { - __result = RumorModeBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight); + __result = RumorModeBuilder.GetCuriosityColor(curiosityName, highlight, __instance._neutralColor, __instance._neutralHighlight); return false; } } diff --git a/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs b/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs index 5470d5f2..32318a5c 100644 --- a/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs +++ b/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs @@ -12,9 +12,9 @@ namespace NewHorizons.Patches.SignalPatches { [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.SignalNameToString))] - public static bool AudioSignal_SignalNameToString(SignalName __0, ref string __result) + public static bool AudioSignal_SignalNameToString(SignalName name, ref string __result) { - var customSignalName = SignalBuilder.GetCustomSignalName(__0); + var customSignalName = SignalBuilder.GetCustomSignalName(name); if (!string.IsNullOrEmpty(customSignalName)) { __result = TranslationHandler.GetTranslation(customSignalName, TranslationHandler.TextType.UI, false).ToUpper(); @@ -25,9 +25,9 @@ namespace NewHorizons.Patches.SignalPatches [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.FrequencyToIndex))] - public static bool AudioSignal_FrequencyToIndex(SignalFrequency __0, ref int __result) + public static bool AudioSignal_FrequencyToIndex(SignalFrequency frequency, out int __result) { - __result = __0 switch + __result = frequency switch { SignalFrequency.Default => 0, SignalFrequency.Traveler => 1, @@ -37,16 +37,16 @@ namespace NewHorizons.Patches.SignalPatches SignalFrequency.HideAndSeek => 5, SignalFrequency.Radio => 6, SignalFrequency.Statue => 7, - _ => (int)(Mathf.Log((float)__0) / Mathf.Log(2f)),// Frequencies are in powers of 2 + _ => (int)(Mathf.Log((float)frequency) / Mathf.Log(2f)),// Frequencies are in powers of 2 }; return false; } [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.IndexToFrequency))] - public static bool AudioSignal_IndexToFrequency(int __0, ref SignalFrequency __result) + public static bool AudioSignal_IndexToFrequency(int index, out SignalFrequency __result) { - __result = __0 switch + __result = index switch { 0 => SignalFrequency.Default, 1 => SignalFrequency.Traveler, @@ -56,16 +56,16 @@ namespace NewHorizons.Patches.SignalPatches 5 => SignalFrequency.HideAndSeek, 6 => SignalFrequency.Radio, 7 => SignalFrequency.Statue, - _ => (SignalFrequency)Math.Pow(2, __0), + _ => (SignalFrequency)Math.Pow(2, index), }; return false; } [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.FrequencyToString))] - public static bool AudioSignal_FrequencyToString(SignalFrequency __0, ref string __result) + public static bool AudioSignal_FrequencyToString(SignalFrequency frequency, ref string __result) { - var customName = SignalBuilder.GetCustomFrequencyName(__0); + var customName = SignalBuilder.GetCustomFrequencyName(frequency); if (!string.IsNullOrEmpty(customName)) { if (NewHorizonsData.KnowsFrequency(customName)) __result = TranslationHandler.GetTranslation(customName, TranslationHandler.TextType.UI, false).ToUpper(); diff --git a/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs b/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs index b6e241a4..6b401d45 100644 --- a/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs +++ b/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs @@ -15,9 +15,8 @@ namespace NewHorizons.Patches.SignalPatches [HarmonyPrefix] [HarmonyPatch(nameof(Signalscope.SwitchFrequencyFilter))] - public static bool Signalscope_SwitchFrequencyFilter(Signalscope __instance, int __0) + public static bool Signalscope_SwitchFrequencyFilter(Signalscope __instance, int increment) { - var increment = __0; var count = SignalBuilder.NumberOfFrequencies; __instance._frequencyFilterIndex += increment; __instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 0 : __instance._frequencyFilterIndex; diff --git a/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs b/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs index 08cd5d15..a5f33f20 100644 --- a/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs +++ b/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs @@ -9,7 +9,7 @@ namespace NewHorizons.Patches.ToolPatches // This is to stop the game throwing too many errors if the probe is destroyed by a blackhole [HarmonyPrefix] [HarmonyPatch(nameof(SurveyorProbe.IsLaunched))] - public static bool SurveyorProbe_IsLaunched(SurveyorProbe __instance, ref bool __result) + public static bool SurveyorProbe_IsLaunched(SurveyorProbe __instance, out bool __result) { __result = __instance?.gameObject?.activeSelf ?? false; return false; diff --git a/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs b/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs index 45564b50..3203e335 100644 --- a/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs +++ b/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs @@ -8,14 +8,14 @@ using System.Threading.Tasks; namespace NewHorizons.Patches.VolumePatches { - [HarmonyPatch] + [HarmonyPatch(typeof(DestructionVolume))] public static class DestructionVolumePatches { [HarmonyPrefix] - [HarmonyPatch(typeof(DestructionVolume), nameof(DestructionVolume.Vanish))] - public static bool DestructionVolume_Vanish(OWRigidbody __0) + [HarmonyPatch(nameof(DestructionVolume.Vanish))] + public static bool DestructionVolume_Vanish(OWRigidbody bodyToVanish) { - var quantumPlanet = __0.gameObject.GetComponent(); + var quantumPlanet = bodyToVanish.gameObject.GetComponent(); if (quantumPlanet == null) return true; diff --git a/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs b/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs index 21283d6e..f63bad81 100644 --- a/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs +++ b/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs @@ -8,7 +8,7 @@ namespace NewHorizons.Patches.VolumePatches { [HarmonyPrefix] [HarmonyPatch(typeof(SphericalFogWarpVolume), nameof(SphericalFogWarpVolume.IsProbeOnly))] - public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, ref bool __result) + public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, out bool __result) { __result = Mathf.Approximately(__instance._exitRadius / __instance._warpRadius, 2f); // Check the ratio between these to determine if seed, instead of just < 10 return false; @@ -16,7 +16,7 @@ namespace NewHorizons.Patches.VolumePatches [HarmonyPrefix] [HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.GetFogThickness))] - public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, ref float __result) + public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, out float __result) { if (__instance is InnerFogWarpVolume sph) __result = sph._exitRadius; else __result = 50; // 50f is hardcoded as the return value in the base game diff --git a/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs b/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs index 9afd44e9..af2cb69b 100644 --- a/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs +++ b/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs @@ -4,11 +4,11 @@ using UnityEngine; namespace NewHorizons.Patches.WarpPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(EyeCoordinatePromptTrigger))] public static class EyeCoordinatePromptTriggerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(EyeCoordinatePromptTrigger), nameof(EyeCoordinatePromptTrigger.Update))] + [HarmonyPatch(nameof(EyeCoordinatePromptTrigger.Update))] public static bool EyeCoordinatePromptTrigger_Update(EyeCoordinatePromptTrigger __instance) { var showPrompts = __instance._warpController.HasPower(); @@ -22,10 +22,10 @@ namespace NewHorizons.Patches.WarpPatches } [HarmonyPrefix] - [HarmonyPatch(typeof(EyeCoordinatePromptTrigger), nameof(EyeCoordinatePromptTrigger.OnExit))] - public static void EyeCoordinatePromptTrigger_OnExit(GameObject __0) + [HarmonyPatch(nameof(EyeCoordinatePromptTrigger.OnExit))] + public static void EyeCoordinatePromptTrigger_OnExit(GameObject hitObj) { - if (__0.CompareTag("PlayerDetector")) + if (hitObj.CompareTag("PlayerDetector")) { VesselCoordinatePromptHandler.SetPromptVisibility(false); } diff --git a/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs b/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs index f34b9785..38d1aa36 100644 --- a/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs +++ b/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs @@ -11,8 +11,12 @@ namespace NewHorizons.Patches.WarpPatches public static bool NomaiCoordinateInterface_SetPillarRaised(NomaiCoordinateInterface __instance, bool raised) { if (raised) - return !(!__instance._powered || __instance.CheckEyeCoordinates() && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" || __instance.CheckAllCoordinates(out string targetSystem) && Main.Instance.CurrentStarSystem != targetSystem); + return !( + !__instance._powered || + __instance.CheckEyeCoordinates() && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" || + __instance.CheckAllCoordinates(out var targetSystem) && Main.Instance.CurrentStarSystem != targetSystem + ); return true; } } -} +} \ No newline at end of file