diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs
index 951a211d..1af57973 100644
--- a/NewHorizons/External/Configs/StarSystemConfig.cs
+++ b/NewHorizons/External/Configs/StarSystemConfig.cs
@@ -190,6 +190,16 @@ namespace NewHorizons.External.Configs
///
public string promptFact;
+ ///
+ /// Whether the vessel should spawn in this system even if it wasn't used to warp to it.
+ ///
+ public bool alwaysPresent;
+
+ ///
+ /// Whether to always spawn the player on the vessel, even if it wasn't used to warp to the system.
+ ///
+ public bool spawnOnVessel;
+
///
/// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.
///
diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs
index e84a49b2..f159a8c6 100644
--- a/NewHorizons/Handlers/VesselWarpHandler.cs
+++ b/NewHorizons/Handlers/VesselWarpHandler.cs
@@ -29,13 +29,16 @@ namespace NewHorizons.Handlers
public static void LoadVessel()
{
+ var system = SystemDict[Instance.CurrentStarSystem];
if (Instance.CurrentStarSystem == "EyeOfTheUniverse")
{
_vesselSpawnPoint = SearchUtilities.Find("Vessel_Body/SPAWN_Vessel").GetComponent();
return;
}
- if (Instance.IsWarpingFromVessel)
+ var vesselIsPresent = system.Config?.Vessel?.alwaysPresent ?? false;
+
+ if (Instance.IsWarpingFromVessel || vesselIsPresent)
_vesselSpawnPoint = Instance.CurrentStarSystem == "SolarSystem" ? UpdateVessel() : CreateVessel();
else
_vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren();
@@ -91,11 +94,7 @@ namespace NewHorizons.Handlers
VesselObject = vesselObject;
var vesselAO = vesselObject.AddComponent();
- if (system.Config.Vessel?.hasPhysics ?? true)
- {
- vesselAO._owRigidbody = vesselObject.GetComponent();
- vesselObject.transform.parent = null;
- }
+ vesselAO._owRigidbody = vesselObject.GetComponent();
vesselAO._rootSector = vesselObject.GetComponentInChildren(true);
vesselAO._customName = "Vessel";
vesselAO._name = AstroObject.Name.CustomString;
@@ -159,6 +158,20 @@ namespace NewHorizons.Handlers
EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren(true);
system.SpawnPoint = eyeSpawnPoint;
+ if (system.Config.Vessel?.hasPhysics ?? true)
+ {
+ vesselObject.transform.parent = null;
+ }
+ else
+ {
+ vesselAO._owRigidbody = null;
+ UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent());
+ UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent());
+ UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent());
+ UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent());
+ }
+ vesselWarpController._targetWarpPlatform._owRigidbody = warpExit.GetAttachedOWRigidbody();
+
vesselObject.SetActive(true);
Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController));
diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs
index 1538d7bb..eae48e17 100644
--- a/NewHorizons/Main.cs
+++ b/NewHorizons/Main.cs
@@ -400,8 +400,11 @@ namespace NewHorizons
}
if (HasWarpDrive == true) EnableWarpDrive();
+ var vesselIsPresent = SystemDict[CurrentStarSystem].Config?.Vessel?.alwaysPresent ?? false;
+ var shouldSpawnOnVessel = vesselIsPresent && (SystemDict[CurrentStarSystem].Config?.Vessel?.spawnOnVessel ?? false);
+
var shouldWarpInFromShip = IsWarpingFromShip && _shipWarpController != null;
- var shouldWarpInFromVessel = IsWarpingFromVessel && VesselWarpHandler.VesselSpawnPoint != null;
+ var shouldWarpInFromVessel = (IsWarpingFromVessel || shouldSpawnOnVessel) && VesselWarpHandler.VesselSpawnPoint != null;
Delay.RunWhen(() => IsSystemReady, () => OnSystemReady(shouldWarpInFromShip, shouldWarpInFromVessel));
IsWarpingFromShip = false;