Fix vessel spawn overriding other spawns

This commit is contained in:
Joshua Thome 2023-03-22 13:37:14 -05:00
parent 094968187b
commit 5805908e6d
2 changed files with 14 additions and 7 deletions

View File

@ -45,7 +45,7 @@ namespace NewHorizons.Handlers
{
var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel;
var shouldSpawnOnVessel = IsVesselPresent() && (vesselConfig?.spawnOnVessel ?? false);
return Instance.IsWarpingFromVessel || shouldSpawnOnVessel;
return !Instance.IsWarpingFromShip && (Instance.IsWarpingFromVessel || shouldSpawnOnVessel);
}
public static void LoadVessel()
@ -174,9 +174,6 @@ namespace NewHorizons.Handlers
vesselObject.GetComponent<MapMarker>()._labelID = (UITextType)TranslationHandler.AddUI("Vessel");
EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren<EyeSpawnPoint>(true);
system.SpawnPoint = eyeSpawnPoint;
var hasParentBody = !string.IsNullOrEmpty(system.Config.Vessel?.vesselSpawn?.parentBody);
var hasPhysics = system.Config.Vessel?.hasPhysics ?? !hasParentBody;
@ -209,6 +206,12 @@ namespace NewHorizons.Handlers
}
}
EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren<EyeSpawnPoint>(true);
if (ShouldSpawnAtVessel())
{
system.SpawnPoint = eyeSpawnPoint;
}
vesselObject.SetActive(true);
Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController));

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using NewHorizons.Utility;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Patches.PlayerPatches
@ -15,12 +16,15 @@ namespace NewHorizons.Patches.PlayerPatches
Logger.LogWarning("Abort player spawn. Vessel will handle it.");
return false;
}
else
else if (Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint != null)
{
Logger.LogVerbose("Player spawning");
Logger.LogVerbose($"Player spawning at {Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint.transform.GetPath()}");
__instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint);
return true;
} else if (Main.Instance.CurrentStarSystem != "SolarSystem" && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse")
{
Logger.LogWarning("No player spawn point set.");
}
return true;
}
}
}