Merge branch 'dev' into eye-of-the-universe

This commit is contained in:
Noah Pilarski 2022-10-08 12:40:18 -04:00
commit a0a9ff8640
8 changed files with 48 additions and 67 deletions

View File

@ -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 // 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; SC.radius = sphereOfInfluence * 2;
var RFV = rfGO.AddComponent<ReferenceFrameVolume>(); float targetDistance = module.maxTargetDistance;
ReferenceFrameVolume RFV;
if (module.hideInMap)
{
var mapRFV = rfGO.AddComponent<MapReferenceFrameVolume>();
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<ReferenceFrameVolume>();
var minTargetDistance = module.targetWhenClose ? 0 : sphereOfInfluence; var minTargetDistance = module.targetWhenClose ? 0 : sphereOfInfluence;
var RV = new ReferenceFrame(owrb); var RV = new ReferenceFrame(owrb);
RV._minSuitTargetDistance = minTargetDistance; RV._minSuitTargetDistance = minTargetDistance;
// The game raycasts to 100km, but if the target is farther than this max distance it ignores it // 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._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
RV._autoAlignmentDistance = sphereOfInfluence * 1.5f; RV._autoAlignmentDistance = sphereOfInfluence * 1.5f;
@ -55,7 +66,6 @@ namespace NewHorizons.Builder.General
GameObject.Destroy(rfGO); GameObject.Destroy(rfGO);
return null; return null;
} }
else rfGO.SetActive(!module.hideInMap);
return rfGO; return rfGO;
} }

View File

@ -21,10 +21,8 @@ namespace NewHorizons.Components.ShipLog
private Vector2 _panRootPos = Vector2.zero; private Vector2 _panRootPos = Vector2.zero;
private Vector2 _startPanPos; private Vector2 _startPanPos;
private ScreenPromptList _upperRightPromptList;
private ScreenPromptList _centerPromptList; private ScreenPromptList _centerPromptList;
private ScreenPrompt _detectiveModePrompt;
private ScreenPrompt _targetSystemPrompt; private ScreenPrompt _targetSystemPrompt;
private ScreenPrompt _warpPrompt = new ScreenPrompt(InputLibrary.autopilot, "<CMD> Warp to system"); private ScreenPrompt _warpPrompt = new ScreenPrompt(InputLibrary.autopilot, "<CMD> Warp to system");
@ -45,9 +43,7 @@ namespace NewHorizons.Components.ShipLog
_oneShotSource = oneShotSource; _oneShotSource = oneShotSource;
_centerPromptList = centerPromptList; _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); _targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, TranslationHandler.GetTranslation("LOCK_AUTOPILOT_WARP", TranslationHandler.TextType.UI), 0, ScreenPrompt.DisplayState.Normal, false);
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame)); GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
@ -169,7 +165,7 @@ namespace NewHorizons.Components.ShipLog
{ {
gameObject.SetActive(true); 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); Locator.GetPromptManager().AddScreenPrompt(_targetSystemPrompt, _centerPromptList, TextAnchor.MiddleCenter, -1, true);
} }
@ -177,7 +173,6 @@ namespace NewHorizons.Components.ShipLog
{ {
gameObject.SetActive(false); gameObject.SetActive(false);
Locator.GetPromptManager().RemoveScreenPrompt(_detectiveModePrompt);
Locator.GetPromptManager().RemoveScreenPrompt(_targetSystemPrompt); Locator.GetPromptManager().RemoveScreenPrompt(_targetSystemPrompt);
} }

View File

@ -1,6 +1,7 @@
using NewHorizons.Components.ShipLog; using NewHorizons.Components.ShipLog;
using NewHorizons.Utility; using NewHorizons.Utility;
using System.Collections.Generic; using System.Collections.Generic;
using NewHorizons.OtherMods.CustomShipLogModes;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Handlers namespace NewHorizons.Handlers
@ -46,14 +47,7 @@ namespace NewHorizons.Handlers
panRoot.transform.localPosition = Vector3.zero; panRoot.transform.localPosition = Vector3.zero;
panRoot.transform.localRotation = Quaternion.Euler(0, 0, 0); panRoot.transform.localRotation = Quaternion.Euler(0, 0, 0);
var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>(); CustomShipLogModesHandler.AddInterstellarMode();
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>();
var oneShotSource = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
ShipLogStarChartMode.Initialize(
centerPromptList,
upperRightPromptList,
oneShotSource);
} }
_starSystemToFactID = new Dictionary<string, string>(); _starSystemToFactID = new Dictionary<string, string>();

View File

@ -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<ICustomShipLogModesAPI>("dgarro.CustomShipLogModes");
}
public static void AddInterstellarMode()
{
API.AddMode(StarChartHandler.ShipLogStarChartMode,
() => Main.HasWarpDrive,
() => TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI));
}
}

View File

@ -0,0 +1,8 @@
using System;
namespace NewHorizons.OtherMods.CustomShipLogModes;
public interface ICustomShipLogModesAPI
{
public void AddMode(ShipLogMode mode, Func<bool> isEnabledSupplier, Func<string> nameSupplier);
}

View File

@ -11,6 +11,9 @@ namespace NewHorizons.Patches.CameraPatches
[HarmonyPatch(typeof(NomaiRemoteCamera), nameof(NomaiRemoteCamera.Awake))] [HarmonyPatch(typeof(NomaiRemoteCamera), 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
CommonCameraHandler.RegisterCustomCamera(__instance._camera);
// These layers were left on because it doesnt come up in base game (Dreamworld is inactive, player is far away) // These layers were left on because it doesnt come up in base game (Dreamworld is inactive, player is far away)
__instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("DreamSimulation")); __instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("DreamSimulation"));
__instance._camera.mainCamera.cullingMask &= ~(1 <<LayerMask.NameToLayer("UI")); __instance._camera.mainCamera.cullingMask &= ~(1 <<LayerMask.NameToLayer("UI"));

View File

@ -7,18 +7,6 @@ namespace NewHorizons.Patches
[HarmonyPatch] [HarmonyPatch]
public static class WarpDrivePatches public static class WarpDrivePatches
{ {
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.EnterMode))]
public static void ShipLogMapMode_EnterMode(ShipLogMapMode __instance)
{
if (!Main.HasWarpDrive) return;
var newPrompt = TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI);
__instance._detectiveModePrompt.SetText(newPrompt);
var text = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/ScreenPromptListScaleRoot/ScreenPromptList_UpperRight/ScreenPrompt/Text").GetComponent<UnityEngine.UI.Text>();
text.text = newPrompt;
}
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))] [HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))]
public static bool ShipCockpitController_Update(ShipCockpitController __instance) public static bool ShipCockpitController_Update(ShipCockpitController __instance)
@ -37,42 +25,5 @@ namespace NewHorizons.Patches
} }
return true; 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;
}
} }
} }

View File

@ -6,7 +6,7 @@
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "1.6.2", "version": "1.6.2",
"owmlVersion": "2.7.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" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ],
"pathsToPreserve": [ "planets", "systems", "translations" ] "pathsToPreserve": [ "planets", "systems", "translations" ]
} }