From 41121fdc2655daab635470f8099b4e5f25560a3e Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 22 Aug 2023 23:47:12 -0400 Subject: [PATCH] Fix spawning inside cloaks fixes #671 --- NewHorizons/Handlers/PlayerSpawnHandler.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Handlers/PlayerSpawnHandler.cs b/NewHorizons/Handlers/PlayerSpawnHandler.cs index 8a9eb6f8..d81a3cd6 100644 --- a/NewHorizons/Handlers/PlayerSpawnHandler.cs +++ b/NewHorizons/Handlers/PlayerSpawnHandler.cs @@ -10,11 +10,11 @@ namespace NewHorizons.Handlers { public static void SetUpPlayerSpawn() { - var spawnPoint = Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint; - if (spawnPoint != null) + if (UsingCustomSpawn()) { - SearchUtilities.Find("Player_Body").GetComponent().SetBodyToMatch(spawnPoint.GetAttachedOWRigidbody()); - GetPlayerSpawner().SetInitialSpawnPoint(spawnPoint); + var spawn = GetDefaultSpawn(); + SearchUtilities.Find("Player_Body").GetComponent().SetBodyToMatch(spawn.GetAttachedOWRigidbody()); + GetPlayerSpawner().SetInitialSpawnPoint(spawn); } else { @@ -44,6 +44,13 @@ namespace NewHorizons.Handlers // Arbitrary number, depending on the machine some people die, some people fall through the floor, its very inconsistent Delay.StartCoroutine(SpawnCoroutine(30)); } + + var cloak = GetDefaultSpawn()?.GetAttachedOWRigidbody()?.GetComponentInChildren(); + if (cloak != null) + { + // Ensures it has invoked everything and actually placed the player in the cloaking field + cloak._firstUpdate = true; + } } public static void SpawnShip()