Don't be summoned back to the star by default

This commit is contained in:
Nick 2023-07-18 23:28:03 -04:00
parent a755f150d3
commit 177f69861a
3 changed files with 15 additions and 2 deletions

View File

@ -20,6 +20,12 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public bool freeMapAngle; public bool freeMapAngle;
/// <summary>
/// When well past the furthest orbit, should the player be summoned back to the star?
/// </summary>
[DefaultValue(true)]
public bool returnToSolarSystemWhenTooFar = true;
/// <summary> /// <summary>
/// An override value for the far clip plane. Allows you to see farther. /// An override value for the far clip plane. Allows you to see farther.
/// </summary> /// </summary>

View File

@ -89,6 +89,8 @@ namespace NewHorizons
public static bool HasDLC { get => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned; } public static bool HasDLC { get => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned; }
public static StarSystemConfig GetCurrentSystemConfig => SystemDict[Instance.CurrentStarSystem].Config;
public override object GetApi() public override object GetApi()
{ {
return new NewHorizonsApi(); return new NewHorizonsApi();

View File

@ -50,8 +50,8 @@ namespace NewHorizons.Patches.WarpPatches
.RemoveInstructions(2) .RemoveInstructions(2)
.Insert( .Insert(
// First do an if statement to see if the warp drive is locked on // First do an if statement to see if the warp drive is locked on
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StarChartHandler), nameof(StarChartHandler.IsWarpDriveLockedOn))), new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ShipCockpitControllerPatches), nameof(ShipCockpitControllerPatches.ShouldReturn))),
new CodeInstruction(OpCodes.Brtrue_S, returnLabel), new CodeInstruction(OpCodes.Brfalse_S, returnLabel),
// Then get the center of the universe and its reference frame // Then get the center of the universe and its reference frame
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Locator), nameof(Locator.GetCenterOfTheUniverse))), new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Locator), nameof(Locator.GetCenterOfTheUniverse))),
@ -59,5 +59,10 @@ namespace NewHorizons.Patches.WarpPatches
) )
.InstructionEnumeration(); .InstructionEnumeration();
} }
private static bool ShouldReturn()
{
return !StarChartHandler.IsWarpDriveLockedOn() && Main.GetCurrentSystemConfig.returnToSolarSystemWhenTooFar;
}
} }
} }