mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Stop any rigidbody from unparenting itself when deleting solar system
This commit is contained in:
parent
adf8f0b182
commit
6945c0b6c7
@ -3,6 +3,7 @@ using NewHorizons.Utility;
|
|||||||
using OWML.Utils;
|
using OWML.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
@ -30,12 +31,26 @@ namespace NewHorizons.Handlers
|
|||||||
"White Hole"
|
"White Hole"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static readonly string[] _suspendBlacklist = new string[]
|
||||||
|
{
|
||||||
|
"Player_Body",
|
||||||
|
"Ship_Body"
|
||||||
|
};
|
||||||
|
|
||||||
public static void RemoveSolarSystem()
|
public static void RemoveSolarSystem()
|
||||||
{
|
{
|
||||||
// Stop the sun from killing the player
|
// Stop the sun from killing the player
|
||||||
var sunVolumes = SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN");
|
var sunVolumes = SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN");
|
||||||
sunVolumes.SetActive(false);
|
sunVolumes.SetActive(false);
|
||||||
|
|
||||||
|
foreach (var ow in GameObject.FindObjectsOfType<OWRigidbody>())
|
||||||
|
{
|
||||||
|
if (ow._origParent != null && (ow._origParentBody != null || ow._simulateInSector != null) && ow.transform.GetComponent<AstroObject>() == null && !ow._suspended && !_suspendBlacklist.Contains(ow.gameObject.name))
|
||||||
|
{
|
||||||
|
ow.Suspend();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var name in _solarSystemBodies)
|
foreach (var name in _solarSystemBodies)
|
||||||
{
|
{
|
||||||
var ao = AstroObjectLocator.GetAstroObject(name);
|
var ao = AstroObjectLocator.GetAstroObject(name);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user