Delete entire solar system using cool EOTS method thanks John

This commit is contained in:
Nick 2023-08-04 20:49:13 -04:00
parent 9becbd8fcb
commit fba6b1ea36

View File

@ -55,19 +55,22 @@ namespace NewHorizons.Handlers
public static void RemoveSolarSystem() public static void RemoveSolarSystem()
{ {
// Stop the sun from killing the player if they spawn at the center of the solar system // Stop the sun from killing the player if they spawn at the center of the solar system
var sunVolumes = SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN"); SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN").SetActive(false);
sunVolumes.SetActive(false);
// Random shit breaks if we don't wait idk why Delay.FireInNUpdates(() =>
foreach (var name in _solarSystemBodies)
{ {
var ao = AstroObjectLocator.GetAstroObject(name); // From EOTS thanks corby
if (ao != null) Delay.FireInNUpdates(() => RemoveBody(ao, false), 2); foreach (var rigidbody in CenterOfTheUniverse.s_rigidbodies)
else NHLogger.LogError($"Couldn't find [{name}]"); if (rigidbody.name is not "Player_Body" or "Ship_Body")
} rigidbody.gameObject.SetActive(false);
// Bring the sun back foreach (var proxyBody in GameObject.FindObjectsOfType<ProxyBody>())
Delay.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 3); proxyBody.gameObject.SetActive(false);
GameObject.FindObjectOfType<SunProxy>().gameObject.SetActive(false);
foreach (var streamingAssetBundle in StreamingManager.s_activeBundles)
streamingAssetBundle.Unload();
}, 2); // Random shit breaks if we don't wait idk why
} }
public static void RemoveEyeOfTheUniverse() public static void RemoveEyeOfTheUniverse()