new-horizons/NewHorizons/Patches/WarpDrivePatches.cs
2022-10-05 02:09:40 -03:00

30 lines
1018 B
C#

using HarmonyLib;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class WarpDrivePatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))]
public static bool ShipCockpitController_Update(ShipCockpitController __instance)
{
if (!Main.HasWarpDrive) return true;
StarChartHandler.ShipLogStarChartMode.UpdateWarpPromptVisibility();
if (__instance._playerAtFlightConsole && OWInput.IsNewlyPressed(InputLibrary.autopilot, InputMode.ShipCockpit))
{
var targetSystem = StarChartHandler.ShipLogStarChartMode.GetTargetStarSystem();
if (targetSystem != null)
{
Main.Instance.ChangeCurrentStarSystem(targetSystem, true);
return false;
}
}
return true;
}
}
}