From 738c41701a819193680500ffed9db8af63da287b Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 25 Mar 2024 13:08:53 -0400 Subject: [PATCH] Fix ship not being added to volumes --- NewHorizons/Handlers/PlayerSpawnHandler.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/NewHorizons/Handlers/PlayerSpawnHandler.cs b/NewHorizons/Handlers/PlayerSpawnHandler.cs index 22380665..4a569ec3 100644 --- a/NewHorizons/Handlers/PlayerSpawnHandler.cs +++ b/NewHorizons/Handlers/PlayerSpawnHandler.cs @@ -115,6 +115,23 @@ namespace NewHorizons.Handlers } // For some reason none of this seems to apply to the Player. // If somebody ever makes a sound volume thats somehow always applying to the player tho then itd probably be this + + + // Sometimes the ship isn't added to the volumes it's meant to now be in + // We'll just toggle all volumes on the planet on and off + var shipDetector = Locator.GetShipDetector().GetComponent(); + var shipDetector2 = Locator.GetShipDetector().GetComponent(); + foreach (var volume in SpawnPointBuilder.ShipSpawn.GetAttachedOWRigidbody().GetComponentsInChildren()) + { + if (volume.GetOWTriggerVolume().GetDistanceToBoundary(ship.transform.position) <= 0) + { + // Add ship to volume + // If it's already tracking it it will complain here but thats fine + shipDetector.AddVolume(volume); + shipDetector2.AddVolume(volume); + volume.GetOWTriggerVolume().AddObjectToVolume(shipDetector.gameObject); + } + } } } else if (Main.Instance.CurrentStarSystem != "SolarSystem" && !Main.Instance.IsWarpingFromShip)