From f914f121f511ba2adb41b5597b4b6d5f8b505882 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 10 Jun 2024 23:12:19 -0400 Subject: [PATCH] Fix warp eyes --- .../Components/Ship/ShipWarpController.cs | 19 +++++++-------- .../WarpPatches/InputManagerPatches.cs | 24 +++++++++++++++++++ NewHorizons/manifest.json | 2 +- 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 NewHorizons/Patches/WarpPatches/InputManagerPatches.cs diff --git a/NewHorizons/Components/Ship/ShipWarpController.cs b/NewHorizons/Components/Ship/ShipWarpController.cs index d1f8e62d..c6620df0 100644 --- a/NewHorizons/Components/Ship/ShipWarpController.cs +++ b/NewHorizons/Components/Ship/ShipWarpController.cs @@ -47,12 +47,6 @@ namespace NewHorizons.Components.Ship public void Start() { _isWarpingIn = false; - GlobalMessenger.AddListener("FinishOpenEyes", new Callback(OnFinishOpenEyes)); - } - - public void OnDestroy() - { - GlobalMessenger.RemoveListener("FinishOpenEyes", new Callback(OnFinishOpenEyes)); } private void MakeBlackHole() @@ -144,6 +138,12 @@ namespace NewHorizons.Components.Ship resources._currentHealth = 100f; if (!PlayerState.AtFlightConsole()) TeleportToShip(); } + + if (PlayerState.IsInsideShip() && !_eyesOpen) + { + _eyesOpen = true; + Locator.GetPlayerCamera().GetComponent().OpenEyesImmediate(); + } } // Idk whats making this work but now it works and idc @@ -154,11 +154,6 @@ namespace NewHorizons.Components.Ship } } - private void OnFinishOpenEyes() - { - _eyesOpen = true; - } - private void StartWarpInEffect() { NHLogger.LogVerbose("Starting warp-in effect"); @@ -203,6 +198,8 @@ namespace NewHorizons.Components.Ship PlayerState.OnEnterShip(); PlayerSpawnHandler.SpawnShip(); + OWInput.ChangeInputMode(InputMode.ShipCockpit); + Delay.FireInNUpdates(() => OWInput.ChangeInputMode(InputMode.ShipCockpit), 10); } } } diff --git a/NewHorizons/Patches/WarpPatches/InputManagerPatches.cs b/NewHorizons/Patches/WarpPatches/InputManagerPatches.cs new file mode 100644 index 00000000..0a41f168 --- /dev/null +++ b/NewHorizons/Patches/WarpPatches/InputManagerPatches.cs @@ -0,0 +1,24 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.WarpPatches; + +[HarmonyPatch(typeof(InputManager))] +public static class InputManagerPatches +{ + [HarmonyPrefix] + [HarmonyPatch(nameof(InputManager.ChangeInputMode))] + public static bool InputManager_ChangeInputMode(InputManager __instance, InputMode mode) + { + // Can't use player state because it is updated after this method is called + var atFlightConsole = Locator.GetPlayerCameraController()?._shipController?.IsPlayerAtFlightConsole() ?? false; + // If we're flying the ship don't let it break our input by changing us to another input mode + if (atFlightConsole && mode == InputMode.Character) + { + return false; + } + else + { + return true; + } + } +} diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index fd79e6fc..205ce96a 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.21.0", + "version": "1.21.1", "owmlVersion": "2.12.1", "dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "PacificEngine.OW_CommonResources" ],