do another pass on patches

This commit is contained in:
JohnCorby 2023-03-18 13:05:39 -07:00
parent 6ecdc3d7a1
commit 577472c21b
17 changed files with 82 additions and 91 deletions

View File

@ -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 <<LayerMask.NameToLayer("UI"));
__instance._camera.mainCamera.cullingMask &= ~(1 <<LayerMask.NameToLayer("HeadsUpDisplay"));
__instance._camera.mainCamera.cullingMask &= ~(1 <<LayerMask.NameToLayer("HelmetUVPass"));
__instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("UI"));
__instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("HeadsUpDisplay"));
__instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("HelmetUVPass"));
}
}
}

View File

@ -7,7 +7,7 @@ namespace NewHorizons.Patches.CameraPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(OWCamera.Awake))]
public static void OnOWCameraAwake(OWCamera __instance)
public static void OWCamera_Awake(OWCamera __instance)
{
if (Main.SystemDict.TryGetValue(Main.Instance.CurrentStarSystem, out var system) && system?.Config?.farClipPlaneOverride != 0f)
{

View File

@ -1,18 +1,14 @@
using HarmonyLib;
using NewHorizons.Utility;
using System;
namespace NewHorizons.Patches.CreditsScene
namespace NewHorizons.Patches.CreditsScenePatches
{
[HarmonyPatch(typeof(CreditsEntry))]
public static class CreditsEntryPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(CreditsEntry.SetContents))]
public static bool CreditsEntry_SetContents(CreditsEntry __instance, string[] __0)
public static bool CreditsEntry_SetContents(CreditsEntry __instance, string[] columnTexts)
{
var columnTexts = __0;
for (int i = 0; i < __instance._columns.Length; i++)
{
// Base method throws out of bounds exception sometimes (_columns length doesn't match columnTexts length)

View File

@ -1,7 +1,7 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.CreditsScene
namespace NewHorizons.Patches.CreditsScenePatches
{
[HarmonyPatch(typeof(Credits))]
public static class CreditsPatches

View File

@ -3,7 +3,7 @@ using UnityEngine;
namespace NewHorizons.Patches.DetectorPatches
{
[HarmonyPatch]
[HarmonyPatch(typeof(AlignToSurfaceFluidDetector))]
public static class AlignToSurfaceFluidDetectorPatches
{
[HarmonyReversePatch]
@ -14,7 +14,7 @@ namespace NewHorizons.Patches.DetectorPatches
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AlignToSurfaceFluidDetector), nameof(AlignToSurfaceFluidDetector.ManagedFixedUpdate))]
[HarmonyPatch(nameof(AlignToSurfaceFluidDetector.ManagedFixedUpdate))]
public static bool AlignToSurfaceFluidDetector_ManagedFixedUpdate(AlignToSurfaceFluidDetector __instance)
{
if (__instance._alignmentFluid is not RadialFluidVolume) return true;

View File

@ -3,7 +3,7 @@ using UnityEngine;
namespace NewHorizons.Patches.EchoesOfTheEyePatches
{
[HarmonyPatch]
[HarmonyPatch(typeof(VisionTorchItem))]
public static class VisionTorchItemPatches
{
// This is some dark magic
@ -15,7 +15,7 @@ namespace NewHorizons.Patches.EchoesOfTheEyePatches
// Make the vision torch droppable. In the base game you can only drop it if you're in the dream world.
[HarmonyPrefix]
[HarmonyPatch(typeof(VisionTorchItem), nameof(VisionTorchItem.DropItem))]
[HarmonyPatch(nameof(VisionTorchItem.DropItem))]
public static bool VisionTorchItem_DropItem(VisionTorchItem __instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget)
{
if (!Locator.GetDreamWorldController().IsInDream())

View File

@ -20,7 +20,7 @@ namespace NewHorizons.Patches.MapPatches
[HarmonyPostfix]
[HarmonyPatch(nameof(MapController.OnTargetReferenceFrame))]
public static void MapController_OnTargetReferenceFrame(MapController __instance, ReferenceFrame __0)
public static void MapController_OnTargetReferenceFrame(MapController __instance, ReferenceFrame referenceFrame)
{
// Locked onto map satellite just means it will move vertically up from the plane of the solar system
__instance._isLockedOntoMapSatellite = true;

View File

@ -10,6 +10,7 @@ namespace NewHorizons.Patches
public static void MeteorController_Suspend(MeteorController __instance)
{
// Meteors launch inactive because of prefab. So let's fix that.
// how tf does this work
__instance.gameObject.SetActive(true);
}
}

View File

@ -15,11 +15,10 @@ namespace NewHorizons.Patches.PlayerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerData.KnowsFrequency))]
public static bool OnPlayerDataKnowsFrequency(SignalFrequency __0, ref bool __result)
public static bool PlayerData_KnowsFrequency(SignalFrequency frequency, ref bool __result)
{
var freqString = SignalBuilder.GetCustomFrequencyName(__0);
if (freqString != null && freqString != "")
var freqString = SignalBuilder.GetCustomFrequencyName(frequency);
if (!string.IsNullOrEmpty(freqString))
{
__result = NewHorizonsData.KnowsFrequency(freqString);
return false;
@ -29,10 +28,10 @@ namespace NewHorizons.Patches.PlayerPatches
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerData.LearnFrequency))]
public static bool OnPlayerDataLearnFrequency(SignalFrequency __0)
public static bool PlayerData_LearnFrequency(SignalFrequency frequency)
{
var freqString = SignalBuilder.GetCustomFrequencyName(__0);
if (freqString != null && freqString != "")
var freqString = SignalBuilder.GetCustomFrequencyName(frequency);
if (!string.IsNullOrEmpty(freqString))
{
NewHorizonsData.LearnFrequency(freqString);
NewFrequencyAchievement.Earn();
@ -43,10 +42,10 @@ namespace NewHorizons.Patches.PlayerPatches
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerData.KnowsSignal))]
public static bool OnPlayerDataKnowsSignal(SignalName __0, ref bool __result)
public static bool PlayerData_KnowsSignal(SignalName signalName, ref bool __result)
{
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
if (customSignalName != null)
var customSignalName = SignalBuilder.GetCustomSignalName(signalName);
if (!string.IsNullOrEmpty(customSignalName))
{
__result = NewHorizonsData.KnowsSignal(customSignalName);
return false;
@ -56,10 +55,10 @@ namespace NewHorizons.Patches.PlayerPatches
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerData.LearnSignal))]
public static bool OnPlayerDataLearnSignal(SignalName __0)
public static bool PlayerData_LearnSignal(SignalName signalName)
{
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
if (customSignalName != null)
var customSignalName = SignalBuilder.GetCustomSignalName(signalName);
if (!string.IsNullOrEmpty(customSignalName))
{
if (!NewHorizonsData.KnowsSignal(customSignalName))
{
@ -75,7 +74,7 @@ namespace NewHorizons.Patches.PlayerPatches
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerData.KnowsMultipleFrequencies))]
public static bool OnPlayerDataKnowsMultipleFrequencies(ref bool __result)
public static bool PlayerData_KnowsMultipleFrequencies(ref bool __result)
{
if (NewHorizonsData.KnowsMultipleFrequencies())
{
@ -87,22 +86,19 @@ namespace NewHorizons.Patches.PlayerPatches
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerData.AddNewlyRevealedFactID))]
public static bool OnPlayerDataAddNewlyRevealedFactID(string __0)
public static bool PlayerData_AddNewlyRevealedFactID(string id)
{
if (ShipLogHandler.IsModdedFact(__0))
if (ShipLogHandler.IsModdedFact(id))
{
NewHorizonsData.AddNewlyRevealedFactID(__0);
NewHorizonsData.AddNewlyRevealedFactID(id);
return false;
}
else
{
return true;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))]
public static bool OnPlayerDataGetNewlyRevealedFactIDs(ref List<string> __result)
public static bool PlayerData_GetNewlyRevealedFactIDs_Prefix(ref List<string> __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<string> __result)
public static void PlayerData_GetNewlyRevealedFactIDs_Postfix(ref List<string> __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();
}
}
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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<QuantumPlanet>();
var quantumPlanet = bodyToVanish.gameObject.GetComponent<QuantumPlanet>();
if (quantumPlanet == null) return true;

View File

@ -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

View File

@ -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);
}

View File

@ -11,7 +11,11 @@ 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;
}
}