From 7df0a1181d92774f99aeb7da6ca54cab8fba9319 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 9 Apr 2022 14:18:29 -0400 Subject: [PATCH 1/2] Add warp drive prompt --- .../Components/ShipLogStarChartMode.cs | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 5dc215be..1adbad66 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -30,11 +30,19 @@ namespace NewHorizons.Components private ScreenPrompt _detectiveModePrompt; private ScreenPrompt _targetSystemPrompt; + private ScreenPrompt _warpPrompt = new ScreenPrompt(InputLibrary.autopilot, " Warp to system"); private ShipLogEntryCard _target = null; private NotificationData _warpNotificationData = null; private int _nextCardIndex; + private bool _isAtFlightConsole; + + private void Awake() + { + // Prompts + Locator.GetPromptManager().AddScreenPrompt(_warpPrompt, PromptPosition.UpperLeft, false); + } public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource) { @@ -49,6 +57,9 @@ namespace NewHorizons.Components GlobalMessenger.AddListener("TargetReferenceFrame", new Callback(OnTargetReferenceFrame)); GlobalMessenger.AddListener("EnterFlightConsole", new Callback(OnEnterFlightConsole)); + GlobalMessenger.AddListener("ExitFlightConsole", new Callback(OnExitFlightConsole)); + GlobalMessenger.AddListener("GamePaused", new Callback(OnGamePaused)); + GlobalMessenger.AddListener("GameUnpaused", new Callback(OnGameUnpaused)); _nextCardIndex = 0; foreach (var starSystem in Main.SystemDict.Keys) @@ -91,11 +102,39 @@ namespace NewHorizons.Components { GlobalMessenger.RemoveListener("TargetReferenceFrame", new Callback(OnTargetReferenceFrame)); GlobalMessenger.RemoveListener("EnterFlightConsole", new Callback(OnEnterFlightConsole)); + GlobalMessenger.RemoveListener("ExitFlightConsole", new Callback(OnExitFlightConsole)); + GlobalMessenger.RemoveListener("GamePaused", new Callback(OnGamePaused)); + GlobalMessenger.RemoveListener("GameUnpaused", new Callback(OnGameUnpaused)); + + Locator.GetPromptManager().RemoveScreenPrompt(_warpPrompt, PromptPosition.UpperLeft); } private void OnEnterFlightConsole(OWRigidbody _) { - if (_target == null) GlobalMessenger.FireEvent("UntargetReferenceFrame"); + _isAtFlightConsole = true; + if(_target != null) + { + _warpPrompt.SetVisibility(true); + } + } + + private void OnExitFlightConsole() + { + _isAtFlightConsole = false; + _warpPrompt.SetVisibility(false); + } + + private void OnGamePaused() + { + _warpPrompt.SetVisibility(false); + } + + private void OnGameUnpaused() + { + if(_target != null && _isAtFlightConsole) + { + _warpPrompt.SetVisibility(true); + } } public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position) @@ -271,9 +310,13 @@ namespace NewHorizons.Components _oneShotSource.PlayOneShot(global::AudioType.ShipLogUnmarkLocation, 1f); _target = shipLogEntryCard; _target.SetMarkedOnHUD(true); + Locator._rfTracker.UntargetReferenceFrame(); + GlobalMessenger.FireEvent("UntargetReferenceFrame"); _warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueNameToString(shipLogEntryCard.name).ToUpper()}"); NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true); + + _warpPrompt.SetText($" Engage Warp To {UniqueNameToString(shipLogEntryCard.name)}"); } private void RemoveWarpTarget(bool playSound = false) @@ -283,11 +326,24 @@ namespace NewHorizons.Components if(playSound) _oneShotSource.PlayOneShot(global::AudioType.ShipLogMarkLocation, 1f); _target.SetMarkedOnHUD(false); _target = null; + + _warpPrompt.SetVisibility(false); } public string GetTargetStarSystem() { return _target?.name; } + + private bool IsWarpDriveAvailable() + { + return OWInput.IsInputMode(InputMode.ShipCockpit) && _target != null; + } + + private void Update() + { + Logger.Log("???"); + _warpPrompt.SetVisibility(IsWarpDriveAvailable()); + } } } From d5707ca9ad8bb7389f99d6433b3cd5a5a8d02b03 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 9 Apr 2022 18:07:37 -0400 Subject: [PATCH 2/2] Update manifest.json --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 06ca8f68..545c4307 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -3,7 +3,7 @@ "author": "xen, Idiot, & Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "0.10.1", + "version": "0.10.2", "owmlVersion": "2.1.0", "dependencies": [ "PacificEngine.OW_CommonResources" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ],