Hide warp prompt in landing cam

This commit is contained in:
Damián Garro 2022-05-27 04:11:59 -03:00
parent 745b773389
commit c12939b5bd
2 changed files with 2 additions and 40 deletions

View File

@ -31,7 +31,6 @@ namespace NewHorizons.Components
private NotificationData _warpNotificationData = null; private NotificationData _warpNotificationData = null;
private int _nextCardIndex; private int _nextCardIndex;
private bool _isAtFlightConsole;
private void Awake() private void Awake()
{ {
@ -51,10 +50,6 @@ namespace NewHorizons.Components
_targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, "Lock Autopilot to Star System", 0, ScreenPrompt.DisplayState.Normal, false); _targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, "Lock Autopilot to Star System", 0, ScreenPrompt.DisplayState.Normal, false);
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame)); GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
GlobalMessenger.AddListener("ExitFlightConsole", new Callback(OnExitFlightConsole));
GlobalMessenger.AddListener("GamePaused", new Callback(OnGamePaused));
GlobalMessenger.AddListener("GameUnpaused", new Callback(OnGameUnpaused));
_nextCardIndex = 0; _nextCardIndex = 0;
foreach (var starSystem in Main.SystemDict.Keys) foreach (var starSystem in Main.SystemDict.Keys)
@ -96,42 +91,10 @@ namespace NewHorizons.Components
public void OnDestroy() public void OnDestroy()
{ {
GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame)); GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
GlobalMessenger<OWRigidbody>.RemoveListener("EnterFlightConsole", new Callback<OWRigidbody>(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); Locator.GetPromptManager().RemoveScreenPrompt(_warpPrompt, PromptPosition.UpperLeft);
} }
private void OnEnterFlightConsole(OWRigidbody _)
{
_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 uniqueID, Transform parent, Vector2 position) public GameObject CreateCard(string uniqueID, Transform parent, Vector2 position)
{ {
if (_cardTemplate == null) if (_cardTemplate == null)
@ -329,8 +292,6 @@ namespace NewHorizons.Components
if (playSound) _oneShotSource.PlayOneShot(global::AudioType.ShipLogMarkLocation, 1f); if (playSound) _oneShotSource.PlayOneShot(global::AudioType.ShipLogMarkLocation, 1f);
_target.SetMarkedOnHUD(false); _target.SetMarkedOnHUD(false);
_target = null; _target = null;
_warpPrompt.SetVisibility(false);
} }
public string GetTargetStarSystem() public string GetTargetStarSystem()
@ -343,7 +304,7 @@ namespace NewHorizons.Components
return OWInput.IsInputMode(InputMode.ShipCockpit) && _target != null; return OWInput.IsInputMode(InputMode.ShipCockpit) && _target != null;
} }
private void Update() public void UpdateWarpPromptVisibility()
{ {
_warpPrompt.SetVisibility(IsWarpDriveAvailable()); _warpPrompt.SetVisibility(IsWarpDriveAvailable());
} }

View File

@ -24,6 +24,7 @@ namespace NewHorizons.Patches
{ {
if (!Main.HasWarpDrive) return true; if (!Main.HasWarpDrive) return true;
StarChartHandler.ShipLogStarChartMode.UpdateWarpPromptVisibility();
if (__instance._playerAtFlightConsole && OWInput.IsNewlyPressed(InputLibrary.autopilot, InputMode.ShipCockpit)) if (__instance._playerAtFlightConsole && OWInput.IsNewlyPressed(InputLibrary.autopilot, InputMode.ShipCockpit))
{ {
var targetSystem = StarChartHandler.ShipLogStarChartMode.GetTargetStarSystem(); var targetSystem = StarChartHandler.ShipLogStarChartMode.GetTargetStarSystem();