Rearrange and clean up patches

This commit is contained in:
Nick 2023-03-18 13:30:22 -04:00
parent 80e5f0c15e
commit 6ecdc3d7a1
76 changed files with 1288 additions and 1225 deletions

View File

@ -4,11 +4,11 @@ using UnityEngine;
namespace NewHorizons.Patches.CameraPatches namespace NewHorizons.Patches.CameraPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(NomaiRemoteCamera))]
public static class NomaiRemoteCameraPatches public static class NomaiRemoteCameraPatches
{ {
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(NomaiRemoteCamera), nameof(NomaiRemoteCamera.Awake))] [HarmonyPatch(nameof(NomaiRemoteCamera.Awake))]
public static void NomaiRemoteCamera_Awake(NomaiRemoteCamera __instance) public static void NomaiRemoteCamera_Awake(NomaiRemoteCamera __instance)
{ {
// Ensures that if the player is visible from the remote camera they look normal // Ensures that if the player is visible from the remote camera they look normal

View File

@ -0,0 +1,32 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.CameraPatches
{
[HarmonyPatch(typeof(NomaiRemoteCameraPlatform))]
public static class NomaiRemoteCameraPlatformPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(NomaiRemoteCameraPlatform.IDToPlanetString))]
public static bool NomaiRemoteCameraPlatform_IDToPlanetString(NomaiRemoteCameraPlatform.ID id, out string __result)
{
__result = id switch
{
NomaiRemoteCameraPlatform.ID.None => "None",
NomaiRemoteCameraPlatform.ID.SunStation => UITextLibrary.GetString(UITextType.LocationSS),
NomaiRemoteCameraPlatform.ID.HGT_TimeLoop => UITextLibrary.GetString(UITextType.LocationTT),
NomaiRemoteCameraPlatform.ID.TH_Mine => UITextLibrary.GetString(UITextType.LocationTH),
NomaiRemoteCameraPlatform.ID.THM_EyeLocator => UITextLibrary.GetString(UITextType.LocationTHMoon),
NomaiRemoteCameraPlatform.ID.BH_Observatory or NomaiRemoteCameraPlatform.ID.BH_GravityCannon or NomaiRemoteCameraPlatform.ID.BH_QuantumFragment or NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge or NomaiRemoteCameraPlatform.ID.BH_NorthPole => UITextLibrary.GetString(UITextType.LocationBH),
NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1 or NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2 or NomaiRemoteCameraPlatform.ID.GD_StatueIsland => UITextLibrary.GetString(UITextType.LocationGD),
NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule => UITextLibrary.GetString(UITextType.LocationOPC_Module3),
NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule => UITextLibrary.GetString(UITextType.LocationOPC_Module2),
NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule => UITextLibrary.GetString(UITextType.LocationOPC_Module1),
NomaiRemoteCameraPlatform.ID.VM_Interior => UITextLibrary.GetString(UITextType.LocationBHMoon),
NomaiRemoteCameraPlatform.ID.HGT_TLE => UITextLibrary.GetString(UITextType.LocationCT),
_ => RemoteHandler.GetPlatformIDName(id),
};
return false;
}
}
}

View File

@ -2,11 +2,11 @@ using HarmonyLib;
namespace NewHorizons.Patches.CameraPatches namespace NewHorizons.Patches.CameraPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(OWCamera))]
public static class OWCameraPatch public static class OWCameraPatches
{ {
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(OWCamera), nameof(OWCamera.Awake))] [HarmonyPatch(nameof(OWCamera.Awake))]
public static void OnOWCameraAwake(OWCamera __instance) public static void OnOWCameraAwake(OWCamera __instance)
{ {
if (Main.SystemDict.TryGetValue(Main.Instance.CurrentStarSystem, out var system) && system?.Config?.farClipPlaneOverride != 0f) if (Main.SystemDict.TryGetValue(Main.Instance.CurrentStarSystem, out var system) && system?.Config?.farClipPlaneOverride != 0f)

View File

@ -0,0 +1,16 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.CameraPatches
{
[HarmonyPatch(typeof(ProbeCamera))]
public static class ProbeCameraPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(ProbeCamera.HasInterference))]
public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result)
{
__result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe()));
}
}
}

View File

@ -1,26 +0,0 @@
using HarmonyLib;
namespace NewHorizons.Patches;
[HarmonyPatch]
internal static class CharacterDialogueTreePatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.Awake))]
private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance)
{
GlobalMessenger<OWRigidbody>.AddListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.OnDestroy))]
private static void CharacterDialogueTree_OnDestroy(CharacterDialogueTree __instance)
{
GlobalMessenger<OWRigidbody>.RemoveListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint);
}
private static void OnAttachPlayerToPoint(this CharacterDialogueTree characterDialogueTree, OWRigidbody rigidbody)
{
characterDialogueTree.EndConversation();
}
}

View File

@ -4,11 +4,11 @@ using System;
namespace NewHorizons.Patches.CreditsScene namespace NewHorizons.Patches.CreditsScene
{ {
[HarmonyPatch] [HarmonyPatch(typeof(CreditsEntry))]
public static class CreditsEntryPatches public static class CreditsEntryPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(CreditsEntry), nameof(CreditsEntry.SetContents))] [HarmonyPatch(nameof(CreditsEntry.SetContents))]
public static bool CreditsEntry_SetContents(CreditsEntry __instance, string[] __0) public static bool CreditsEntry_SetContents(CreditsEntry __instance, string[] __0)
{ {
var columnTexts = __0; var columnTexts = __0;

View File

@ -3,11 +3,11 @@ using NewHorizons.Handlers;
namespace NewHorizons.Patches.CreditsScene namespace NewHorizons.Patches.CreditsScene
{ {
[HarmonyPatch] [HarmonyPatch(typeof(Credits))]
public static class CreditsPatches public static class CreditsPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(Credits), nameof(Credits.Start))] [HarmonyPatch(nameof(Credits.Start))]
public static void Credits_Start(Credits __instance) public static void Credits_Start(Credits __instance)
{ {
CreditsHandler.AddCredits(__instance); CreditsHandler.AddCredits(__instance);

View File

@ -0,0 +1,41 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches.DetectorPatches
{
[HarmonyPatch]
public static class AlignToSurfaceFluidDetectorPatches
{
[HarmonyReversePatch]
[HarmonyPatch(typeof(AsymmetricFluidDetector), nameof(AsymmetricFluidDetector.ManagedFixedUpdate))]
public static void AsymmetricFluidDetector_ManagedFixedUpdate(AsymmetricFluidDetector __instance)
{
// This is like doing base.FixedUpdate
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AlignToSurfaceFluidDetector), nameof(AlignToSurfaceFluidDetector.ManagedFixedUpdate))]
public static bool AlignToSurfaceFluidDetector_ManagedFixedUpdate(AlignToSurfaceFluidDetector __instance)
{
if (__instance._alignmentFluid is not RadialFluidVolume) return true;
// Mostly copy pasting from the AlignWithDirection class
AsymmetricFluidDetector_ManagedFixedUpdate(__instance);
if (__instance._inAlignmentFluid)
{
// Both in world space
var currentDirection = __instance._owRigidbody.transform.up;
var alignmentDirection = (__instance.transform.position - __instance._alignmentFluid.transform.position).normalized;
var degreesToTarget = Vector3.Angle(currentDirection, alignmentDirection);
var adjustedSlerpRate = Mathf.Clamp01(0.01f * degreesToTarget * Time.fixedDeltaTime);
Vector3 a = OWPhysics.FromToAngularVelocity(currentDirection, alignmentDirection);
__instance._owRigidbody.AddAngularVelocityChange(a * adjustedSlerpRate);
}
return false;
}
}
}

View File

@ -1,15 +1,15 @@
using HarmonyLib; using HarmonyLib;
namespace NewHorizons.Patches namespace NewHorizons.Patches.DetectorPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(PlayerFogWarpDetector))]
public static class PlayerFogWarpDetectorPatches public static class PlayerFogWarpDetectorPatches
{ {
// Morbius moment: they only let fog go away if there is a fog controller on the planet near you // Morbius moment: they only let fog go away if there is a fog controller on the planet near you
// However you can leave these volumes with fog on your screen, or have fog applied by a bramble node on a fogless planet // However you can leave these volumes with fog on your screen, or have fog applied by a bramble node on a fogless planet
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(PlayerFogWarpDetector), nameof(PlayerFogWarpDetector.LateUpdate))] [HarmonyPatch(nameof(PlayerFogWarpDetector.LateUpdate))]
public static void PlayerFogWarpDetector_LateUpdate(PlayerFogWarpDetector __instance) public static void PlayerFogWarpDetector_LateUpdate(PlayerFogWarpDetector __instance)
{ {
if (PlanetaryFogController.GetActiveFogSphere() == null) if (PlanetaryFogController.GetActiveFogSphere() == null)

View File

@ -1,17 +1,15 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Components;
using NewHorizons.OtherMods.AchievementsPlus;
using NewHorizons.OtherMods.AchievementsPlus.NH; using NewHorizons.OtherMods.AchievementsPlus.NH;
using System.Linq; using NewHorizons.OtherMods.AchievementsPlus;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches.DetectorPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(ProbeDestructionDetector))]
public static class AchievementPatches internal static class ProbeDestructionDetectorPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ProbeDestructionDetector), nameof(ProbeDestructionDetector.FixedUpdate))] [HarmonyPatch(nameof(ProbeDestructionDetector.FixedUpdate))]
public static bool ProbeDestructionDetector_FixedUpdate(ProbeDestructionDetector __instance) public static bool ProbeDestructionDetector_FixedUpdate(ProbeDestructionDetector __instance)
{ {
if (__instance._activeVolumes.Count > 0 && __instance._safetyVolumes.Count == 0) if (__instance._activeVolumes.Count > 0 && __instance._safetyVolumes.Count == 0)
@ -32,17 +30,5 @@ namespace NewHorizons.Patches
__instance.enabled = false; __instance.enabled = false;
return false; return false;
} }
[HarmonyPostfix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.StartConversation))]
public static void CharacterDialogueTree_StartConversation(CharacterDialogueTree __instance)
{
if (!AchievementHandler.Enabled) return;
if (__instance is NHCharacterDialogueTree)
{
TalkToFiveCharactersAchievement.OnTalkedToCharacter(__instance._characterName);
}
}
} }
} }

View File

@ -0,0 +1,41 @@
using HarmonyLib;
using NewHorizons.Components;
using NewHorizons.OtherMods.AchievementsPlus.NH;
using NewHorizons.OtherMods.AchievementsPlus;
namespace NewHorizons.Patches.DialoguePatches;
[HarmonyPatch(typeof(CharacterDialogueTree))]
public static class CharacterDialogueTreePatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(CharacterDialogueTree.Awake))]
private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance)
{
GlobalMessenger<OWRigidbody>.AddListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint);
}
[HarmonyPrefix]
[HarmonyPatch(nameof(CharacterDialogueTree.OnDestroy))]
private static void CharacterDialogueTree_OnDestroy(CharacterDialogueTree __instance)
{
GlobalMessenger<OWRigidbody>.RemoveListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint);
}
private static void OnAttachPlayerToPoint(this CharacterDialogueTree characterDialogueTree, OWRigidbody rigidbody)
{
characterDialogueTree.EndConversation();
}
[HarmonyPostfix]
[HarmonyPatch(nameof(CharacterDialogueTree.StartConversation))]
public static void CharacterDialogueTree_StartConversation(CharacterDialogueTree __instance)
{
if (!AchievementHandler.Enabled) return;
if (__instance is NHCharacterDialogueTree)
{
TalkToFiveCharactersAchievement.OnTalkedToCharacter(__instance._characterName);
}
}
}

View File

@ -1,19 +1,18 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Utility;
using System;
namespace NewHorizons.Patches namespace NewHorizons.Patches.DialoguePatches
{ {
/// <summary> [HarmonyPatch(typeof(RemoteDialogueTrigger))]
/// Should fix a bug where disabled a CharacterDialogueTree makes its related RemoteDialogueTriggers softlock your game
/// </summary>
[HarmonyPatch]
public static class RemoteDialogueTriggerPatches public static class RemoteDialogueTriggerPatches
{ {
private static bool _wasLastDialogueInactive = false; private static bool _wasLastDialogueInactive = false;
/// <summary>
/// Should fix a bug where disabled a CharacterDialogueTree makes its related RemoteDialogueTriggers softlock your game
/// </summary>
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(RemoteDialogueTrigger), nameof(RemoteDialogueTrigger.OnTriggerEnter))] [HarmonyPatch(nameof(RemoteDialogueTrigger.OnTriggerEnter))]
public static void RemoteDialogueTrigger_OnTriggerEnter(RemoteDialogueTrigger __instance) public static void RemoteDialogueTrigger_OnTriggerEnter(RemoteDialogueTrigger __instance)
{ {
if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue?.gameObject != null) if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue?.gameObject != null)
@ -27,7 +26,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(RemoteDialogueTrigger), nameof(RemoteDialogueTrigger.OnEndConversation))] [HarmonyPatch(nameof(RemoteDialogueTrigger.OnEndConversation))]
public static void RemoteDialogueTrigger_OnEndConversation(RemoteDialogueTrigger __instance) public static void RemoteDialogueTrigger_OnEndConversation(RemoteDialogueTrigger __instance)
{ {
if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue != null) if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue != null)

View File

@ -1,12 +1,12 @@
using HarmonyLib; using HarmonyLib;
namespace NewHorizons.Patches namespace NewHorizons.Patches.EchoesOfTheEyePatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(AutoSlideProjector))]
public class AutoSlideProjectorPatches public static class AutoSlideProjectorPatches
{ {
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(AutoSlideProjector), nameof(AutoSlideProjector.Play))] [HarmonyPatch(nameof(AutoSlideProjector.Play))]
public static void AutoSlideProjector_Play(AutoSlideProjector __instance) public static void AutoSlideProjector_Play(AutoSlideProjector __instance)
{ {
__instance._slideCollectionItem.enabled = true; __instance._slideCollectionItem.enabled = true;

View File

@ -1,33 +1,33 @@
using HarmonyLib; using HarmonyLib;
namespace NewHorizons.Patches namespace NewHorizons.Patches.EchoesOfTheEyePatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(CloakFieldController))]
public static class CloakPatches public static class CloakFieldControllerPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.FixedUpdate))] [HarmonyPatch(nameof(CloakFieldController.FixedUpdate))]
public static bool CloakFieldController_FixedUpdate(CloakFieldController __instance) public static bool CloakFieldController_FixedUpdate(CloakFieldController __instance)
{ {
return __instance != null && __instance._cloakSphereShape != null; return __instance != null && __instance._cloakSphereShape != null;
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isPlayerInsideCloak), MethodType.Getter)] [HarmonyPatch(nameof(CloakFieldController.isPlayerInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isPlayerInsideCloak(ref bool __result) public static void CloakFieldController_isPlayerInsideCloak(ref bool __result)
{ {
__result = __result || Components.CloakSectorController.isPlayerInside; __result = __result || Components.CloakSectorController.isPlayerInside;
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isProbeInsideCloak), MethodType.Getter)] [HarmonyPatch(nameof(CloakFieldController.isProbeInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isProbeInsideCloak(ref bool __result) public static void CloakFieldController_isProbeInsideCloak(ref bool __result)
{ {
__result = __result || Components.CloakSectorController.isProbeInside; __result = __result || Components.CloakSectorController.isProbeInside;
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isShipInsideCloak), MethodType.Getter)] [HarmonyPatch(nameof(CloakFieldController.isShipInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isShipInsideCloak(ref bool __result) public static void CloakFieldController_isShipInsideCloak(ref bool __result)
{ {
__result = __result || Components.CloakSectorController.isShipInside; __result = __result || Components.CloakSectorController.isShipInside;

View File

@ -0,0 +1,47 @@
using HarmonyLib;
using NewHorizons.Builder.Props;
using UnityEngine;
namespace NewHorizons.Patches.EchoesOfTheEyePatches
{
[HarmonyPatch(typeof(MindProjectorTrigger))]
public static class MindProjectorTriggerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(MindProjectorTrigger.OnTriggerVolumeEntry))]
public static bool MindProjectorTrigger_OnTriggerVolumeEntry(MindProjectorTrigger __instance, GameObject hitObj)
{
var t = hitObj.GetComponent<VisionTorchTarget>();
if (t != null) //(hitObj.CompareTag("PrisonerDetector"))
{
__instance._mindProjector.OnProjectionStart += t.onSlidesStart;
__instance._mindProjector.OnProjectionComplete += t.onSlidesComplete;
__instance._mindProjector.SetMindSlideCollection(t.slideCollection);
__instance.OnBeamStartHitPrisoner.Invoke();
__instance._mindProjector.Play(reset: true);
__instance._mindProjector.OnProjectionStart += __instance.OnProjectionStart;
__instance._mindProjector.OnProjectionComplete += __instance.OnProjectionComplete;
Locator.GetPlayerTransform().GetComponent<PlayerLockOnTargeting>().LockOn(hitObj.transform, Vector3.zero);
__instance._playerLockedOn = true;
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(MindProjectorTrigger.OnTriggerVolumeExit))]
private static bool MindProjectorTrigger_OnTriggerVolumeExit(MindProjectorTrigger __instance, GameObject hitObj)
{
var t = hitObj.GetComponent<VisionTorchTarget>();
if (t != null) //(hitObj.CompareTag("PrisonerDetector"))
{
__instance._mindProjector.OnProjectionStart -= t.onSlidesStart;
__instance._mindProjector.OnProjectionComplete -= t.onSlidesComplete;
}
return true;
}
}
}

View File

@ -0,0 +1,35 @@
using HarmonyLib;
namespace NewHorizons.Patches.EchoesOfTheEyePatches
{
[HarmonyPatch(typeof(MindSlideProjector))]
public static class MindSlideProjectionPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(MindSlideProjector), nameof(MindSlideProjector.SetMindSlideCollection))]
private static bool MindSlideProjector_SetMindSlideCollection(MindSlideProjector __instance, MindSlideCollection mindSlideCollection)
{
if (mindSlideCollection == null) return false;
if (__instance._mindSlideCollection == mindSlideCollection) return false;
// Original method didn't check if old _slideCollectionItem was null.
if (__instance._slideCollectionItem != null)
{
__instance._slideCollectionItem.onSlideTextureUpdated -= __instance.OnSlideTextureUpdated;
__instance._slideCollectionItem.onPlayBeatAudio -= __instance.OnPlayBeatAudio;
}
__instance._mindSlideCollection = mindSlideCollection;
__instance._defaultSlideDuration = mindSlideCollection.defaultSlideDuration;
__instance._slideCollectionItem = mindSlideCollection.slideCollectionContainer;
__instance._slideCollectionItem.onSlideTextureUpdated += __instance.OnSlideTextureUpdated;
__instance._slideCollectionItem.onPlayBeatAudio += __instance.OnPlayBeatAudio;
__instance._slideCollectionItem.Initialize();
__instance._slideCollectionItem.enabled = false;
return false;
}
}
}

View File

@ -1,12 +1,13 @@
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches
namespace NewHorizons.Patches.EchoesOfTheEyePatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(RaftController))]
public static class RaftPatches public static class RaftControllerPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(RaftController), nameof(RaftController.FixedUpdate))] [HarmonyPatch(nameof(RaftController.FixedUpdate))]
public static bool RaftController_FixedUpdate(RaftController __instance) public static bool RaftController_FixedUpdate(RaftController __instance)
{ {
// If it has a river fluid its a normal one and we don't do anything // If it has a river fluid its a normal one and we don't do anything
@ -18,7 +19,7 @@ namespace NewHorizons.Patches
return false; return false;
} }
bool playerInEffectsRange = __instance._playerInEffectsRange; bool playerInEffectsRange = __instance._playerInEffectsRange;
__instance._playerInEffectsRange = ((Locator.GetPlayerBody().GetPosition() - __instance._raftBody.GetPosition()).sqrMagnitude < 2500f); __instance._playerInEffectsRange = (Locator.GetPlayerBody().GetPosition() - __instance._raftBody.GetPosition()).sqrMagnitude < 2500f;
if (playerInEffectsRange && !__instance._playerInEffectsRange) if (playerInEffectsRange && !__instance._playerInEffectsRange)
{ {
__instance._effectsController.StopAllEffects(); __instance._effectsController.StopAllEffects();
@ -71,48 +72,5 @@ namespace NewHorizons.Patches
return false; return false;
} }
[HarmonyReversePatch]
[HarmonyPatch(typeof(AsymmetricFluidDetector), nameof(AsymmetricFluidDetector.ManagedFixedUpdate))]
public static void AsymmetricFluidDetector_ManagedFixedUpdate(AsymmetricFluidDetector __instance)
{
// This is like doing base.FixedUpdate
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AlignToSurfaceFluidDetector), nameof(AlignToSurfaceFluidDetector.ManagedFixedUpdate))]
public static bool AlignToSurfaceFluidDetector_ManagedFixedUpdate(AlignToSurfaceFluidDetector __instance)
{
if (__instance._alignmentFluid is not RadialFluidVolume) return true;
// Mostly copy pasting from the AlignWithDirection class
AsymmetricFluidDetector_ManagedFixedUpdate(__instance);
if (__instance._inAlignmentFluid)
{
// Both in world space
var currentDirection = __instance._owRigidbody.transform.up;
var alignmentDirection = (__instance.transform.position - __instance._alignmentFluid.transform.position).normalized;
var degreesToTarget = Vector3.Angle(currentDirection, alignmentDirection);
var adjustedSlerpRate = Mathf.Clamp01(0.01f * degreesToTarget * Time.fixedDeltaTime);
Vector3 a = OWPhysics.FromToAngularVelocity(currentDirection, alignmentDirection);
__instance._owRigidbody.AddAngularVelocityChange(a * adjustedSlerpRate);
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FluidVolume), nameof(FluidVolume.GetDepthAtPosition))]
public static bool FluidVolume_GetDepthAtPosition(FluidVolume __instance, ref float __result, Vector3 worldPosition)
{
if (__instance is not RadialFluidVolume radialFluidVolume) return true;
Vector3 vector = radialFluidVolume.transform.InverseTransformPoint(worldPosition);
__result = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z + vector.y * vector.y) - radialFluidVolume._radius;
return false;
}
} }
} }

View File

@ -0,0 +1,33 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches.EchoesOfTheEyePatches
{
[HarmonyPatch]
public static class VisionTorchItemPatches
{
// This is some dark magic
// this creates a method called base_DropItem that basically just calls OWItem.PickUpItem whenever it (VisionTorchItemPatches.base_PickUpItem) is called
[HarmonyReversePatch]
[HarmonyPatch(typeof(OWItem), nameof(OWItem.DropItem))]
private static void base_DropItem(OWItem instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget) { }
// 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))]
public static bool VisionTorchItem_DropItem(VisionTorchItem __instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget)
{
if (!Locator.GetDreamWorldController().IsInDream())
{
base_DropItem(__instance, position, normal, parent, sector, customDropTarget);
}
if (__instance._wasProjecting) __instance._mindProjectorTrigger.SetProjectorActive(false);
__instance.gameObject.GetComponent<Collider>().enabled = true;
return true;
}
}
}

View File

@ -1,53 +0,0 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class EyeOfTheUniversePatches
{
// Funny eye of the universe stuff
private static void OnLoadScene(OWScene scene)
{
if (scene == OWScene.SolarSystem && !Main.Instance.IsWarpingBackToEye)
{
PlayerData.SaveEyeCompletion();
// Switch to default just in case another mod warps back.
if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") Main.Instance._currentStarSystem = Main.Instance.DefaultStarSystem;
}
// Switch to eye just in case another mod warps there.
else if (scene == OWScene.EyeOfTheUniverse) Main.Instance._currentStarSystem = "EyeOfTheUniverse";
}
[HarmonyPrefix]
[HarmonyPatch(typeof(LoadManager), nameof(LoadManager.LoadSceneImmediate))]
public static void LoadManager_LoadSceneImmediate(OWScene scene) => OnLoadScene(scene);
[HarmonyPrefix]
[HarmonyPatch(typeof(LoadManager), nameof(LoadManager.StartAsyncSceneLoad))]
public static void LoadManager_StartAsyncSceneLoad(OWScene scene) => OnLoadScene(scene);
[HarmonyPrefix]
[HarmonyPatch(typeof(SubmitActionLoadScene), nameof(SubmitActionLoadScene.ConfirmSubmit))]
public static void SubmitActionLoadScene_ConfirmSubmit(SubmitActionLoadScene __instance)
{
// Title screen can warp you to eye and cause problems.
if (__instance._sceneToLoad == SubmitActionLoadScene.LoadableScenes.EYE)
{
Utility.Logger.LogWarning("Warping to solar system and then back to eye");
Main.Instance.IsWarpingBackToEye = true;
__instance._sceneToLoad = SubmitActionLoadScene.LoadableScenes.GAME;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EyeVortexTrigger), nameof(EyeVortexTrigger.OnEnterVortex))]
public static void EyeVortexTrigger_OnEnterVortex(EyeVortexTrigger __instance, GameObject hitObj)
{
if (!hitObj.CompareTag("PlayerDetector")) return;
__instance._tunnelObject.SetActive(true);
}
}
}

View File

@ -0,0 +1,17 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches.EyeScenePatches
{
[HarmonyPatch(typeof(EyeVortexTrigger))]
public static class EyeVortexTriggerPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(EyeVortexTrigger.OnEnterVortex))]
public static void EyeVortexTrigger_OnEnterVortex(EyeVortexTrigger __instance, GameObject hitObj)
{
if (!hitObj.CompareTag("PlayerDetector")) return;
__instance._tunnelObject.SetActive(true);
}
}
}

View File

@ -0,0 +1,29 @@
using HarmonyLib;
namespace NewHorizons.Patches.EyeScenePatches
{
[HarmonyPatch(typeof(LoadManager))]
public static class LoadManagerPatches
{
private static void OnLoadScene(OWScene scene)
{
if (scene == OWScene.SolarSystem && !Main.Instance.IsWarpingBackToEye)
{
PlayerData.SaveEyeCompletion();
// Switch to default just in case another mod warps back.
if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") Main.Instance._currentStarSystem = Main.Instance.DefaultStarSystem;
}
// Switch to eye just in case another mod warps there.
else if (scene == OWScene.EyeOfTheUniverse) Main.Instance._currentStarSystem = "EyeOfTheUniverse";
}
[HarmonyPrefix]
[HarmonyPatch(nameof(LoadManager.LoadSceneImmediate))]
public static void LoadManager_LoadSceneImmediate(OWScene scene) => OnLoadScene(scene);
[HarmonyPrefix]
[HarmonyPatch(nameof(LoadManager.StartAsyncSceneLoad))]
public static void LoadManager_StartAsyncSceneLoad(OWScene scene) => OnLoadScene(scene);
}
}

View File

@ -0,0 +1,21 @@
using HarmonyLib;
namespace NewHorizons.Patches.EyeScenePatches
{
[HarmonyPatch(typeof(SubmitActionLoadScene))]
public static class SubmitActionLoadScenePatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(SubmitActionLoadScene.ConfirmSubmit))]
public static void SubmitActionLoadScene_ConfirmSubmit(SubmitActionLoadScene __instance)
{
// Title screen can warp you to eye and cause problems.
if (__instance._sceneToLoad == SubmitActionLoadScene.LoadableScenes.EYE)
{
Utility.Logger.LogWarning("Warping to solar system and then back to eye");
Main.Instance.IsWarpingBackToEye = true;
__instance._sceneToLoad = SubmitActionLoadScene.LoadableScenes.GAME;
}
}
}
}

View File

@ -1,124 +0,0 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class HUDPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.Awake))]
public static void HUDMarker_Awake(HUDMarker __instance)
{
GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.AddListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.OnDestroy))]
public static void HUDMarker_OnDestroy(HUDMarker __instance)
{
GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.RemoveListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.Awake))]
public static void ProbeHUDMarker_Awake(ProbeHUDMarker __instance)
{
GlobalMessenger.AddListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("ProbeExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.OnDestroy))]
public static void ProbeHUDMarker_OnDestroy(ProbeHUDMarker __instance)
{
GlobalMessenger.RemoveListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("ProbeExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.Awake))]
public static void ShipHUDMarker_Awake(ShipHUDMarker __instance)
{
GlobalMessenger.AddListener("ShipEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("ShipExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.OnDestroy))]
public static void ShipHUDMarker_OnDestroy(ShipHUDMarker __instance)
{
GlobalMessenger.RemoveListener("ShipEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("ShipExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.RefreshOwnVisibility))]
public static bool ProbeHUDMarker_RefreshOwnVisibility(ProbeHUDMarker __instance)
{
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsProbeInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside == Locator.GetRingWorldController().isProbeInside;
bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isProbeInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isProbeInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsProbe();
bool isActive = __instance.gameObject.activeInHierarchy || __instance._isTLCDuplicate;
__instance._isVisible = isActive && !insideEYE && !insideQM && !__instance._translatorEquipped && !__instance._inConversation && __instance._launched && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideRW && insideIP && insideCloak && sameInterference;
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.RefreshOwnVisibility))]
public static bool ShipHUDMarker_RefreshOwnVisibility(ShipHUDMarker __instance)
{
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsShipInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside;
bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isShipInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isShipInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsShip();
__instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && !__instance._shipDestroyed && !__instance._playerInShip && PlayerState.HasPlayerEnteredShip() && __instance._isWearingHelmet && insideIP && insideCloak && sameInterference;
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogEntryHUDMarker), nameof(ShipLogEntryHUDMarker.RefreshOwnVisibility))]
public static bool ShipLogEntryHUDMarker_RefreshOwnVisibility(ShipLogEntryHUDMarker __instance)
{
bool hasEntryLocation = ShipLogEntryHUDMarker.s_entryLocation != null;
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && __instance._quantumMoon.IsPlayerInside();
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside && ShipLogEntryHUDMarker.s_entryLocationID == "IP_RING_WORLD";
bool insideIP = (hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField()) || !(Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak);
bool insideCloak = (hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField()) || !Components.CloakSectorController.isPlayerInside;
__instance._isVisible = (!insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && hasEntryLocation && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideIP && insideCloak);
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ProbeCamera), nameof(ProbeCamera.HasInterference))]
public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result)
{
__result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe()));
}
}
}

View File

@ -0,0 +1,28 @@
using HarmonyLib;
namespace NewHorizons.Patches.HUDPatches
{
[HarmonyPatch(typeof(HUDMarker))]
public static class HUDMarkerPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(HUDMarker.Awake))]
public static void HUDMarker_Awake(HUDMarker __instance)
{
GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.AddListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
}
[HarmonyPostfix]
[HarmonyPatch(nameof(HUDMarker.OnDestroy))]
public static void HUDMarker_OnDestroy(HUDMarker __instance)
{
GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.RemoveListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
}
}
}

View File

@ -0,0 +1,44 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.HUDPatches
{
[HarmonyPatch(typeof(ProbeHUDMarker))]
public static class ProbeHUDMarkerPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(ProbeHUDMarker.Awake))]
public static void ProbeHUDMarker_Awake(ProbeHUDMarker __instance)
{
GlobalMessenger.AddListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("ProbeExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(nameof(ProbeHUDMarker.OnDestroy))]
public static void ProbeHUDMarker_OnDestroy(ProbeHUDMarker __instance)
{
GlobalMessenger.RemoveListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("ProbeExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPrefix]
[HarmonyPatch(nameof(ProbeHUDMarker.RefreshOwnVisibility))]
public static bool ProbeHUDMarker_RefreshOwnVisibility(ProbeHUDMarker __instance)
{
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsProbeInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside == Locator.GetRingWorldController().isProbeInside;
bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isProbeInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isProbeInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsProbe();
bool isActive = __instance.gameObject.activeInHierarchy || __instance._isTLCDuplicate;
__instance._isVisible = isActive && !insideEYE && !insideQM && !__instance._translatorEquipped && !__instance._inConversation && __instance._launched && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideRW && insideIP && insideCloak && sameInterference;
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
}
}

View File

@ -0,0 +1,43 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.HUDPatches
{
[HarmonyPatch(typeof(ShipHUDMarker))]
public static class ShipHUDMarkerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipHUDMarker.RefreshOwnVisibility))]
public static bool ShipHUDMarker_RefreshOwnVisibility(ShipHUDMarker __instance)
{
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsShipInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside;
bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isShipInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isShipInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsShip();
__instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && !__instance._shipDestroyed && !__instance._playerInShip && PlayerState.HasPlayerEnteredShip() && __instance._isWearingHelmet && insideIP && insideCloak && sameInterference;
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(ShipHUDMarker.OnDestroy))]
public static void ShipHUDMarker_OnDestroy(ShipHUDMarker __instance)
{
GlobalMessenger.RemoveListener("ShipEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("ShipExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(nameof(ShipHUDMarker.Awake))]
public static void ShipHUDMarker_Awake(ShipHUDMarker __instance)
{
GlobalMessenger.AddListener("ShipEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("ShipExitCloakField", __instance.RefreshOwnVisibility);
}
}
}

View File

@ -0,0 +1,26 @@
using HarmonyLib;
namespace NewHorizons.Patches.HUDPatches
{
[HarmonyPatch(typeof(ShipLogEntryHUDMarker))]
public static class ShipLogEntryHUDMarkerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogEntryHUDMarker.RefreshOwnVisibility))]
public static bool ShipLogEntryHUDMarker_RefreshOwnVisibility(ShipLogEntryHUDMarker __instance)
{
bool hasEntryLocation = ShipLogEntryHUDMarker.s_entryLocation != null;
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && __instance._quantumMoon.IsPlayerInside();
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside && ShipLogEntryHUDMarker.s_entryLocationID == "IP_RING_WORLD";
bool insideIP = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !(Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak);
bool insideCloak = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !Components.CloakSectorController.isPlayerInside;
__instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && hasEntryLocation && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideIP && insideCloak;
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
}
}

View File

@ -2,7 +2,7 @@ using HarmonyLib;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(Locator))]
public static class LocatorPatches public static class LocatorPatches
{ {
public static AstroObject _attlerock; public static AstroObject _attlerock;
@ -13,7 +13,7 @@ namespace NewHorizons.Patches
public static AstroObject _sunStation; public static AstroObject _sunStation;
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(Locator), nameof(Locator.RegisterCloakFieldController))] [HarmonyPatch(nameof(Locator.RegisterCloakFieldController))]
public static bool Locator_RegisterCloakFieldController() public static bool Locator_RegisterCloakFieldController()
{ {
return Locator._cloakFieldController == null; return Locator._cloakFieldController == null;
@ -22,7 +22,7 @@ namespace NewHorizons.Patches
// Locator Fixes // Locator Fixes
// Vanilla doesn't register these AstroObjects for some reason. So here is a fix. // Vanilla doesn't register these AstroObjects for some reason. So here is a fix.
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(Locator), nameof(Locator.GetAstroObject))] [HarmonyPatch(nameof(Locator.GetAstroObject))]
public static bool Locator_GetAstroObject(AstroObject.Name astroObjectName, ref AstroObject __result) public static bool Locator_GetAstroObject(AstroObject.Name astroObjectName, ref AstroObject __result)
{ {
switch (astroObjectName) switch (astroObjectName)
@ -52,7 +52,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(Locator), nameof(Locator.RegisterAstroObject))] [HarmonyPatch(nameof(Locator.RegisterAstroObject))]
public static bool Locator_RegisterAstroObject(AstroObject astroObject) public static bool Locator_RegisterAstroObject(AstroObject astroObject)
{ {
if (astroObject.GetAstroObjectName() == AstroObject.Name.None) return false; if (astroObject.GetAstroObjectName() == AstroObject.Name.None) return false;
@ -98,7 +98,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(Locator), nameof(Locator.ClearReferences))] [HarmonyPatch(nameof(Locator.ClearReferences))]
public static void Locator_ClearReferences() public static void Locator_ClearReferences()
{ {
_attlerock = null; _attlerock = null;

View File

@ -0,0 +1,19 @@
using HarmonyLib;
using NewHorizons.Handlers;
using System;
using UnityEngine;
namespace NewHorizons.Patches.MapPatches
{
[HarmonyPatch(typeof(CanvasMapMarker))]
public static class CanvasMapMarkerPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(CanvasMapMarker.Init), new Type[] { typeof(Canvas), typeof(Transform), typeof(string) })]
[HarmonyPatch(nameof(CanvasMapMarker.SetLabel))]
public static void CanvasMapMarker_LocalizeLabel(CanvasMapMarker __instance)
{
__instance._label = TranslationHandler.GetTranslation(__instance._label, TranslationHandler.TextType.UI);
}
}
}

View File

@ -2,13 +2,13 @@ using HarmonyLib;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
namespace NewHorizons.Patches namespace NewHorizons.Patches.MapPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(MapController))]
public static class MapControllerPatches public static class MapControllerPatches
{ {
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(MapController), nameof(MapController.Awake))] [HarmonyPatch(nameof(MapController.Awake))]
public static void MapController_Awake(MapController __instance) public static void MapController_Awake(MapController __instance)
{ {
__instance._maxPanDistance = Mathf.Max(__instance._maxPanDistance, Main.FurthestOrbit * 1.5f); __instance._maxPanDistance = Mathf.Max(__instance._maxPanDistance, Main.FurthestOrbit * 1.5f);
@ -19,14 +19,15 @@ namespace NewHorizons.Patches
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(MapController), nameof(MapController.OnTargetReferenceFrame))] [HarmonyPatch(nameof(MapController.OnTargetReferenceFrame))]
public static void MapController_OnTargetReferenceFrame(MapController __instance, ReferenceFrame __0) public static void MapController_OnTargetReferenceFrame(MapController __instance, ReferenceFrame __0)
{ {
// Locked onto map satellite just means it will move vertically up from the plane of the solar system
__instance._isLockedOntoMapSatellite = true; __instance._isLockedOntoMapSatellite = true;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(MapController), nameof(MapController.MapInoperable))] [HarmonyPatch(nameof(MapController.MapInoperable))]
public static bool MapController_MapInoperable(MapController __instance, ref bool __result) public static bool MapController_MapInoperable(MapController __instance, ref bool __result)
{ {
if (SceneManager.GetActiveScene().name != "SolarSystem") return true; if (SceneManager.GetActiveScene().name != "SolarSystem") return true;
@ -44,12 +45,5 @@ namespace NewHorizons.Patches
return true; return true;
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(ReferenceFrameTracker), nameof(ReferenceFrameTracker.UntargetReferenceFrame), new System.Type[] { typeof(bool) })]
public static bool ReferenceFrameTracker_UntargetReferenceFrame(ReferenceFrameTracker __instance, bool playAudio)
{
return __instance != null && __instance._hasTarget && __instance._currentReferenceFrame != null;
}
} }
} }

View File

@ -1,15 +1,14 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using System;
using UnityEngine; namespace NewHorizons.Patches.MapPatches
namespace NewHorizons.Patches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(ReferenceFrame))]
public static class TranslationPatches public static class ReferenceFramePatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ReferenceFrame), nameof(ReferenceFrame.GetHUDDisplayName))] [HarmonyPatch(nameof(ReferenceFrame.GetHUDDisplayName))]
public static bool ReferenceFrame_GetHUDDisplayName(ReferenceFrame __instance, ref string __result) public static bool ReferenceFrame_GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
{ {
var ao = __instance.GetAstroObject(); var ao = __instance.GetAstroObject();
@ -35,19 +34,5 @@ namespace NewHorizons.Patches
return false; return false;
} }
[HarmonyPostfix]
[HarmonyPatch(typeof(CanvasMapMarker), nameof(CanvasMapMarker.Init), new Type[] { typeof(Canvas), typeof(Transform), typeof(string) })]
public static void CanvasMapMarker_Init(CanvasMapMarker __instance)
{
__instance._label = TranslationHandler.GetTranslation(__instance._label, TranslationHandler.TextType.UI);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CanvasMapMarker), nameof(CanvasMapMarker.SetLabel))]
public static void CanvasMapMarker_SetLabel(CanvasMapMarker __instance)
{
__instance._label = TranslationHandler.GetTranslation(__instance._label, TranslationHandler.TextType.UI);
}
} }
} }

View File

@ -0,0 +1,15 @@
using HarmonyLib;
namespace NewHorizons.Patches.MapPatches
{
[HarmonyPatch(typeof(ReferenceFrameTracker))]
public static class ReferenceFrameTrackerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ReferenceFrameTracker.UntargetReferenceFrame), new System.Type[] { typeof(bool) })]
public static bool ReferenceFrameTracker_UntargetReferenceFrame(ReferenceFrameTracker __instance, bool playAudio)
{
return __instance != null && __instance._hasTarget && __instance._currentReferenceFrame != null;
}
}
}

View File

@ -2,11 +2,11 @@ using HarmonyLib;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(MeteorController))]
public static class MeteorPatches public static class MeteorControllerPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(MeteorController), nameof(MeteorController.Suspend), new System.Type[0])] [HarmonyPatch(nameof(MeteorController.Suspend), new System.Type[0])]
public static void MeteorController_Suspend(MeteorController __instance) public static void MeteorController_Suspend(MeteorController __instance)
{ {
// Meteors launch inactive because of prefab. So let's fix that. // Meteors launch inactive because of prefab. So let's fix that.

View File

@ -1,20 +1,20 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.OtherMods.AchievementsPlus;
using NewHorizons.OtherMods.AchievementsPlus.NH;
using NewHorizons.Builder.Props; using NewHorizons.Builder.Props;
using NewHorizons.External; using NewHorizons.External;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.OtherMods.AchievementsPlus;
using NewHorizons.OtherMods.AchievementsPlus.NH;
using NewHorizons.Utility;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NewHorizons.Utility;
namespace NewHorizons.Patches namespace NewHorizons.Patches.PlayerPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(PlayerData))]
public static class PlayerDataPatches public static class PlayerDataPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.KnowsFrequency))] [HarmonyPatch(nameof(PlayerData.KnowsFrequency))]
public static bool OnPlayerDataKnowsFrequency(SignalFrequency __0, ref bool __result) public static bool OnPlayerDataKnowsFrequency(SignalFrequency __0, ref bool __result)
{ {
var freqString = SignalBuilder.GetCustomFrequencyName(__0); var freqString = SignalBuilder.GetCustomFrequencyName(__0);
@ -28,7 +28,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.LearnFrequency))] [HarmonyPatch(nameof(PlayerData.LearnFrequency))]
public static bool OnPlayerDataLearnFrequency(SignalFrequency __0) public static bool OnPlayerDataLearnFrequency(SignalFrequency __0)
{ {
var freqString = SignalBuilder.GetCustomFrequencyName(__0); var freqString = SignalBuilder.GetCustomFrequencyName(__0);
@ -42,7 +42,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.KnowsSignal))] [HarmonyPatch(nameof(PlayerData.KnowsSignal))]
public static bool OnPlayerDataKnowsSignal(SignalName __0, ref bool __result) public static bool OnPlayerDataKnowsSignal(SignalName __0, ref bool __result)
{ {
var customSignalName = SignalBuilder.GetCustomSignalName(__0); var customSignalName = SignalBuilder.GetCustomSignalName(__0);
@ -55,7 +55,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.LearnSignal))] [HarmonyPatch(nameof(PlayerData.LearnSignal))]
public static bool OnPlayerDataLearnSignal(SignalName __0) public static bool OnPlayerDataLearnSignal(SignalName __0)
{ {
var customSignalName = SignalBuilder.GetCustomSignalName(__0); var customSignalName = SignalBuilder.GetCustomSignalName(__0);
@ -74,7 +74,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.KnowsMultipleFrequencies))] [HarmonyPatch(nameof(PlayerData.KnowsMultipleFrequencies))]
public static bool OnPlayerDataKnowsMultipleFrequencies(ref bool __result) public static bool OnPlayerDataKnowsMultipleFrequencies(ref bool __result)
{ {
if (NewHorizonsData.KnowsMultipleFrequencies()) if (NewHorizonsData.KnowsMultipleFrequencies())
@ -86,7 +86,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.AddNewlyRevealedFactID))] [HarmonyPatch(nameof(PlayerData.AddNewlyRevealedFactID))]
public static bool OnPlayerDataAddNewlyRevealedFactID(string __0) public static bool OnPlayerDataAddNewlyRevealedFactID(string __0)
{ {
if (ShipLogHandler.IsModdedFact(__0)) if (ShipLogHandler.IsModdedFact(__0))
@ -101,7 +101,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.GetNewlyRevealedFactIDs))] [HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))]
public static bool OnPlayerDataGetNewlyRevealedFactIDs(ref List<string> __result) public static bool OnPlayerDataGetNewlyRevealedFactIDs(ref List<string> __result)
{ {
var newHorizonsNewlyRevealedFactIDs = NewHorizonsData.GetNewlyRevealedFactIDs(); var newHorizonsNewlyRevealedFactIDs = NewHorizonsData.GetNewlyRevealedFactIDs();
@ -118,7 +118,7 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.ClearNewlyRevealedFactIDs))] [HarmonyPatch(nameof(PlayerData.ClearNewlyRevealedFactIDs))]
public static bool OnPlayerDataClearNewlyRevealedFactIDs() public static bool OnPlayerDataClearNewlyRevealedFactIDs()
{ {
PlayerData._currentGameSave.newlyRevealedFactIDs.Clear(); PlayerData._currentGameSave.newlyRevealedFactIDs.Clear();
@ -127,14 +127,14 @@ namespace NewHorizons.Patches
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.ResetGame))] [HarmonyPatch(nameof(PlayerData.ResetGame))]
public static void OnPlayerDataResetGame() public static void OnPlayerDataResetGame()
{ {
NewHorizonsData.Reset(); NewHorizonsData.Reset();
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(PlayerData), nameof(PlayerData.GetNewlyRevealedFactIDs))] [HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))]
public static void PlayerData_GetNewlyRevealedFactIDs(ref List<string> __result) public static void PlayerData_GetNewlyRevealedFactIDs(ref List<string> __result)
{ {
ShipLogManager manager = Locator.GetShipLogManager(); ShipLogManager manager = Locator.GetShipLogManager();

View File

@ -1,12 +1,13 @@
using HarmonyLib; using HarmonyLib;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Patches
namespace NewHorizons.Patches.PlayerPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(PlayerSpawner))]
public static class PlayerSpawnerPatches public static class PlayerSpawnerPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerSpawner), nameof(PlayerSpawner.SpawnPlayer))] [HarmonyPatch(nameof(PlayerSpawner.SpawnPlayer))]
public static bool PlayerSpawner_SpawnPlayer(PlayerSpawner __instance) public static bool PlayerSpawner_SpawnPlayer(PlayerSpawner __instance)
{ {
if (Main.Instance.IsWarpingFromVessel || Main.Instance.DidWarpFromVessel) if (Main.Instance.IsWarpingFromVessel || Main.Instance.DidWarpFromVessel)

View File

@ -1,12 +1,12 @@
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches.PlayerPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(PlayerState))]
public static class PlayerStatePatches public static class PlayerStatePatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlayerState), nameof(PlayerState.CheckShipOutsideSolarSystem))] [HarmonyPatch(nameof(PlayerState.CheckShipOutsideSolarSystem))]
public static bool PlayerState_CheckShipOutsideSolarSystem(PlayerState __instance, ref bool __result) public static bool PlayerState_CheckShipOutsideSolarSystem(PlayerState __instance, ref bool __result)
{ {
if (PlayerState._inBrambleDimension) return false; if (PlayerState._inBrambleDimension) return false;

View File

@ -1,14 +0,0 @@
using HarmonyLib;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class ProbeLauncherPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ProbeLauncher), nameof(ProbeLauncher.UpdateOrbitalLaunchValues))]
public static bool ProbeLauncher_UpdateOrbitalLaunchValues(ProbeLauncher __instance)
{
return (Locator.GetPlayerRulesetDetector()?.GetPlanetoidRuleset()?.GetGravityVolume() != null);
}
}
}

View File

@ -0,0 +1,15 @@
using HarmonyLib;
namespace NewHorizons.Patches.ProxyPatches
{
[HarmonyPatch(typeof(ProxyBody))]
public static class ProxyBodyPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ProxyBody.IsObjectInSupernova))]
public static bool ProxyBody_IsObjectInSupernova(ProxyBody __instance)
{
return Locator.GetSunController() != null;
}
}
}

View File

@ -1,23 +1,15 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Components;
using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches.ProxyPatches
{ {
[HarmonyPatch] [HarmonyPatch]
public static class ProxyBodyPatches public static class ProxyPlanetPatches
{ {
[HarmonyPrefix] // To call the base method
[HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.IsObjectInSupernova))]
public static bool ProxyBody_IsObjectInSupernova(ProxyBody __instance)
{
return Locator.GetSunController() != null;
}
[HarmonyReversePatch] [HarmonyReversePatch]
[HarmonyPatch(typeof(ProxyPlanet), nameof(ProxyPlanet.Initialize))] [HarmonyPatch(typeof(ProxyPlanet), nameof(ProxyPlanet.Initialize))]
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]

View File

@ -0,0 +1,22 @@
using HarmonyLib;
namespace NewHorizons.Patches.ProxyPatches
{
[HarmonyPatch(typeof(SunProxyEffectController))]
public static class SunProxyEffectControllerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(SunProxyEffectController.UpdateScales))]
public static bool SunProxyEffectController_UpdateScales(SunProxyEffectController __instance)
{
return __instance != null && __instance._surface != null && __instance._fog != null && __instance._fogMaterial != null && __instance._solarFlareEmitter != null && __instance._atmosphere != null;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(SunProxyEffectController.UpdateAtmosphereRadii))]
public static bool SunProxyEffectController_UpdateAtmosphereRadii(SunProxyEffectController __instance)
{
return __instance != null && __instance.transform != null && __instance.transform.parent != null && __instance._atmosphereMaterial != null;
}
}
}

View File

@ -1,153 +0,0 @@
using HarmonyLib;
using NewHorizons.Components;
using NewHorizons.Handlers;
using UnityEngine;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public class RemotePatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(NomaiRemoteCameraPlatform), nameof(NomaiRemoteCameraPlatform.IDToPlanetString))]
public static bool NomaiRemoteCameraPlatform_IDToPlanetString(NomaiRemoteCameraPlatform.ID id, out string __result)
{
switch (id)
{
case NomaiRemoteCameraPlatform.ID.None:
__result = "None";
break;
case NomaiRemoteCameraPlatform.ID.SunStation:
__result = UITextLibrary.GetString(UITextType.LocationSS);
break;
case NomaiRemoteCameraPlatform.ID.HGT_TimeLoop:
__result = UITextLibrary.GetString(UITextType.LocationTT);
break;
case NomaiRemoteCameraPlatform.ID.TH_Mine:
__result = UITextLibrary.GetString(UITextType.LocationTH);
break;
case NomaiRemoteCameraPlatform.ID.THM_EyeLocator:
__result = UITextLibrary.GetString(UITextType.LocationTHMoon);
break;
case NomaiRemoteCameraPlatform.ID.BH_Observatory:
case NomaiRemoteCameraPlatform.ID.BH_GravityCannon:
case NomaiRemoteCameraPlatform.ID.BH_QuantumFragment:
case NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge:
case NomaiRemoteCameraPlatform.ID.BH_NorthPole:
__result = UITextLibrary.GetString(UITextType.LocationBH);
break;
case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1:
case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2:
case NomaiRemoteCameraPlatform.ID.GD_StatueIsland:
__result = UITextLibrary.GetString(UITextType.LocationGD);
break;
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule:
__result = UITextLibrary.GetString(UITextType.LocationOPC_Module3);
break;
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule:
__result = UITextLibrary.GetString(UITextType.LocationOPC_Module2);
break;
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule:
__result = UITextLibrary.GetString(UITextType.LocationOPC_Module1);
break;
case NomaiRemoteCameraPlatform.ID.VM_Interior:
__result = UITextLibrary.GetString(UITextType.LocationBHMoon);
break;
case NomaiRemoteCameraPlatform.ID.HGT_TLE:
__result = UITextLibrary.GetString(UITextType.LocationCT);
break;
default:
__result = RemoteHandler.GetPlatformIDName(id);
break;
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(NomaiRemoteCameraStreaming), nameof(NomaiRemoteCameraStreaming.NomaiRemoteCameraPlatformIDToSceneName))]
public static bool NomaiRemoteCameraStreaming_NomaiRemoteCameraPlatformIDToSceneName(NomaiRemoteCameraPlatform.ID id, out string __result)
{
switch (id)
{
case NomaiRemoteCameraPlatform.ID.SunStation:
__result = "SolarSystem";
break;
case NomaiRemoteCameraPlatform.ID.HGT_TimeLoop:
case NomaiRemoteCameraPlatform.ID.HGT_TLE:
__result = "HourglassTwins";
break;
case NomaiRemoteCameraPlatform.ID.TH_Mine:
case NomaiRemoteCameraPlatform.ID.THM_EyeLocator:
__result = "TimberHearth";
break;
case NomaiRemoteCameraPlatform.ID.BH_Observatory:
case NomaiRemoteCameraPlatform.ID.BH_GravityCannon:
case NomaiRemoteCameraPlatform.ID.BH_QuantumFragment:
case NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge:
case NomaiRemoteCameraPlatform.ID.BH_NorthPole:
case NomaiRemoteCameraPlatform.ID.VM_Interior:
__result = "BrittleHollow";
break;
case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1:
case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2:
case NomaiRemoteCameraPlatform.ID.GD_StatueIsland:
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule:
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule:
case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule:
__result = "GiantsDeep";
break;
case NomaiRemoteCameraPlatform.ID.None:
__result = "";
break;
default:
var key = RemoteHandler.GetPlatformIDKey(id);
var _ = key.IndexOf("_");
switch ((_ == -1) ? key : key.Substring(0, _))
{
case "SS":
__result = "SolarSystem";
break;
case "HGT":
case "CT":
case "TT":
__result = "HourglassTwins";
break;
case "CO":
__result = "Comet";
break;
case "QM":
__result = "QuantumMoon";
break;
case "GD":
__result = "GiantsDeep";
break;
case "BH":
case "VM":
__result = "BrittleHollow";
break;
case "TH":
case "THM":
__result = "TimberHearth";
break;
case "DB":
__result = "DarkBramble";
break;
case "WH":
__result = "WhiteHole";
break;
case "RW":
__result = "RingWorld";
break;
case "DW":
__result = "DreamWorld";
break;
default:
__result = key;
break;
}
break;
}
return false;
}
}
}

View File

@ -3,11 +3,11 @@ using System.Collections.Generic;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(ShapeManager))]
public class ShapePatches public class ShapeManagerPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ShapeManager), nameof(ShapeManager.Initialize))] [HarmonyPatch(nameof(ShapeManager.Initialize))]
public static bool ShapeManager_Initialize() public static bool ShapeManager_Initialize()
{ {
ShapeManager._exists = true; ShapeManager._exists = true;

View File

@ -1,254 +0,0 @@
using HarmonyLib;
using NewHorizons.OtherMods.AchievementsPlus;
using NewHorizons.Builder.ShipLog;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
using Object = UnityEngine.Object;
using NewHorizons.Components.ShipLog;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class ShipLogPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.Awake))]
public static void ShipLogManager_Awake_Prefix(ShipLogManager __instance)
{
if (Main.Instance.IsWarpingBackToEye) return;
RumorModeBuilder.Init();
ShipLogHandler.Init();
var currentStarSystem = Main.Instance.CurrentStarSystem;
if (!Main.SystemDict.ContainsKey(currentStarSystem) || !Main.BodyDict.ContainsKey(currentStarSystem))
{
currentStarSystem = Main.Instance.DefaultStarSystem;
}
Logger.Log($"Beginning Ship Log Generation For: {currentStarSystem}");
if (currentStarSystem != "SolarSystem")
{
__instance._shipLogXmlAssets = new TextAsset[] { };
foreach (ShipLogEntryLocation logEntryLocation in GameObject.FindObjectsOfType<ShipLogEntryLocation>())
{
logEntryLocation._initialized = true;
}
}
var curiosities = Main.SystemDict[currentStarSystem].Config.curiosities;
if (curiosities != null)
{
RumorModeBuilder.AddCuriosityColors(curiosities);
}
foreach (NewHorizonsBody body in Main.BodyDict[currentStarSystem])
{
if (body.Config.ShipLog?.xmlFile != null)
{
RumorModeBuilder.AddBodyToShipLog(__instance, body);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.Awake))]
public static void ShipLogManager_Awake_Postfix(ShipLogManager __instance)
{
if (Main.Instance.IsWarpingBackToEye) return;
ShipLogHandler.CheckForModdedFacts(__instance);
RumorModeBuilder.GenerateEntryData(__instance);
for (var i = 0; i < __instance._entryList.Count; i++)
{
ShipLogEntry logEntry = __instance._entryList[i];
RumorModeBuilder.UpdateEntryCuriosity(ref logEntry);
}
Logger.Log($"Ship Log Generation Complete For: {Main.Instance.CurrentStarSystem}");
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.IsFactRevealed))]
public static bool ShipLogManager_IsFactRevealed(ShipLogManager __instance, ref bool __result, string __0)
{
if (__instance._factDict != null && __instance._factDict.ContainsKey(__0))
{
__result = __instance._factDict[__0].IsRevealed();
}
else
{
__result = false;
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.CheckForCompletionAchievement))]
public static bool ShipLogManager_CheckForCompletionAchievement(ShipLogManager __instance)
{
foreach (KeyValuePair<string, ShipLogFact> keyValuePair in __instance._factDict)
{
if (!ShipLogHandler.IsModdedFact(keyValuePair.Key) && !keyValuePair.Value.IsRumor() && !keyValuePair.Value.IsRevealed() && !keyValuePair.Key.Equals("TH_VILLAGE_X3") && !keyValuePair.Key.Equals("GD_GABBRO_ISLAND_X1") && __instance.GetEntry(keyValuePair.Value.GetEntryID()).GetCuriosityName() != CuriosityName.InvisiblePlanet)
{
return false;
}
}
Achievements.Earn(Achievements.Type.STUDIOUS);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.Start))]
public static bool ShipLogManager_Start(ShipLogManager __instance)
{
var initialReveal = Main.SystemDict[Main.Instance.CurrentStarSystem].Config.initialReveal ?? Array.Empty<string>();
foreach (string fact in initialReveal)
{
__instance.RevealFact(fact, false, false);
}
if (Main.Instance.CurrentStarSystem == "SolarSystem")
{
return true;
}
else
{
EntryLocationBuilder.InitializeLocations();
return false;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIStyleManager), nameof(UIStyleManager.GetCuriosityColor))]
public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result)
{
if ((int)__0 < 7)
{
return true;
}
else
{
__result = RumorModeBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight);
return false;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.Initialize))]
public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance)
{
GameObject panRoot = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH);
GameObject sunObject = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun");
ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer);
if (navMatrix == null || navMatrix.Length <= 1)
{
Logger.LogWarning("Skipping Map Mode Generation.");
}
else
{
__instance._astroObjects = navMatrix;
__instance._startingAstroObjectID = navMatrix[1][0].GetID();
if (Main.Instance.CurrentStarSystem != "SolarSystem")
{
List<GameObject> delete = panRoot.GetAllChildren().Where(g => g.name.Contains("_ShipLog") == false).ToList();
foreach (GameObject gameObject in delete)
{
Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
}
if (SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null)
{
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
}
}
}
Logger.Log("Map Mode Construction Complete");
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogAstroObject), nameof(ShipLogAstroObject.GetName))]
public static bool ShipLogAstroObject_GetName(ShipLogAstroObject __instance, ref string __result)
{
if (ShipLogHandler.IsVanillaAstroID(__instance.GetID()))
{
return true;
}
else
{
__result = MapModeBuilder.GetAstroBodyShipLogName(__instance.GetID());
return false;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipLogAstroObject), nameof(ShipLogAstroObject.UpdateState))]
public static void ShipLogAstroObject_UpdateState(ShipLogAstroObject __instance)
{
Transform detailsParent = __instance.transform.Find("Details");
if (detailsParent != null)
{
foreach (GameObject child in detailsParent.gameObject.GetAllChildren())
{
if (child.TryGetComponent(typeof(ShipLogDetail), out Component detail))
{
(detail as ShipLogDetail)?.UpdateState(__instance._state);
}
}
}
Transform lineObject = __instance.transform.Find("Line_ShipLog");
if (lineObject != null)
{
ShipLogDetail lineDetail = lineObject.gameObject.GetComponent<ShipLogDetail>();
lineDetail.UpdateState(__instance._state);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogSandFunnel), nameof(ShipLogSandFunnel.UpdateState))]
public static bool ShipLogSandFunnel_UpdateState()
{
return Main.Instance.CurrentStarSystem == "SolarSystem";
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogSandFunnel), nameof(ShipLogSandFunnel.Awake))]
public static bool ShipLogSandFunnel_Awake()
{
return Main.Instance.CurrentStarSystem == "SolarSystem";
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.RevealFact))]
public static void ShipLogManager_RevealFact(string __0)
{
StarChartHandler.OnRevealFact(__0);
AchievementHandler.OnRevealFact();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogFact), nameof(ShipLogFact.GetText))]
public static bool ShipLogFact_GetText(ShipLogFact __instance, ref string __result)
{
if (ShipLogHandler.IsModdedFact(__instance.GetID()))
{
__result = TranslationHandler.GetTranslation(__instance._text, TranslationHandler.TextType.SHIPLOG);
return false;
}
else
{
return true;
}
}
}
}

View File

@ -0,0 +1,52 @@
using HarmonyLib;
using NewHorizons.Builder.ShipLog;
using NewHorizons.Components.ShipLog;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Patches.ShipLogPatches
{
[HarmonyPatch(typeof(ShipLogAstroObject))]
public static class ShipLogAstroObjectPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogAstroObject.GetName))]
public static bool ShipLogAstroObject_GetName(ShipLogAstroObject __instance, ref string __result)
{
if (ShipLogHandler.IsVanillaAstroID(__instance.GetID()))
{
return true;
}
else
{
__result = MapModeBuilder.GetAstroBodyShipLogName(__instance.GetID());
return false;
}
}
[HarmonyPostfix]
[HarmonyPatch(nameof(ShipLogAstroObject.UpdateState))]
public static void ShipLogAstroObject_UpdateState(ShipLogAstroObject __instance)
{
Transform detailsParent = __instance.transform.Find("Details");
if (detailsParent != null)
{
foreach (GameObject child in detailsParent.gameObject.GetAllChildren())
{
if (child.TryGetComponent(typeof(ShipLogDetail), out Component detail))
{
(detail as ShipLogDetail)?.UpdateState(__instance._state);
}
}
}
Transform lineObject = __instance.transform.Find("Line_ShipLog");
if (lineObject != null)
{
ShipLogDetail lineDetail = lineObject.gameObject.GetComponent<ShipLogDetail>();
lineDetail.UpdateState(__instance._state);
}
}
}
}

View File

@ -0,0 +1,24 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.ShipLogPatches
{
[HarmonyPatch(typeof(ShipLogFact))]
public static class ShipLogFactPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogFact.GetText))]
public static bool ShipLogFact_GetText(ShipLogFact __instance, ref string __result)
{
if (ShipLogHandler.IsModdedFact(__instance.GetID()))
{
__result = TranslationHandler.GetTranslation(__instance._text, TranslationHandler.TextType.SHIPLOG);
return false;
}
else
{
return true;
}
}
}
}

View File

@ -0,0 +1,135 @@
using HarmonyLib;
using NewHorizons.Builder.ShipLog;
using NewHorizons.Handlers;
using NewHorizons.OtherMods.AchievementsPlus;
using NewHorizons.Utility;
using System.Collections.Generic;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Patches.ShipLogPatches
{
[HarmonyPatch(typeof(ShipLogManager))]
public static class ShipLogManagerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogManager.Awake))]
public static void ShipLogManager_Awake_Prefix(ShipLogManager __instance)
{
if (Main.Instance.IsWarpingBackToEye) return;
RumorModeBuilder.Init();
ShipLogHandler.Init();
var currentStarSystem = Main.Instance.CurrentStarSystem;
if (!Main.SystemDict.ContainsKey(currentStarSystem) || !Main.BodyDict.ContainsKey(currentStarSystem))
{
currentStarSystem = Main.Instance.DefaultStarSystem;
}
Logger.Log($"Beginning Ship Log Generation For: {currentStarSystem}");
if (currentStarSystem != "SolarSystem")
{
__instance._shipLogXmlAssets = new TextAsset[] { };
foreach (ShipLogEntryLocation logEntryLocation in Object.FindObjectsOfType<ShipLogEntryLocation>())
{
logEntryLocation._initialized = true;
}
}
var curiosities = Main.SystemDict[currentStarSystem].Config.curiosities;
if (curiosities != null)
{
RumorModeBuilder.AddCuriosityColors(curiosities);
}
foreach (NewHorizonsBody body in Main.BodyDict[currentStarSystem])
{
if (body.Config.ShipLog?.xmlFile != null)
{
RumorModeBuilder.AddBodyToShipLog(__instance, body);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(nameof(ShipLogManager.Awake))]
public static void ShipLogManager_Awake_Postfix(ShipLogManager __instance)
{
if (Main.Instance.IsWarpingBackToEye) return;
ShipLogHandler.CheckForModdedFacts(__instance);
RumorModeBuilder.GenerateEntryData(__instance);
for (var i = 0; i < __instance._entryList.Count; i++)
{
ShipLogEntry logEntry = __instance._entryList[i];
RumorModeBuilder.UpdateEntryCuriosity(ref logEntry);
}
Logger.Log($"Ship Log Generation Complete For: {Main.Instance.CurrentStarSystem}");
}
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogManager.IsFactRevealed))]
public static bool ShipLogManager_IsFactRevealed(ShipLogManager __instance, ref bool __result, string __0)
{
if (__instance._factDict != null && __instance._factDict.ContainsKey(__0))
{
__result = __instance._factDict[__0].IsRevealed();
}
else
{
__result = false;
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogManager.CheckForCompletionAchievement))]
public static bool ShipLogManager_CheckForCompletionAchievement(ShipLogManager __instance)
{
foreach (KeyValuePair<string, ShipLogFact> keyValuePair in __instance._factDict)
{
if (!ShipLogHandler.IsModdedFact(keyValuePair.Key) && !keyValuePair.Value.IsRumor() && !keyValuePair.Value.IsRevealed() && !keyValuePair.Key.Equals("TH_VILLAGE_X3") && !keyValuePair.Key.Equals("GD_GABBRO_ISLAND_X1") && __instance.GetEntry(keyValuePair.Value.GetEntryID()).GetCuriosityName() != CuriosityName.InvisiblePlanet)
{
return false;
}
}
Achievements.Earn(Achievements.Type.STUDIOUS);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogManager.Start))]
public static bool ShipLogManager_Start(ShipLogManager __instance)
{
var initialReveal = Main.SystemDict[Main.Instance.CurrentStarSystem].Config.initialReveal ?? System.Array.Empty<string>();
foreach (string fact in initialReveal)
{
__instance.RevealFact(fact, false, false);
}
if (Main.Instance.CurrentStarSystem == "SolarSystem")
{
return true;
}
else
{
EntryLocationBuilder.InitializeLocations();
return false;
}
}
[HarmonyPostfix]
[HarmonyPatch(nameof(ShipLogManager.RevealFact))]
public static void ShipLogManager_RevealFact(string __0)
{
StarChartHandler.OnRevealFact(__0);
AchievementHandler.OnRevealFact();
}
}
}

View File

@ -0,0 +1,47 @@
using HarmonyLib;
using NewHorizons.Builder.ShipLog;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Patches.ShipLogPatches
{
[HarmonyPatch(typeof(ShipLogMapMode))]
public static class ShipLogMapModePatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(ShipLogMapMode.Initialize))]
public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance)
{
GameObject panRoot = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH);
GameObject sunObject = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun");
ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer);
if (navMatrix == null || navMatrix.Length <= 1)
{
Logger.LogWarning("Skipping Map Mode Generation.");
}
else
{
__instance._astroObjects = navMatrix;
__instance._startingAstroObjectID = navMatrix[1][0].GetID();
if (Main.Instance.CurrentStarSystem != "SolarSystem")
{
List<GameObject> delete = panRoot.GetAllChildren().Where(g => g.name.Contains("_ShipLog") == false).ToList();
foreach (GameObject gameObject in delete)
{
Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
}
if (SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null)
{
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
}
}
}
Logger.Log("Map Mode Construction Complete");
}
}
}

View File

@ -0,0 +1,22 @@
using HarmonyLib;
namespace NewHorizons.Patches.ShipLogPatches
{
[HarmonyPatch(typeof(ShipLogSandFunnel))]
public static class ShipLogSandFunnelPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogSandFunnel.UpdateState))]
public static bool ShipLogSandFunnel_UpdateState()
{
return Main.Instance.CurrentStarSystem == "SolarSystem";
}
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogSandFunnel.Awake))]
public static bool ShipLogSandFunnel_Awake()
{
return Main.Instance.CurrentStarSystem == "SolarSystem";
}
}
}

View File

@ -0,0 +1,25 @@
using HarmonyLib;
using NewHorizons.Builder.ShipLog;
using UnityEngine;
namespace NewHorizons.Patches.ShipLogPatches
{
[HarmonyPatch(typeof(UIStyleManager))]
public static class UIStyleManagerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(UIStyleManager.GetCuriosityColor))]
public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result)
{
if ((int)__0 < 7)
{
return true;
}
else
{
__result = RumorModeBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight);
return false;
}
}
}
}

View File

@ -5,13 +5,13 @@ using NewHorizons.Handlers;
using System; using System;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches.SignalPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(AudioSignal))]
public static class AudioSignalPatches public static class AudioSignalPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.SignalNameToString))] [HarmonyPatch(nameof(AudioSignal.SignalNameToString))]
public static bool AudioSignal_SignalNameToString(SignalName __0, ref string __result) public static bool AudioSignal_SignalNameToString(SignalName __0, ref string __result)
{ {
var customSignalName = SignalBuilder.GetCustomSignalName(__0); var customSignalName = SignalBuilder.GetCustomSignalName(__0);
@ -24,83 +24,45 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.FrequencyToIndex))] [HarmonyPatch(nameof(AudioSignal.FrequencyToIndex))]
public static bool AudioSignal_FrequencyToIndex(SignalFrequency __0, ref int __result) public static bool AudioSignal_FrequencyToIndex(SignalFrequency __0, ref int __result)
{ {
switch (__0) __result = __0 switch
{ {
case (SignalFrequency.Default): SignalFrequency.Default => 0,
__result = 0; SignalFrequency.Traveler => 1,
break; SignalFrequency.Quantum => 2,
case (SignalFrequency.Traveler): SignalFrequency.EscapePod => 3,
__result = 1; SignalFrequency.WarpCore => 4,
break; SignalFrequency.HideAndSeek => 5,
case (SignalFrequency.Quantum): SignalFrequency.Radio => 6,
__result = 2; SignalFrequency.Statue => 7,
break; _ => (int)(Mathf.Log((float)__0) / Mathf.Log(2f)),// Frequencies are in powers of 2
case (SignalFrequency.EscapePod): };
__result = 3;
break;
case (SignalFrequency.WarpCore):
__result = 4;
break;
case (SignalFrequency.HideAndSeek):
__result = 5;
break;
case (SignalFrequency.Radio):
__result = 6;
break;
case (SignalFrequency.Statue):
__result = 7;
break;
default:
// Frequencies are in powers of 2
__result = (int)(Mathf.Log((float)__0) / Mathf.Log(2f));
break;
}
return false; return false;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.IndexToFrequency))] [HarmonyPatch(nameof(AudioSignal.IndexToFrequency))]
public static bool AudioSignal_IndexToFrequency(int __0, ref SignalFrequency __result) public static bool AudioSignal_IndexToFrequency(int __0, ref SignalFrequency __result)
{ {
switch (__0) __result = __0 switch
{ {
case 0: 0 => SignalFrequency.Default,
__result = SignalFrequency.Default; 1 => SignalFrequency.Traveler,
break; 2 => SignalFrequency.Quantum,
case 1: 3 => SignalFrequency.EscapePod,
__result = SignalFrequency.Traveler; 4 => SignalFrequency.WarpCore,
break; 5 => SignalFrequency.HideAndSeek,
case 2: 6 => SignalFrequency.Radio,
__result = SignalFrequency.Quantum; 7 => SignalFrequency.Statue,
break; _ => (SignalFrequency)Math.Pow(2, __0),
case 3: };
__result = SignalFrequency.EscapePod;
break;
case 4:
__result = SignalFrequency.WarpCore;
break;
case 5:
__result = SignalFrequency.HideAndSeek;
break;
case 6:
__result = SignalFrequency.Radio;
break;
case 7:
__result = SignalFrequency.Statue;
break;
default:
__result = (SignalFrequency)(Math.Pow(2, __0));
break;
}
return false; return false;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.FrequencyToString))] [HarmonyPatch(nameof(AudioSignal.FrequencyToString))]
public static bool AudioSignal_FrequencyToString(SignalFrequency __0, ref string __result) public static bool AudioSignal_FrequencyToString(SignalFrequency __0, ref string __result)
{ {
var customName = SignalBuilder.GetCustomFrequencyName(__0); var customName = SignalBuilder.GetCustomFrequencyName(__0);
@ -114,13 +76,13 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.UpdateSignalStrength))] [HarmonyPatch(nameof(AudioSignal.UpdateSignalStrength))]
public static bool AudioSignal_UpdateSignalStrength(AudioSignal __instance, Signalscope scope, float distToClosestScopeObstruction) public static bool AudioSignal_UpdateSignalStrength(AudioSignal __instance, Signalscope scope, float distToClosestScopeObstruction)
{ {
if (!SignalBuilder.Initialized) return true; if (!SignalBuilder.Initialized) return true;
var isCloaked = SignalBuilder.IsCloaked(__instance._name); var isCloaked = __instance._name.IsCloaked();
var isOnQuantumMoon = SignalBuilder.IsOnQuantumMoon(__instance._name); var isOnQuantumMoon = __instance._name.IsOnQuantumMoon();
if (!isCloaked && !isOnQuantumMoon) return true; if (!isCloaked && !isOnQuantumMoon) return true;
@ -213,12 +175,5 @@ namespace NewHorizons.Patches
return false; return false;
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(TravelerAudioManager), nameof(TravelerAudioManager.Update))]
public static void TravelerAudioManager_Update(TravelerAudioManager __instance)
{
__instance._signals.RemoveAll(signal => signal == null || signal.gameObject == null || signal._owAudioSource == null || signal._owAudioSource._audioSource == null);
}
} }
} }

View File

@ -1,33 +1,34 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Builder.Props; using NewHorizons.Builder.Props;
namespace NewHorizons.Patches
namespace NewHorizons.Patches.SignalPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(Signalscope))]
public static class SignalScopePatches public static class SignalScopePatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(Signalscope), nameof(Signalscope.Awake))] [HarmonyPatch(nameof(Signalscope.Awake))]
public static bool Signalscope_Awake(Signalscope __instance) public static void Signalscope_Awake(Signalscope __instance)
{ {
__instance._strongestSignals = new AudioSignal[8]; __instance._strongestSignals = new AudioSignal[8];
return true;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(Signalscope), nameof(Signalscope.SwitchFrequencyFilter))] [HarmonyPatch(nameof(Signalscope.SwitchFrequencyFilter))]
public static bool Signalscope_SwitchFrequencyFilter(Signalscope __instance, int __0) public static bool Signalscope_SwitchFrequencyFilter(Signalscope __instance, int __0)
{ {
var increment = __0; var increment = __0;
var count = SignalBuilder.NumberOfFrequencies; var count = SignalBuilder.NumberOfFrequencies;
__instance._frequencyFilterIndex += increment; __instance._frequencyFilterIndex += increment;
__instance._frequencyFilterIndex = ((__instance._frequencyFilterIndex >= count) ? 0 : __instance._frequencyFilterIndex); __instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 0 : __instance._frequencyFilterIndex;
__instance._frequencyFilterIndex = ((__instance._frequencyFilterIndex < 0) ? count - 1 : __instance._frequencyFilterIndex); __instance._frequencyFilterIndex = __instance._frequencyFilterIndex < 0 ? count - 1 : __instance._frequencyFilterIndex;
SignalFrequency signalFrequency = AudioSignal.IndexToFrequency(__instance._frequencyFilterIndex); SignalFrequency signalFrequency = AudioSignal.IndexToFrequency(__instance._frequencyFilterIndex);
if (!PlayerData.KnowsFrequency(signalFrequency) && (!__instance._isUnknownFreqNearby || __instance._unknownFrequency != signalFrequency)) if (!PlayerData.KnowsFrequency(signalFrequency) && (!__instance._isUnknownFreqNearby || __instance._unknownFrequency != signalFrequency))
{ {
__instance.SwitchFrequencyFilter(increment); __instance.SwitchFrequencyFilter(increment);
} }
return false; return false;
} }
} }

View File

@ -0,0 +1,15 @@
using HarmonyLib;
namespace NewHorizons.Patches.SignalPatches
{
[HarmonyPatch(typeof(TravelerAudioManager))]
public static class TravelerAudioManagerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(TravelerAudioManager.Update))]
public static void TravelerAudioManager_Update(TravelerAudioManager __instance)
{
__instance._signals.RemoveAll(signal => signal == null || signal.gameObject == null || signal._owAudioSource == null || signal._owAudioSource._audioSource == null);
}
}
}

View File

@ -1,51 +0,0 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class SingularityPatches
{
// For our custom black holes that don't link to anything
[HarmonyPrefix]
[HarmonyPatch(typeof(BlackHoleVolume), nameof(BlackHoleVolume.Start))]
public static bool BlackHoleVolume_Start(BlackHoleVolume __instance)
{
return __instance._whiteHole == null;
}
// To fix custom white holes
[HarmonyPrefix]
[HarmonyPatch(typeof(WhiteHoleVolume), nameof(WhiteHoleVolume.Awake))]
public static bool WhiteHoleVolume_Awake(WhiteHoleVolume __instance)
{
__instance._growQueue = new List<OWRigidbody>(8);
__instance._growQueueLocationData = new List<RelativeLocationData>(8);
__instance._ejectedBodyList = new List<OWRigidbody>(64);
try
{
__instance._whiteHoleBody = __instance.gameObject.GetAttachedOWRigidbody(false);
__instance._whiteHoleProxyShadowSuperGroup = __instance._whiteHoleBody.GetComponentInChildren<ProxyShadowCasterSuperGroup>();
__instance._fluidVolume = __instance.gameObject.GetRequiredComponent<WhiteHoleFluidVolume>();
}
catch (Exception) { }
return false;
}
// This is to stop the game throwing too many errors if the probe is destroyed by a blackhole
[HarmonyPrefix]
[HarmonyPatch(typeof(SurveyorProbe), nameof(SurveyorProbe.IsLaunched))]
public static bool SurveyorProbe_IsLaunched(SurveyorProbe __instance, ref bool __result)
{
try
{
__result = __instance.gameObject.activeSelf;
}
catch (Exception)
{
__result = true;
}
return false;
}
}
}

View File

@ -1,26 +0,0 @@
using HarmonyLib;
using NewHorizons.Handlers;
using OWML.Logging;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class StreamingPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(StreamingManager), nameof(StreamingManager.UnloadStreamingAssets))]
public static bool StreamingManager_UnloadStreamingAssets(string assetBundleName)
{
// Only let it unload stuff that isn't being used
return !StreamingHandler.IsBundleInUse(assetBundleName);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UnityLogger), "OnLogMessageReceived")]
public static bool UnityLogger_OnLogMessageReceived(string message)
{
// Filter out goofy error that doesn't actually break anything
return !message.EndsWith(") is out of bounds (size=0)");
}
}
}

View File

@ -0,0 +1,47 @@
using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.StreamingPatches
{
[HarmonyPatch(typeof(NomaiRemoteCameraStreaming))]
public class NomaiRemoteCameraStreamingPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(NomaiRemoteCameraStreaming.NomaiRemoteCameraPlatformIDToSceneName))]
public static bool NomaiRemoteCameraStreaming_NomaiRemoteCameraPlatformIDToSceneName(NomaiRemoteCameraPlatform.ID id, out string __result)
{
__result = id switch
{
NomaiRemoteCameraPlatform.ID.SunStation => "SolarSystem",
NomaiRemoteCameraPlatform.ID.HGT_TimeLoop or NomaiRemoteCameraPlatform.ID.HGT_TLE => "HourglassTwins",
NomaiRemoteCameraPlatform.ID.TH_Mine or NomaiRemoteCameraPlatform.ID.THM_EyeLocator => "TimberHearth",
NomaiRemoteCameraPlatform.ID.BH_Observatory or NomaiRemoteCameraPlatform.ID.BH_GravityCannon or NomaiRemoteCameraPlatform.ID.BH_QuantumFragment or NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge or NomaiRemoteCameraPlatform.ID.BH_NorthPole or NomaiRemoteCameraPlatform.ID.VM_Interior => "BrittleHollow",
NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1 or NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2 or NomaiRemoteCameraPlatform.ID.GD_StatueIsland or NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule or NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule or NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule => "GiantsDeep",
NomaiRemoteCameraPlatform.ID.None => "",
_ => PlatformKeyToSceneName(id),
};
return false;
}
private static string PlatformKeyToSceneName(NomaiRemoteCameraPlatform.ID id)
{
var key = RemoteHandler.GetPlatformIDKey(id);
var _ = key.IndexOf("_");
return (_ == -1 ? key : key.Substring(0, _)) switch
{
"SS" => "SolarSystem",
"HGT" or "CT" or "TT" => "HourglassTwins",
"CO" => "Comet",
"QM" => "QuantumMoon",
"GD" => "GiantsDeep",
"BH" or "VM" => "BrittleHollow",
"TH" or "THM" => "TimberHearth",
"DB" => "DarkBramble",
"WH" => "WhiteHole",
"RW" => "RingWorld",
"DW" => "DreamWorld",
_ => key,
};
}
}
}

View File

@ -0,0 +1,18 @@
using HarmonyLib;
using NewHorizons.Handlers;
using OWML.Logging;
namespace NewHorizons.Patches.StreamingPatches
{
[HarmonyPatch(typeof(StreamingManager))]
public static class StreamingManagerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(StreamingManager.UnloadStreamingAssets))]
public static bool StreamingManager_UnloadStreamingAssets(string assetBundleName)
{
// Only let it unload stuff that isn't being used
return !StreamingHandler.IsBundleInUse(assetBundleName);
}
}
}

View File

@ -0,0 +1,17 @@
using HarmonyLib;
using OWML.Logging;
namespace NewHorizons.Patches.StreamingPatches
{
[HarmonyPatch(typeof(UnityLogger))]
public static class UnityLoggerPatches
{
[HarmonyPrefix]
[HarmonyPatch("OnLogMessageReceived")]
public static bool UnityLogger_OnLogMessageReceived(string message)
{
// Filter out goofy error that doesn't actually break anything
return !message.EndsWith(") is out of bounds (size=0)");
}
}
}

View File

@ -1,65 +0,0 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class SunPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(SunLightParamUpdater), nameof(SunLightParamUpdater.LateUpdate))]
public static bool SunLightParamUpdater_LateUpdate(SunLightParamUpdater __instance)
{
if (__instance.sunLight)
{
Vector3 position = __instance.transform.position;
float w = 2000f;
if (__instance._sunController != null)
{
w = (__instance._sunController.HasSupernovaStarted() ? __instance._sunController.GetSupernovaRadius() : __instance._sunController.GetSurfaceRadius());
}
float range = __instance.sunLight.range;
Color color = (__instance._sunLightController != null) ? __instance._sunLightController.sunColor : __instance.sunLight.color;
float w2 = (__instance._sunLightController != null) ? __instance._sunLightController.sunIntensity : __instance.sunLight.intensity;
Shader.SetGlobalVector(__instance._propID_SunPosition, new Vector4(position.x, position.y, position.z, w));
Shader.SetGlobalVector(__instance._propID_OWSunPositionRange, new Vector4(position.x, position.y, position.z, 1f / (range * range)));
Shader.SetGlobalVector(__instance._propID_OWSunColorIntensity, new Vector4(color.r, color.g, color.b, w2));
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SunSurfaceAudioController), nameof(SunSurfaceAudioController.Update))]
public static bool SunSurfaceAudioController_Update(SunSurfaceAudioController __instance)
{
if (__instance._sunController != null) return true;
var surfaceRadius = __instance.transform.parent.parent.localScale.magnitude;
float value = Mathf.Max(0f, Vector3.Distance(Locator.GetPlayerCamera().transform.position, __instance.transform.position) - surfaceRadius);
float num = Mathf.InverseLerp(1600f, 100f, value);
__instance._audioSource.SetLocalVolume(num * num * __instance._fade);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateScales))]
public static bool SunProxyEffectController_UpdateScales(SunProxyEffectController __instance)
{
return __instance != null && __instance._surface != null && __instance._fog != null && __instance._fogMaterial != null && __instance._solarFlareEmitter != null && __instance._atmosphere != null;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateAtmosphereRadii))]
public static bool SunProxyEffectController_UpdateAtmosphereRadii(SunProxyEffectController __instance)
{
return __instance != null && __instance.transform != null && __instance.transform.parent != null && __instance._atmosphereMaterial != null;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(VanishVolume), nameof(VanishVolume.Shrink))]
public static bool VanishVolume_Shrink(VanishVolume __instance, OWRigidbody bodyToShrink)
{
return __instance != null && __instance.transform != null && __instance._shrinkingBodies != null && __instance._shrinkingBodyLocationData != null && bodyToShrink != null;
}
}
}

View File

@ -0,0 +1,18 @@
using HarmonyLib;
namespace NewHorizons.Patches.SunPatches
{
[HarmonyPatch(typeof(SunController))]
public static class SunControllerPatches
{
/// <summary>
/// Disables sun logic if no time loop
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(nameof(SunController.Update))]
[HarmonyPatch(nameof(SunController.UpdateScale))]
[HarmonyPatch(nameof(SunController.OnTriggerSupernova))]
public static bool SunController_DisableWithoutTimeLoop(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled;
}
}

View File

@ -0,0 +1,31 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches.SunPatches
{
[HarmonyPatch(typeof(SunLightParamUpdater))]
public static class SunLightParamUpdaterPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(SunLightParamUpdater), nameof(SunLightParamUpdater.LateUpdate))]
public static bool SunLightParamUpdater_LateUpdate(SunLightParamUpdater __instance)
{
if (__instance.sunLight)
{
Vector3 position = __instance.transform.position;
float w = 2000f;
if (__instance._sunController != null)
{
w = __instance._sunController.HasSupernovaStarted() ? __instance._sunController.GetSupernovaRadius() : __instance._sunController.GetSurfaceRadius();
}
float range = __instance.sunLight.range;
Color color = __instance._sunLightController != null ? __instance._sunLightController.sunColor : __instance.sunLight.color;
float w2 = __instance._sunLightController != null ? __instance._sunLightController.sunIntensity : __instance.sunLight.intensity;
Shader.SetGlobalVector(__instance._propID_SunPosition, new Vector4(position.x, position.y, position.z, w));
Shader.SetGlobalVector(__instance._propID_OWSunPositionRange, new Vector4(position.x, position.y, position.z, 1f / (range * range)));
Shader.SetGlobalVector(__instance._propID_OWSunColorIntensity, new Vector4(color.r, color.g, color.b, w2));
}
return false;
}
}
}

View File

@ -0,0 +1,22 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches.SunPatches
{
[HarmonyPatch(typeof(SunSurfaceAudioController))]
public static class SunSurfaceAudioControllerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(SunSurfaceAudioController.Update))]
public static bool SunSurfaceAudioController_Update(SunSurfaceAudioController __instance)
{
if (__instance._sunController != null) return true;
var surfaceRadius = __instance.transform.parent.parent.localScale.magnitude;
float value = Mathf.Max(0f, Vector3.Distance(Locator.GetPlayerCamera().transform.position, __instance.transform.position) - surfaceRadius);
float num = Mathf.InverseLerp(1600f, 100f, value);
__instance._audioSource.SetLocalVolume(num * num * __instance._fade);
return false;
}
}
}

View File

@ -6,52 +6,13 @@ namespace NewHorizons.Patches
public static class TimeLoopPatches public static class TimeLoopPatches
{ {
/// <summary> /// <summary>
/// Disables starfield updates /// Disable certain behaviours without timeloop
/// </summary> /// </summary>
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(StarfieldController), nameof(StarfieldController.Update))] [HarmonyPatch(typeof(StarfieldController), nameof(StarfieldController.Update))]
public static bool StarfieldController_Update() => Main.Instance.TimeLoopEnabled;
/// <summary>
/// Disables interloper destruction
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(typeof(TempCometCollisionFix), nameof(TempCometCollisionFix.Update))] [HarmonyPatch(typeof(TempCometCollisionFix), nameof(TempCometCollisionFix.Update))]
public static bool TempCometCollisionFix_Update() => Main.Instance.TimeLoopEnabled;
/// <summary>
/// Disables sun logic
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(typeof(SunController), nameof(SunController.Update))]
public static bool SunController_Update(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled;
/// <summary>
/// Disables sun expansion
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(typeof(SunController), nameof(SunController.UpdateScale))]
public static bool SunController_UpdateScale(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled;
/// <summary>
/// Disables sun collapse SFX
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(typeof(SunController), nameof(SunController.OnTriggerSupernova))]
public static bool SunController_OnTriggerSupernova(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled;
/// <summary>
/// Disables end times music
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(typeof(GlobalMusicController), nameof(GlobalMusicController.UpdateEndTimesMusic))] [HarmonyPatch(typeof(GlobalMusicController), nameof(GlobalMusicController.UpdateEndTimesMusic))]
public static bool GlobalMusicController_UpdateEndTimesMusic() => Main.Instance.TimeLoopEnabled;
/// <summary>
/// Disables supernova trigger
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(typeof(TimeLoop), nameof(TimeLoop.Update))] [HarmonyPatch(typeof(TimeLoop), nameof(TimeLoop.Update))]
public static bool TimeLoop_Update() => Main.Instance.TimeLoopEnabled; public static bool DisableWithoutTimeLoop() => Main.Instance.TimeLoopEnabled;
} }
} }

View File

@ -0,0 +1,15 @@
using HarmonyLib;
namespace NewHorizons.Patches.ToolPatches
{
[HarmonyPatch(typeof(ProbeLauncher))]
public static class ProbeLauncherPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(ProbeLauncher.UpdateOrbitalLaunchValues))]
public static bool ProbeLauncher_UpdateOrbitalLaunchValues(ProbeLauncher __instance)
{
return Locator.GetPlayerRulesetDetector()?.GetPlanetoidRuleset()?.GetGravityVolume() != null;
}
}
}

View File

@ -0,0 +1,18 @@
using HarmonyLib;
using System;
namespace NewHorizons.Patches.ToolPatches
{
[HarmonyPatch(typeof(SurveyorProbe))]
public static class SurveyorProbePatches
{
// 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)
{
__result = __instance?.gameObject?.activeSelf ?? false;
return false;
}
}
}

View File

@ -1,16 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib; using HarmonyLib;
namespace NewHorizons.Patches namespace NewHorizons.Patches.ToolPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(ToolModeSwapper))]
public static class ToolModeSwapperPatches public static class ToolModeSwapperPatches
{ {
// Patches ToolModeSwapper.EquipToolMode(ToolMode mode) to deny swaps if you're holding a vision torch. // Patches ToolModeSwapper.EquipToolMode(ToolMode mode) to deny swaps if you're holding a vision torch.
// This is critical for preventing swapping to the scout launcher (causes memory slides to fail) but it // This is critical for preventing swapping to the scout launcher (causes memory slides to fail) but it
// just doesn't look right when you switch to other stuff (eg the signalscope), so I'm disabling swapping tools entirely // just doesn't look right when you switch to other stuff (eg the signalscope), so I'm disabling swapping tools entirely
@ -19,7 +13,7 @@ namespace NewHorizons.Patches
// to include a check for "is holding vision torch", but I'm not copy/pasting an entire function, no sir // to include a check for "is holding vision torch", but I'm not copy/pasting an entire function, no sir
// if (((_currentToolMode == ToolMode.None || _currentToolMode == ToolMode.Item) && Locator.GetPlayerSuit().IsWearingSuit(includeTrainingSuit: false)) || ((_currentToolMode == ToolMode.None || _currentToolMode == ToolMode.SignalScope) && OWInput.IsInputMode(InputMode.ShipCockpit))) // if (((_currentToolMode == ToolMode.None || _currentToolMode == ToolMode.Item) && Locator.GetPlayerSuit().IsWearingSuit(includeTrainingSuit: false)) || ((_currentToolMode == ToolMode.None || _currentToolMode == ToolMode.SignalScope) && OWInput.IsInputMode(InputMode.ShipCockpit)))
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ToolModeSwapper), nameof(ToolModeSwapper.EquipToolMode))] [HarmonyPatch(nameof(ToolModeSwapper.EquipToolMode))]
public static bool ToolModeSwapper_EquipToolMode(ToolModeSwapper __instance, ToolMode mode) public static bool ToolModeSwapper_EquipToolMode(ToolModeSwapper __instance, ToolMode mode)
{ {
var isHoldingVisionTorch = __instance.GetItemCarryTool()?.GetHeldItemType() == ItemType.VisionTorch; var isHoldingVisionTorch = __instance.GetItemCarryTool()?.GetHeldItemType() == ItemType.VisionTorch;
@ -27,7 +21,7 @@ namespace NewHorizons.Patches
mode == ToolMode.Probe || mode == ToolMode.Probe ||
mode == ToolMode.SignalScope || mode == ToolMode.SignalScope ||
mode == ToolMode.Translator; mode == ToolMode.Translator;
var isInShip = UnityEngine.GameObject.FindObjectOfType<ShipCockpitController>()?._playerAtFlightConsole ?? false; var isInShip = UnityEngine.Object.FindObjectOfType<ShipCockpitController>()?._playerAtFlightConsole ?? false;
if (!isInShip && isHoldingVisionTorch && swappingToRestrictedTool) return false; if (!isInShip && isHoldingVisionTorch && swappingToRestrictedTool) return false;

View File

@ -1,108 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using NewHorizons.Builder.Props;
using UnityEngine;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class MindProjectorTriggerPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(MindProjectorTrigger), nameof(MindProjectorTrigger.OnTriggerVolumeEntry))]
public static bool MindProjectorTrigger_OnTriggerVolumeEntry(MindProjectorTrigger __instance, GameObject hitObj)
{
var t = hitObj.GetComponent<VisionTorchTarget>();
if (t != null) //(hitObj.CompareTag("PrisonerDetector"))
{
__instance._mindProjector.OnProjectionStart += t.onSlidesStart;
__instance._mindProjector.OnProjectionComplete += t.onSlidesComplete;
__instance._mindProjector.SetMindSlideCollection(t.slideCollection);
__instance.OnBeamStartHitPrisoner.Invoke();
__instance._mindProjector.Play(reset: true);
__instance._mindProjector.OnProjectionStart += __instance.OnProjectionStart;
__instance._mindProjector.OnProjectionComplete += __instance.OnProjectionComplete;
Locator.GetPlayerTransform().GetComponent<PlayerLockOnTargeting>().LockOn(hitObj.transform, Vector3.zero);
__instance._playerLockedOn = true;
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MindProjectorTrigger), nameof(MindProjectorTrigger.OnTriggerVolumeExit))]
private static bool MindProjectorTrigger_OnTriggerVolumeExit(MindProjectorTrigger __instance, GameObject hitObj)
{
var t = hitObj.GetComponent<VisionTorchTarget>();
if (t != null) //(hitObj.CompareTag("PrisonerDetector"))
{
__instance._mindProjector.OnProjectionStart -= t.onSlidesStart;
__instance._mindProjector.OnProjectionComplete -= t.onSlidesComplete;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MindSlideProjector), nameof(MindSlideProjector.SetMindSlideCollection))]
private static bool MindSlideProjector_SetMindSlideCollection(MindSlideProjector __instance, MindSlideCollection mindSlideCollection)
{
if (mindSlideCollection == null) return false;
if (__instance._mindSlideCollection == mindSlideCollection) return false;
// Original method didn't check if old _slideCollectionItem was null.
if (__instance._slideCollectionItem != null)
{
__instance._slideCollectionItem.onSlideTextureUpdated -= __instance.OnSlideTextureUpdated;
__instance._slideCollectionItem.onPlayBeatAudio -= __instance.OnPlayBeatAudio;
}
__instance._mindSlideCollection = mindSlideCollection;
__instance._defaultSlideDuration = mindSlideCollection.defaultSlideDuration;
__instance._slideCollectionItem = mindSlideCollection.slideCollectionContainer;
__instance._slideCollectionItem.onSlideTextureUpdated += __instance.OnSlideTextureUpdated;
__instance._slideCollectionItem.onPlayBeatAudio += __instance.OnPlayBeatAudio;
__instance._slideCollectionItem.Initialize();
__instance._slideCollectionItem.enabled = false;
return false;
}
}
[HarmonyPatch]
public static class VisionTorchItemPatches
{
// This is some dark magic
// this creates a method called base_DropItem that basically just calls OWItem.PickUpItem whenever it (VisionTorchItemPatches.base_PickUpItem) is called
[HarmonyReversePatch]
[HarmonyPatch(typeof(OWItem), nameof(OWItem.DropItem))]
private static void base_DropItem(OWItem instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget) { }
// 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))]
public static bool VisionTorchItem_DropItem(VisionTorchItem __instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget)
{
if (!Locator.GetDreamWorldController().IsInDream())
{
base_DropItem(__instance, position, normal, parent, sector, customDropTarget);
}
if (__instance._wasProjecting) __instance._mindProjectorTrigger.SetProjectorActive(false);
__instance.gameObject.GetComponent<Collider>().enabled = true;
return true;
}
}
}

View File

@ -0,0 +1,15 @@
using HarmonyLib;
namespace NewHorizons.Patches.VolumePatches
{
[HarmonyPatch(typeof(BlackHoleVolume))]
public static class BlackHoleVolumePatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(BlackHoleVolume.Start))]
public static bool BlackHoleVolume_Start(BlackHoleVolume __instance)
{
return __instance._whiteHole == null;
}
}
}

View File

@ -6,7 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NewHorizons.Patches namespace NewHorizons.Patches.VolumePatches
{ {
[HarmonyPatch] [HarmonyPatch]
public static class DestructionVolumePatches public static class DestructionVolumePatches

View File

@ -0,0 +1,20 @@
using HarmonyLib;
using UnityEngine;
namespace NewHorizons.Patches.VolumePatches
{
[HarmonyPatch(typeof(FluidVolume))]
public static class FluidVolumePatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(FluidVolume.GetDepthAtPosition))]
public static bool FluidVolume_GetDepthAtPosition(FluidVolume __instance, ref float __result, Vector3 worldPosition)
{
if (__instance is not RadialFluidVolume radialFluidVolume) return true;
Vector3 vector = radialFluidVolume.transform.InverseTransformPoint(worldPosition);
__result = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z + vector.y * vector.y) - radialFluidVolume._radius;
return false;
}
}
}

View File

@ -1,17 +1,11 @@
using HarmonyLib; using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches.VolumePatches
{ {
[HarmonyPatch] [HarmonyPatch]
public static class BramblePatches public static class FogWarpVolumePatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(SphericalFogWarpVolume), nameof(SphericalFogWarpVolume.IsProbeOnly))] [HarmonyPatch(typeof(SphericalFogWarpVolume), nameof(SphericalFogWarpVolume.IsProbeOnly))]
public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, ref bool __result) public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, ref bool __result)
@ -22,7 +16,7 @@ namespace NewHorizons.Patches
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.GetFogThickness))] [HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.GetFogThickness))]
public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, ref float __result) public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, ref float __result)
{ {
if (__instance is InnerFogWarpVolume sph) __result = sph._exitRadius; if (__instance is InnerFogWarpVolume sph) __result = sph._exitRadius;
else __result = 50; // 50f is hardcoded as the return value in the base game else __result = 50; // 50f is hardcoded as the return value in the base game

View File

@ -0,0 +1,15 @@
using HarmonyLib;
namespace NewHorizons.Patches.VolumePatches
{
[HarmonyPatch(typeof(VanishVolume))]
public static class VanishVolumePatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(VanishVolume.Shrink))]
public static bool VanishVolume_Shrink(VanishVolume __instance, OWRigidbody bodyToShrink)
{
return __instance != null && __instance.transform != null && __instance._shrinkingBodies != null && __instance._shrinkingBodyLocationData != null && bodyToShrink != null;
}
}
}

View File

@ -0,0 +1,28 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
namespace NewHorizons.Patches.VolumePatches
{
[HarmonyPatch(typeof(WhiteHoleVolume))]
public static class WhiteHoleVolumePatches
{
// To fix custom white holes
[HarmonyPrefix]
[HarmonyPatch(nameof(WhiteHoleVolume.Awake))]
public static bool WhiteHoleVolume_Awake(WhiteHoleVolume __instance)
{
__instance._growQueue = new List<OWRigidbody>(8);
__instance._growQueueLocationData = new List<RelativeLocationData>(8);
__instance._ejectedBodyList = new List<OWRigidbody>(64);
try
{
__instance._whiteHoleBody = __instance.gameObject.GetAttachedOWRigidbody(false);
__instance._whiteHoleProxyShadowSuperGroup = __instance._whiteHoleBody.GetComponentInChildren<ProxyShadowCasterSuperGroup>();
__instance._fluidVolume = __instance.gameObject.GetRequiredComponent<WhiteHoleFluidVolume>();
}
catch (Exception) { }
return false;
}
}
}

View File

@ -2,7 +2,7 @@ using HarmonyLib;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches.WarpPatches
{ {
[HarmonyPatch] [HarmonyPatch]
public static class EyeCoordinatePromptTriggerPatches public static class EyeCoordinatePromptTriggerPatches

View File

@ -0,0 +1,18 @@
using HarmonyLib;
using NewHorizons.Utility;
namespace NewHorizons.Patches.WarpPatches
{
[HarmonyPatch(typeof(NomaiCoordinateInterface))]
public static class NomaiCoordinateInterfacePatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(NomaiCoordinateInterface.SetPillarRaised), new System.Type[] { typeof(bool) })]
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 true;
}
}
}

View File

@ -1,14 +1,13 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility;
using UnityEngine; namespace NewHorizons.Patches.WarpPatches
namespace NewHorizons.Patches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(ShipCockpitController))]
public static class WarpDrivePatches public static class ShipCockpitControllerPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))] [HarmonyPatch(nameof(ShipCockpitController.Update))]
public static bool ShipCockpitController_Update(ShipCockpitController __instance) public static bool ShipCockpitController_Update(ShipCockpitController __instance)
{ {
if (!Main.HasWarpDrive) return true; if (!Main.HasWarpDrive) return true;

View File

@ -1,22 +1,13 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches.WarpPatches
{ {
[HarmonyPatch] [HarmonyPatch(typeof(VesselWarpController))]
public static class NomaiCoordinatePatches public static class VesselWarpControllerPatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(NomaiCoordinateInterface), nameof(NomaiCoordinateInterface.SetPillarRaised), new System.Type[] { typeof(bool) })] [HarmonyPatch(nameof(VesselWarpController.WarpVessel))]
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 true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(VesselWarpController), nameof(VesselWarpController.WarpVessel))]
public static bool VesselWarpController_WarpVessel(VesselWarpController __instance, bool debugWarp) public static bool VesselWarpController_WarpVessel(VesselWarpController __instance, bool debugWarp)
{ {
if (!Main.Instance.IsWarpingFromVessel && TimeLoop.GetLoopCount() < 2) if (!Main.Instance.IsWarpingFromVessel && TimeLoop.GetLoopCount() < 2)
@ -29,11 +20,12 @@ namespace NewHorizons.Patches
PlayerData.SaveWarpedToTheEye(TimeLoopUtilities.GetVanillaSecondsRemaining()); PlayerData.SaveWarpedToTheEye(TimeLoopUtilities.GetVanillaSecondsRemaining());
LoadManager.EnableAsyncLoadTransition(); LoadManager.EnableAsyncLoadTransition();
return false; return false;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(VesselWarpController), nameof(VesselWarpController.CheckSystemActivation))] [HarmonyPatch(nameof(VesselWarpController.CheckSystemActivation))]
public static void VesselWarpController_CheckSystemActivation(VesselWarpController __instance) public static void VesselWarpController_CheckSystemActivation(VesselWarpController __instance)
{ {
if (Locator.GetEyeStateManager() == null && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") if (Locator.GetEyeStateManager() == null && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse")
@ -46,19 +38,19 @@ namespace NewHorizons.Patches
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(VesselWarpController), nameof(VesselWarpController.OnSlotActivated))] [HarmonyPatch(nameof(VesselWarpController.OnSlotActivated))]
public static bool VesselWarpController_OnSlotActivated(VesselWarpController __instance, NomaiInterfaceSlot slot) public static bool VesselWarpController_OnSlotActivated(VesselWarpController __instance, NomaiInterfaceSlot slot)
{ {
bool canWarpToEye = __instance._coordinateInterface.CheckEyeCoordinates(); bool canWarpToEye = __instance._coordinateInterface.CheckEyeCoordinates();
bool canWarpToStarSystem = __instance._coordinateInterface.CheckAllCoordinates(out string targetSystem); bool canWarpToStarSystem = __instance._coordinateInterface.CheckAllCoordinates(out string targetSystem);
if (slot == __instance._warpVesselSlot && __instance._hasPower && ((canWarpToEye && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") || (canWarpToStarSystem && targetSystem != Main.Instance.CurrentStarSystem)) && __instance._blackHole.GetState() == SingularityController.State.Collapsed) if (slot == __instance._warpVesselSlot && __instance._hasPower && (canWarpToEye && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" || canWarpToStarSystem && targetSystem != Main.Instance.CurrentStarSystem) && __instance._blackHole.GetState() == SingularityController.State.Collapsed)
{ {
__instance._blackHole.Create(); __instance._blackHole.Create();
RumbleManager.StartVesselWarp(); RumbleManager.StartVesselWarp();
__instance._openingBlackHole = true; __instance._openingBlackHole = true;
__instance.enabled = true; __instance.enabled = true;
Locator.GetPauseCommandListener().AddPauseCommandLock(); Locator.GetPauseCommandListener().AddPauseCommandLock();
if (canWarpToEye || (canWarpToStarSystem && targetSystem == "EyeOfTheUniverse")) if (canWarpToEye || canWarpToStarSystem && targetSystem == "EyeOfTheUniverse")
{ {
Main.Instance._currentStarSystem = "EyeOfTheUniverse"; Main.Instance._currentStarSystem = "EyeOfTheUniverse";
LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, false, LoadManager.FadeType.ToWhite); LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, false, LoadManager.FadeType.ToWhite);