mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Reorganize warp drive patches
This commit is contained in:
parent
39b8c3d503
commit
8e36f5b479
@ -43,6 +43,8 @@ namespace NewHorizons
|
||||
public bool IsWarping { get; private set; } = false;
|
||||
public bool WearingSuit { get; private set; } = false;
|
||||
|
||||
public static bool HasWarpDrive { get; private set; } = false;
|
||||
|
||||
private ShipWarpController _shipWarpController;
|
||||
|
||||
public override object GetApi()
|
||||
@ -59,6 +61,7 @@ namespace NewHorizons
|
||||
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
||||
|
||||
Tools.Patches.Apply();
|
||||
Tools.WarpDrivePatches.Apply();
|
||||
Tools.OWCameraFix.Apply();
|
||||
|
||||
Logger.Log("Begin load of config files...", Logger.LogType.Log);
|
||||
@ -107,6 +110,8 @@ namespace NewHorizons
|
||||
// Make the warp controller if there are multiple star systems
|
||||
if (BodyDict.Keys.Count > 1)
|
||||
{
|
||||
HasWarpDrive = true;
|
||||
|
||||
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>();
|
||||
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => ShipLogBuilder.Init());
|
||||
|
||||
|
||||
@ -50,13 +50,8 @@ namespace NewHorizons.Tools
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ProbeLauncher>("UpdateOrbitalLaunchValues", typeof(Patches), nameof(Patches.OnProbeLauncherUpdateOrbitalLaunchValues));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SurveyorProbe>("IsLaunched", typeof(Patches), nameof(Patches.OnSurveyorProbeIsLaunched));
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogController>("Update", typeof(Patches), nameof(Patches.OnShipLogControllerUpdate));
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipCockpitController>("Update", typeof(Patches), nameof(Patches.OnShipCockpitControllerUpdate));
|
||||
|
||||
// Postfixes
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("EnterMode", typeof(Patches), nameof(Patches.OnShipLogMapModeEnterMode));
|
||||
}
|
||||
|
||||
public static bool GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
|
||||
@ -340,38 +335,6 @@ namespace NewHorizons.Tools
|
||||
return (Locator.GetPlayerRulesetDetector()?.GetPlanetoidRuleset()?.GetGravityVolume() != null);
|
||||
}
|
||||
|
||||
public static bool OnShipLogControllerUpdate(ShipLogController __instance)
|
||||
{
|
||||
if (__instance._exiting
|
||||
|| OWInput.GetInputMode() != InputMode.ShipComputer
|
||||
|| __instance._currentMode.AllowCancelInput() && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.All)
|
||||
|| ShipLogBuilder.ShipLogStarChartMode == null)
|
||||
return true;
|
||||
|
||||
__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 = ShipLogBuilder.ShipLogStarChartMode;
|
||||
else if (currentMode.Equals(ShipLogBuilder.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;
|
||||
}
|
||||
|
||||
public static bool OnSurveyorProbeIsLaunched(SurveyorProbe __instance, ref bool __result)
|
||||
{
|
||||
try
|
||||
@ -384,27 +347,5 @@ namespace NewHorizons.Tools
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool OnShipCockpitControllerUpdate(ShipCockpitController __instance)
|
||||
{
|
||||
if(__instance._playerAtFlightConsole && OWInput.IsNewlyPressed(InputLibrary.autopilot, InputMode.ShipCockpit))
|
||||
{
|
||||
var targetSystem = ShipLogBuilder.ShipLogStarChartMode.GetTargetStarSystem();
|
||||
if (targetSystem != null)
|
||||
{
|
||||
Main.Instance.ChangeCurrentStarSystem(targetSystem, true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void OnShipLogMapModeEnterMode(ShipLogMapMode __instance)
|
||||
{
|
||||
var newPrompt = "Interstellar Mode";
|
||||
__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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
82
NewHorizons/Tools/WarpDrivePatches.cs
Normal file
82
NewHorizons/Tools/WarpDrivePatches.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using NewHorizons.Builder.General;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Tools
|
||||
{
|
||||
public static class WarpDrivePatches
|
||||
{
|
||||
public static void Apply()
|
||||
{
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipCockpitController>("Update", typeof(WarpDrivePatches), nameof(WarpDrivePatches.OnShipCockpitControllerUpdate));
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("EnterMode", typeof(WarpDrivePatches), nameof(WarpDrivePatches.OnShipLogMapModeEnterMode));
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogController>("Update", typeof(WarpDrivePatches), nameof(WarpDrivePatches.OnShipLogControllerUpdate));
|
||||
}
|
||||
|
||||
public static void OnShipLogMapModeEnterMode(ShipLogMapMode __instance)
|
||||
{
|
||||
if (!Main.HasWarpDrive) return;
|
||||
|
||||
var newPrompt = "Interstellar Mode";
|
||||
__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;
|
||||
}
|
||||
|
||||
public static bool OnShipCockpitControllerUpdate(ShipCockpitController __instance)
|
||||
{
|
||||
if (!Main.HasWarpDrive) return true;
|
||||
|
||||
if (__instance._playerAtFlightConsole && OWInput.IsNewlyPressed(InputLibrary.autopilot, InputMode.ShipCockpit))
|
||||
{
|
||||
var targetSystem = ShipLogBuilder.ShipLogStarChartMode.GetTargetStarSystem();
|
||||
if (targetSystem != null)
|
||||
{
|
||||
Main.Instance.ChangeCurrentStarSystem(targetSystem, true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool OnShipLogControllerUpdate(ShipLogController __instance)
|
||||
{
|
||||
if (!Main.HasWarpDrive) return true;
|
||||
|
||||
if (__instance._exiting
|
||||
|| OWInput.GetInputMode() != InputMode.ShipComputer
|
||||
|| __instance._currentMode.AllowCancelInput() && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.All)
|
||||
|| ShipLogBuilder.ShipLogStarChartMode == null)
|
||||
return true;
|
||||
|
||||
__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 = ShipLogBuilder.ShipLogStarChartMode;
|
||||
else if (currentMode.Equals(ShipLogBuilder.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user