Abort player spawn when warping from vessel

This commit is contained in:
Noah Pilarski 2022-10-02 23:15:09 -04:00
parent 06234a2079
commit 36dd053a08
2 changed files with 17 additions and 3 deletions

View File

@ -59,6 +59,7 @@ namespace NewHorizons
public bool IsWarpingFromShip { get; private set; } = false;
public bool IsWarpingFromVessel { get; private set; } = false;
public bool IsWarpingBackToEye { get; internal set; } = false;
public bool DidWarpFromVessel { get; private set; } = false;
public bool WearingSuit { get; private set; } = false;
public bool IsChangingStarSystem { get; private set; } = false;
@ -414,6 +415,7 @@ namespace NewHorizons
IsWarpingFromShip = false;
IsWarpingFromVessel = false;
DidWarpFromVessel = shouldWarpInFromVessel;
var map = GameObject.FindObjectOfType<MapController>();
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
@ -490,6 +492,7 @@ namespace NewHorizons
IsWarpingFromShip = false;
IsWarpingFromVessel = false;
DidWarpFromVessel = false;
}
//Stop starfield from disappearing when there is no lights
@ -783,6 +786,7 @@ namespace NewHorizons
_currentStarSystem = newStarSystem;
IsWarpingFromShip = warp;
IsWarpingFromVessel = vessel;
DidWarpFromVessel = false;
var warpingToEye = newStarSystem == "EyeOfTheUniverse";
@ -802,6 +806,7 @@ namespace NewHorizons
IsWarpingFromShip = warp;
IsWarpingFromVessel = vessel;
DidWarpFromVessel = false;
OnChangeStarSystem?.Invoke(newStarSystem);
Logger.Log($"Warping to {newStarSystem}");

View File

@ -7,10 +7,19 @@ namespace NewHorizons.Patches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerSpawner), nameof(PlayerSpawner.SpawnPlayer))]
public static void PlayerSpawner_SpawnPlayer(PlayerSpawner __instance)
public static bool PlayerSpawner_SpawnPlayer(PlayerSpawner __instance)
{
Logger.LogVerbose("Player spawning");
__instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint);
if (Main.Instance.IsWarpingFromVessel || Main.Instance.DidWarpFromVessel)
{
Logger.LogWarning("Abort player spawn. Vessel will handle it.");
return false;
}
else
{
Logger.LogVerbose("Player spawning");
__instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint);
return true;
}
}
}
}