diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs
index c02e8650..6a696b53 100644
--- a/NewHorizons/External/Configs/StarSystemConfig.cs
+++ b/NewHorizons/External/Configs/StarSystemConfig.cs
@@ -20,6 +20,12 @@ namespace NewHorizons.External.Configs
///
public bool freeMapAngle;
+ ///
+ /// When well past the furthest orbit, should the player be summoned back to the star?
+ ///
+ [DefaultValue(true)]
+ public bool returnToSolarSystemWhenTooFar = true;
+
///
/// An override value for the far clip plane. Allows you to see farther.
///
diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs
index 78367f29..71401f6a 100644
--- a/NewHorizons/Main.cs
+++ b/NewHorizons/Main.cs
@@ -89,6 +89,8 @@ namespace NewHorizons
public static bool HasDLC { get => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned; }
+ public static StarSystemConfig GetCurrentSystemConfig => SystemDict[Instance.CurrentStarSystem].Config;
+
public override object GetApi()
{
return new NewHorizonsApi();
diff --git a/NewHorizons/Patches/WarpPatches/ShipCockpitControllerPatches.cs b/NewHorizons/Patches/WarpPatches/ShipCockpitControllerPatches.cs
index efa5c6fb..198e01dd 100644
--- a/NewHorizons/Patches/WarpPatches/ShipCockpitControllerPatches.cs
+++ b/NewHorizons/Patches/WarpPatches/ShipCockpitControllerPatches.cs
@@ -50,8 +50,8 @@ namespace NewHorizons.Patches.WarpPatches
.RemoveInstructions(2)
.Insert(
// 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.Brtrue_S, returnLabel),
+ new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ShipCockpitControllerPatches), nameof(ShipCockpitControllerPatches.ShouldReturn))),
+ new CodeInstruction(OpCodes.Brfalse_S, returnLabel),
// Then get the center of the universe and its reference frame
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Locator), nameof(Locator.GetCenterOfTheUniverse))),
@@ -59,5 +59,10 @@ namespace NewHorizons.Patches.WarpPatches
)
.InstructionEnumeration();
}
+
+ private static bool ShouldReturn()
+ {
+ return !StarChartHandler.IsWarpDriveLockedOn() && Main.GetCurrentSystemConfig.returnToSolarSystemWhenTooFar;
+ }
}
}