diff --git a/NewHorizons/Builder/General/RFVolumeBuilder.cs b/NewHorizons/Builder/General/RFVolumeBuilder.cs index 3a0d6c67..42d6975c 100644 --- a/NewHorizons/Builder/General/RFVolumeBuilder.cs +++ b/NewHorizons/Builder/General/RFVolumeBuilder.cs @@ -18,14 +18,25 @@ namespace NewHorizons.Builder.General // This radius ends up being set by min and max collider radius on the RFV but we set it anyway because why fix what aint broke SC.radius = sphereOfInfluence * 2; - var RFV = rfGO.AddComponent(); + float targetDistance = module.maxTargetDistance; + + ReferenceFrameVolume RFV; + if (module.hideInMap) + { + var mapRFV = rfGO.AddComponent(); + mapRFV._defaultMaxTargetDistance = targetDistance; + mapRFV._mapMaxTargetDistance = 0.001f; // Setting to 0 makes it targetable at any distance, so lets make this as small as possible. + RFV = mapRFV; + } + else + RFV = rfGO.AddComponent(); var minTargetDistance = module.targetWhenClose ? 0 : sphereOfInfluence; var RV = new ReferenceFrame(owrb); RV._minSuitTargetDistance = minTargetDistance; // The game raycasts to 100km, but if the target is farther than this max distance it ignores it - RV._maxTargetDistance = module.maxTargetDistance; + RV._maxTargetDistance = targetDistance; RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence; RV._autoAlignmentDistance = sphereOfInfluence * 1.5f; @@ -55,7 +66,6 @@ namespace NewHorizons.Builder.General GameObject.Destroy(rfGO); return null; } - else rfGO.SetActive(!module.hideInMap); return rfGO; } diff --git a/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs index f20769ec..ed4bac8a 100644 --- a/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs @@ -21,10 +21,8 @@ namespace NewHorizons.Components.ShipLog private Vector2 _panRootPos = Vector2.zero; private Vector2 _startPanPos; - private ScreenPromptList _upperRightPromptList; private ScreenPromptList _centerPromptList; - private ScreenPrompt _detectiveModePrompt; private ScreenPrompt _targetSystemPrompt; private ScreenPrompt _warpPrompt = new ScreenPrompt(InputLibrary.autopilot, " Warp to system"); @@ -45,9 +43,7 @@ namespace NewHorizons.Components.ShipLog _oneShotSource = oneShotSource; _centerPromptList = centerPromptList; - _upperRightPromptList = upperRightPromptList; - _detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, UITextLibrary.GetString(UITextType.LogRumorModePrompt), 0, ScreenPrompt.DisplayState.Normal, false); _targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, TranslationHandler.GetTranslation("LOCK_AUTOPILOT_WARP", TranslationHandler.TextType.UI), 0, ScreenPrompt.DisplayState.Normal, false); GlobalMessenger.AddListener("TargetReferenceFrame", new Callback(OnTargetReferenceFrame)); @@ -169,7 +165,7 @@ namespace NewHorizons.Components.ShipLog { gameObject.SetActive(true); - Locator.GetPromptManager().AddScreenPrompt(_detectiveModePrompt, _upperRightPromptList, TextAnchor.MiddleRight, -1, true); + _oneShotSource.PlayOneShot(AudioType.ShipLogEnterMapMode); Locator.GetPromptManager().AddScreenPrompt(_targetSystemPrompt, _centerPromptList, TextAnchor.MiddleCenter, -1, true); } @@ -177,7 +173,6 @@ namespace NewHorizons.Components.ShipLog { gameObject.SetActive(false); - Locator.GetPromptManager().RemoveScreenPrompt(_detectiveModePrompt); Locator.GetPromptManager().RemoveScreenPrompt(_targetSystemPrompt); } diff --git a/NewHorizons/Handlers/StarChartHandler.cs b/NewHorizons/Handlers/StarChartHandler.cs index 8083e20e..e4942499 100644 --- a/NewHorizons/Handlers/StarChartHandler.cs +++ b/NewHorizons/Handlers/StarChartHandler.cs @@ -1,6 +1,7 @@ using NewHorizons.Components.ShipLog; using NewHorizons.Utility; using System.Collections.Generic; +using NewHorizons.OtherMods.CustomShipLogModes; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Handlers @@ -46,14 +47,7 @@ namespace NewHorizons.Handlers panRoot.transform.localPosition = Vector3.zero; panRoot.transform.localRotation = Quaternion.Euler(0, 0, 0); - var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent(); - var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent(); - var oneShotSource = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent(); - - ShipLogStarChartMode.Initialize( - centerPromptList, - upperRightPromptList, - oneShotSource); + CustomShipLogModesHandler.AddInterstellarMode(); } _starSystemToFactID = new Dictionary(); diff --git a/NewHorizons/OtherMods/CustomShipLogModes/CustomShipLogModesHandler.cs b/NewHorizons/OtherMods/CustomShipLogModes/CustomShipLogModesHandler.cs new file mode 100644 index 00000000..1ceed1eb --- /dev/null +++ b/NewHorizons/OtherMods/CustomShipLogModes/CustomShipLogModesHandler.cs @@ -0,0 +1,20 @@ +using NewHorizons.Handlers; + +namespace NewHorizons.OtherMods.CustomShipLogModes; + +public static class CustomShipLogModesHandler +{ + private static readonly ICustomShipLogModesAPI API; + + static CustomShipLogModesHandler() + { + API = Main.Instance.ModHelper.Interaction.TryGetModApi("dgarro.CustomShipLogModes"); + } + + public static void AddInterstellarMode() + { + API.AddMode(StarChartHandler.ShipLogStarChartMode, + () => Main.HasWarpDrive, + () => TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI)); + } +} diff --git a/NewHorizons/OtherMods/CustomShipLogModes/ICustomShipLogModes.cs b/NewHorizons/OtherMods/CustomShipLogModes/ICustomShipLogModes.cs new file mode 100644 index 00000000..9ada5f3f --- /dev/null +++ b/NewHorizons/OtherMods/CustomShipLogModes/ICustomShipLogModes.cs @@ -0,0 +1,8 @@ +using System; + +namespace NewHorizons.OtherMods.CustomShipLogModes; + +public interface ICustomShipLogModesAPI +{ + public void AddMode(ShipLogMode mode, Func isEnabledSupplier, Func nameSupplier); +} diff --git a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs index 2b51ba37..29719c0e 100644 --- a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs +++ b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs @@ -11,6 +11,9 @@ namespace NewHorizons.Patches.CameraPatches [HarmonyPatch(typeof(NomaiRemoteCamera), nameof(NomaiRemoteCamera.Awake))] public static void NomaiRemoteCamera_Awake(NomaiRemoteCamera __instance) { + // Ensures that if the player is visible from the remote camera they look normal + CommonCameraHandler.RegisterCustomCamera(__instance._camera); + // These layers were left on because it doesnt come up in base game (Dreamworld is inactive, player is far away) __instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("DreamSimulation")); __instance._camera.mainCamera.cullingMask &= ~(1 <(); - text.text = newPrompt; - } - [HarmonyPrefix] [HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))] public static bool ShipCockpitController_Update(ShipCockpitController __instance) @@ -37,42 +25,5 @@ namespace NewHorizons.Patches } return true; } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogController), nameof(ShipLogController.Update))] - public static bool ShipLogController_Update(ShipLogController __instance) - { - if (!Main.HasWarpDrive) return true; - - if (__instance._exiting - || OWInput.GetInputMode() != InputMode.ShipComputer - || __instance._currentMode.AllowCancelInput() && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.All) - || StarChartHandler.ShipLogStarChartMode == null) - return true; - - // Mostly copied from the base method but we're trying to fit in our new mode - __instance._exitPrompt.SetVisibility(__instance._currentMode.AllowCancelInput()); - __instance._currentMode.UpdateMode(); - if (__instance._currentMode.AllowModeSwap() && OWInput.IsNewlyPressed(InputLibrary.swapShipLogMode, InputMode.All)) - { - ShipLogMode currentMode = __instance._currentMode; - string focusedEntryID = currentMode.GetFocusedEntryID(); - if (!focusedEntryID.Equals("")) return true; - bool flag = currentMode.Equals(__instance._mapMode); - __instance._currentMode = (flag ? __instance._detectiveMode : __instance._mapMode); - - if (currentMode.Equals(__instance._mapMode)) - __instance._currentMode = StarChartHandler.ShipLogStarChartMode; - else if (currentMode.Equals(StarChartHandler.ShipLogStarChartMode)) - __instance._currentMode = __instance._detectiveMode; - else - __instance._currentMode = __instance._mapMode; - - currentMode.ExitMode(); - __instance._currentMode.EnterMode(focusedEntryID, null); - __instance._oneShotSource.PlayOneShot(flag ? global::AudioType.ShipLogEnterDetectiveMode : global::AudioType.ShipLogEnterMapMode, 1f); - } - return false; - } } } diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index ae3d41c3..4a8968b9 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -6,7 +6,7 @@ "uniqueName": "xen.NewHorizons", "version": "1.6.2", "owmlVersion": "2.7.2", - "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility" ], + "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ], "pathsToPreserve": [ "planets", "systems", "translations" ] }