Fix ship spawning separately from player #677

This commit is contained in:
Nick 2023-08-24 14:35:55 -04:00
parent b912593ed1
commit 455068077f

View File

@ -51,11 +51,19 @@ namespace NewHorizons.Handlers
// Ensures it has invoked everything and actually placed the player in the cloaking field #671 // Ensures it has invoked everything and actually placed the player in the cloaking field #671
cloak._firstUpdate = true; cloak._firstUpdate = true;
} }
// Spawn ship
Delay.FireInNUpdates(SpawnShip, 30);
} }
public static void SpawnShip() public static void SpawnShip()
{ {
var ship = SearchUtilities.Find("Ship_Body"); var ship = SearchUtilities.Find("Ship_Body");
if (SpawnPointBuilder.ShipSpawn != null)
{
NHLogger.Log("Spawning player ship");
if (ship != null) if (ship != null)
{ {
ship.SetActive(true); ship.SetActive(true);
@ -71,6 +79,12 @@ namespace NewHorizons.Handlers
SpawnBody(ship.GetAttachedOWRigidbody(), SpawnPointBuilder.ShipSpawn, pos); SpawnBody(ship.GetAttachedOWRigidbody(), SpawnPointBuilder.ShipSpawn, pos);
} }
} }
else if (Main.Instance.CurrentStarSystem != "SolarSystem" && !Main.Instance.IsWarpingFromShip)
{
NHLogger.Log("System has no ship spawn. Deactivating it.");
ship?.SetActive(false);
}
}
private static IEnumerator SpawnCoroutine(int length) private static IEnumerator SpawnCoroutine(int length)
{ {
@ -81,20 +95,6 @@ namespace NewHorizons.Handlers
} }
InvulnerabilityHandler.MakeInvulnerable(false); InvulnerabilityHandler.MakeInvulnerable(false);
if (!Main.Instance.IsWarpingFromShip)
{
if (SpawnPointBuilder.ShipSpawn != null)
{
NHLogger.Log("Spawning player ship");
SpawnShip();
}
else
{
NHLogger.Log("System has no ship spawn. Deactivating it.");
SearchUtilities.Find("Ship_Body")?.SetActive(false);
}
}
} }
private static void FixPlayerVelocity() private static void FixPlayerVelocity()