mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Refactor some planet destroying code
Made it so we *can* delete them but in the end even when its the whole solar system it still causes a ton of issues.
This commit is contained in:
parent
9e2afbbd2d
commit
02a3048720
@ -43,14 +43,14 @@ namespace NewHorizons.Builder.General
|
|||||||
foreach(var name in _solarSystemBodies)
|
foreach(var name in _solarSystemBodies)
|
||||||
{
|
{
|
||||||
var ao = AstroObjectLocator.GetAstroObject(name);
|
var ao = AstroObjectLocator.GetAstroObject(name);
|
||||||
if (ao != null) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => RemoveBody(ao));
|
if (ao != null) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => RemoveBody(ao, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bring the sun back because why not
|
// Bring the sun back because why not
|
||||||
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 2);
|
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveBody(AstroObject ao, List<AstroObject> toDestroy = null)
|
public static void RemoveBody(AstroObject ao, bool delete = false, List<AstroObject> toDestroy = null)
|
||||||
{
|
{
|
||||||
Logger.Log($"Removing {ao.name}");
|
Logger.Log($"Removing {ao.name}");
|
||||||
|
|
||||||
@ -67,7 +67,9 @@ namespace NewHorizons.Builder.General
|
|||||||
toDestroy.Add(ao);
|
toDestroy.Add(ao);
|
||||||
|
|
||||||
if (ao.GetAstroObjectName() == AstroObject.Name.BrittleHollow)
|
if (ao.GetAstroObjectName() == AstroObject.Name.BrittleHollow)
|
||||||
RemoveBody(AstroObjectLocator.GetAstroObject(AstroObject.Name.WhiteHole), toDestroy);
|
{
|
||||||
|
RemoveBody(AstroObjectLocator.GetAstroObject(AstroObject.Name.WhiteHole), delete, toDestroy);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if any other objects depend on it and remove them too
|
// Check if any other objects depend on it and remove them too
|
||||||
var aoArray = AstroObjectLocator.GetAllAstroObjects();
|
var aoArray = AstroObjectLocator.GetAllAstroObjects();
|
||||||
@ -81,7 +83,7 @@ namespace NewHorizons.Builder.General
|
|||||||
if (ao.Equals(obj.GetPrimaryBody()))
|
if (ao.Equals(obj.GetPrimaryBody()))
|
||||||
{
|
{
|
||||||
AstroObjectLocator.RemoveAstroObject(obj);
|
AstroObjectLocator.RemoveAstroObject(obj);
|
||||||
RemoveBody(obj, toDestroy);
|
RemoveBody(obj, delete, toDestroy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,57 +92,61 @@ namespace NewHorizons.Builder.General
|
|||||||
if (ao.GetAstroObjectName() == AstroObject.Name.CaveTwin || ao.GetAstroObjectName() == AstroObject.Name.TowerTwin)
|
if (ao.GetAstroObjectName() == AstroObject.Name.CaveTwin || ao.GetAstroObjectName() == AstroObject.Name.TowerTwin)
|
||||||
{
|
{
|
||||||
if (ao.GetAstroObjectName() == AstroObject.Name.TowerTwin)
|
if (ao.GetAstroObjectName() == AstroObject.Name.TowerTwin)
|
||||||
GameObject.Find("TimeLoopRing_Body").SetActive(false);
|
{
|
||||||
var focalBody = GameObject.Find("FocalBody");
|
DisableBody(GameObject.Find("TimeLoopRing_Body"), delete);
|
||||||
if (focalBody != null) focalBody.SetActive(false);
|
}
|
||||||
|
DisableBody(GameObject.Find("FocalBody"), delete);
|
||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.MapSatellite)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.MapSatellite)
|
||||||
{
|
{
|
||||||
var msb = GameObject.Find("MapSatellite_Body");
|
DisableBody(GameObject.Find("MapSatellite_Body"), delete);
|
||||||
if (msb != null) msb.SetActive(false);
|
|
||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.ProbeCannon)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.ProbeCannon)
|
||||||
{
|
{
|
||||||
GameObject.Find("NomaiProbe_Body").SetActive(false);
|
DisableBody(GameObject.Find("NomaiProbe_Body"), delete);
|
||||||
GameObject.Find("CannonMuzzle_Body").SetActive(false);
|
DisableBody(GameObject.Find("CannonMuzzle_Body"), delete);
|
||||||
GameObject.Find("FakeCannonMuzzle_Body (1)").SetActive(false);
|
DisableBody(GameObject.Find("FakeCannonMuzzle_Body (1)"), delete);
|
||||||
GameObject.Find("CannonBarrel_Body").SetActive(false);
|
DisableBody(GameObject.Find("CannonBarrel_Body"), delete);
|
||||||
GameObject.Find("FakeCannonBarrel_Body (1)").SetActive(false);
|
DisableBody(GameObject.Find("FakeCannonBarrel_Body (1)"), delete);
|
||||||
GameObject.Find("Debris_Body (1)").SetActive(false);
|
DisableBody(GameObject.Find("Debris_Body (1)"), delete);
|
||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.SunStation)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.SunStation)
|
||||||
{
|
{
|
||||||
GameObject.Find("SS_Debris_Body").SetActive(false);
|
DisableBody(GameObject.Find("SS_Debris_Body"), delete);
|
||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.GiantsDeep)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.GiantsDeep)
|
||||||
{
|
{
|
||||||
GameObject.Find("BrambleIsland_Body").SetActive(false);
|
DisableBody(GameObject.Find("BrambleIsland_Body"), delete);
|
||||||
GameObject.Find("GabbroIsland_Body").SetActive(false);
|
DisableBody(GameObject.Find("GabbroIsland_Body"), delete);
|
||||||
GameObject.Find("QuantumIsland_Body").SetActive(false);
|
DisableBody(GameObject.Find("QuantumIsland_Body"), delete);
|
||||||
GameObject.Find("StatueIsland_Body").SetActive(false);
|
DisableBody(GameObject.Find("StatueIsland_Body"), delete);
|
||||||
GameObject.Find("ConstructionYardIsland_Body").SetActive(false);
|
DisableBody(GameObject.Find("ConstructionYardIsland_Body"), delete);
|
||||||
GameObject.Find("GabbroShip_Body").SetActive(false);
|
DisableBody(GameObject.Find("GabbroShip_Body"), delete);
|
||||||
|
|
||||||
foreach (var jelly in GameObject.FindObjectsOfType<JellyfishController>())
|
foreach (var jelly in GameObject.FindObjectsOfType<JellyfishController>())
|
||||||
{
|
{
|
||||||
jelly.gameObject.SetActive(false);
|
DisableBody(jelly.gameObject, delete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.WhiteHole)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.WhiteHole)
|
||||||
{
|
{
|
||||||
GameObject.Find("WhiteholeStation_Body").SetActive(false);
|
DisableBody(GameObject.Find("WhiteholeStation_Body"), delete);
|
||||||
GameObject.Find("WhiteholeStationSuperstructure_Body").SetActive(false);
|
DisableBody(GameObject.Find("WhiteholeStationSuperstructure_Body"), delete);
|
||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.TimberHearth)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.TimberHearth)
|
||||||
{
|
{
|
||||||
GameObject.Find("MiningRig_Body").SetActive(false);
|
// Always just fucking kill this one to stop THE WARP BUG!!!
|
||||||
|
DisableBody(GameObject.Find("StreamingGroup_TH"), true);
|
||||||
|
|
||||||
|
DisableBody(GameObject.Find("MiningRig_Body"), delete);
|
||||||
|
|
||||||
foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>())
|
foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>())
|
||||||
{
|
{
|
||||||
GameObject.Destroy(obj);
|
DisableBody(obj.gameObject, true);
|
||||||
}
|
}
|
||||||
foreach (var obj in GameObject.FindObjectsOfType<VillageMusicVolume>())
|
foreach (var obj in GameObject.FindObjectsOfType<VillageMusicVolume>())
|
||||||
{
|
{
|
||||||
GameObject.Destroy(obj);
|
DisableBody(obj.gameObject, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.Sun)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.Sun)
|
||||||
@ -172,8 +178,8 @@ namespace NewHorizons.Builder.General
|
|||||||
}
|
}
|
||||||
else if (ao.GetAstroObjectName() == AstroObject.Name.DreamWorld)
|
else if (ao.GetAstroObjectName() == AstroObject.Name.DreamWorld)
|
||||||
{
|
{
|
||||||
GameObject.Find("BackRaft_Body").SetActive(false);
|
DisableBody(GameObject.Find("BackRaft_Body"), delete);
|
||||||
GameObject.Find("SealRaft_Body").SetActive(false);
|
DisableBody(GameObject.Find("SealRaft_Body"), delete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@ -186,14 +192,13 @@ namespace NewHorizons.Builder.General
|
|||||||
{
|
{
|
||||||
if (p.GetValue<AstroObject>("_originalBody") == ao.gameObject)
|
if (p.GetValue<AstroObject>("_originalBody") == ao.gameObject)
|
||||||
{
|
{
|
||||||
p.gameObject.SetActive(false);
|
DisableBody(p.gameObject, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RemoveProxy(ao.name.Replace("_Body", ""));
|
RemoveProxy(ao.name.Replace("_Body", ""));
|
||||||
|
|
||||||
// For TH we wait until the player is fully loaded in
|
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => DisableBody(ao.gameObject, delete));
|
||||||
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => ao.transform.root.gameObject.SetActive(false));
|
|
||||||
|
|
||||||
foreach (ProxyBody proxy in GameObject.FindObjectsOfType<ProxyBody>())
|
foreach (ProxyBody proxy in GameObject.FindObjectsOfType<ProxyBody>())
|
||||||
{
|
{
|
||||||
@ -209,7 +214,14 @@ namespace NewHorizons.Builder.General
|
|||||||
public static void RemoveDistantProxyClones()
|
public static void RemoveDistantProxyClones()
|
||||||
{
|
{
|
||||||
GameObject.Destroy(GameObject.FindObjectOfType<DistantProxyManager>().gameObject);
|
GameObject.Destroy(GameObject.FindObjectOfType<DistantProxyManager>().gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DisableBody(GameObject go, bool delete)
|
||||||
|
{
|
||||||
|
if (go == null) return;
|
||||||
|
|
||||||
|
if (delete) GameObject.Destroy(go);
|
||||||
|
else go.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RemoveProxy(string name)
|
private static void RemoveProxy(string name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user