Track AO children in AOLocator

This commit is contained in:
Nick 2022-05-07 02:48:31 -04:00
parent 100b3f1b46
commit 59109671c9
3 changed files with 63 additions and 48 deletions

View File

@ -91,55 +91,24 @@ 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)
{
DisableBody(GameObject.Find("TimeLoopRing_Body"), delete);
}
DisableBody(GameObject.Find("FocalBody"), delete); DisableBody(GameObject.Find("FocalBody"), delete);
} }
else if (ao.GetAstroObjectName() == AstroObject.Name.MapSatellite) else if (ao.GetAstroObjectName() == AstroObject.Name.MapSatellite)
{ {
DisableBody(GameObject.Find("MapSatellite_Body"), delete); DisableBody(GameObject.Find("MapSatellite_Body"), delete);
} }
else if (ao.GetAstroObjectName() == AstroObject.Name.ProbeCannon)
{
DisableBody(GameObject.Find("NomaiProbe_Body"), delete);
DisableBody(GameObject.Find("CannonMuzzle_Body"), delete);
DisableBody(GameObject.Find("FakeCannonMuzzle_Body (1)"), delete);
DisableBody(GameObject.Find("CannonBarrel_Body"), delete);
DisableBody(GameObject.Find("FakeCannonBarrel_Body (1)"), delete);
DisableBody(GameObject.Find("Debris_Body (1)"), delete);
}
else if (ao.GetAstroObjectName() == AstroObject.Name.SunStation)
{
DisableBody(GameObject.Find("SS_Debris_Body"), delete);
}
else if (ao.GetAstroObjectName() == AstroObject.Name.GiantsDeep) else if (ao.GetAstroObjectName() == AstroObject.Name.GiantsDeep)
{ {
DisableBody(GameObject.Find("BrambleIsland_Body"), delete);
DisableBody(GameObject.Find("GabbroIsland_Body"), delete);
DisableBody(GameObject.Find("QuantumIsland_Body"), delete);
DisableBody(GameObject.Find("StatueIsland_Body"), delete);
DisableBody(GameObject.Find("ConstructionYardIsland_Body"), delete);
DisableBody(GameObject.Find("GabbroShip_Body"), delete);
foreach (var jelly in GameObject.FindObjectsOfType<JellyfishController>()) foreach (var jelly in GameObject.FindObjectsOfType<JellyfishController>())
{ {
DisableBody(jelly.gameObject, delete); DisableBody(jelly.gameObject, delete);
} }
} }
else if (ao.GetAstroObjectName() == AstroObject.Name.WhiteHole)
{
DisableBody(GameObject.Find("WhiteholeStation_Body"), delete);
DisableBody(GameObject.Find("WhiteholeStationSuperstructure_Body"), delete);
}
else if (ao.GetAstroObjectName() == AstroObject.Name.TimberHearth) else if (ao.GetAstroObjectName() == AstroObject.Name.TimberHearth)
{ {
// Always just fucking kill this one to stop THE WARP BUG!!! // Always just fucking kill this one to stop THE WARP BUG!!!
DisableBody(GameObject.Find("StreamingGroup_TH"), true); 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>())
{ {
DisableBody(obj.gameObject, true); DisableBody(obj.gameObject, true);
@ -176,10 +145,11 @@ namespace NewHorizons.Builder.General
GameObject.Destroy(sunProxy.gameObject); GameObject.Destroy(sunProxy.gameObject);
} }
} }
else if (ao.GetAstroObjectName() == AstroObject.Name.DreamWorld)
// Just delete the children
foreach(var child in AstroObjectLocator.GetChildren(ao))
{ {
DisableBody(GameObject.Find("BackRaft_Body"), delete); DisableBody(child, true);
DisableBody(GameObject.Find("SealRaft_Body"), delete);
} }
} }
catch(Exception e) catch(Exception e)

View File

@ -210,7 +210,7 @@ namespace NewHorizons
NewHorizonsData.Load(); NewHorizonsData.Load();
SignalBuilder.Init(); SignalBuilder.Init();
AstroObjectLocator.RefreshList(); AstroObjectLocator.Init();
OWAssetHandler.Init(); OWAssetHandler.Init();
PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]); PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]);
SystemCreationHandler.LoadSystem(SystemDict[CurrentStarSystem]); SystemCreationHandler.LoadSystem(SystemDict[CurrentStarSystem]);

View File

@ -17,6 +17,16 @@ namespace NewHorizons.Utility
private static List<AstroObject> _list = new List<AstroObject>(); private static List<AstroObject> _list = new List<AstroObject>();
public static void Init()
{
_list = new List<AstroObject>();
_customAstroObjectDictionary = new Dictionary<string, AstroObject>();
foreach (AstroObject ao in GameObject.FindObjectsOfType<AstroObject>())
{
AddAstroObject(ao);
}
}
public static AstroObject GetAstroObject(string name, bool flag = false) public static AstroObject GetAstroObject(string name, bool flag = false)
{ {
if (_customAstroObjectDictionary.ContainsKey(name)) return _customAstroObjectDictionary[name]; if (_customAstroObjectDictionary.ContainsKey(name)) return _customAstroObjectDictionary[name];
@ -98,16 +108,6 @@ namespace NewHorizons.Utility
_customAstroObjectDictionary.Remove(ao.GetCustomName()); _customAstroObjectDictionary.Remove(ao.GetCustomName());
} }
public static void RefreshList()
{
_customAstroObjectDictionary = new Dictionary<string, AstroObject>();
_list = new List<AstroObject>();
foreach (AstroObject ao in GameObject.FindObjectsOfType<AstroObject>())
{
AddAstroObject(ao);
}
}
public static AstroObject[] GetAllAstroObjects() public static AstroObject[] GetAllAstroObjects()
{ {
return _list.ToArray(); return _list.ToArray();
@ -123,9 +123,54 @@ namespace NewHorizons.Utility
_list.Remove(ao); _list.Remove(ao);
} }
public static AstroObject[] GetMoons(AstroObject primary) public static GameObject[] GetMoons(AstroObject primary)
{ {
return _list.Where(x => x._primaryBody == primary).ToArray(); return _list.Where(x => x._primaryBody == primary).Select(x => x.gameObject).ToArray();
}
public static GameObject[] GetChildren(AstroObject primary)
{
var otherChildren = new List<GameObject>();
switch(primary.GetAstroObjectName())
{
case AstroObject.Name.TowerTwin:
otherChildren.Add(GameObject.Find("TimeLoopRing_Body"));
break;
case AstroObject.Name.ProbeCannon:
otherChildren.Add(GameObject.Find("NomaiProbe_Body"));
otherChildren.Add(GameObject.Find("CannonMuzzle_Body"));
otherChildren.Add(GameObject.Find("FakeCannonMuzzle_Body (1)"));
otherChildren.Add(GameObject.Find("CannonBarrel_Body"));
otherChildren.Add(GameObject.Find("FakeCannonBarrel_Body (1)"));
otherChildren.Add(GameObject.Find("Debris_Body (1)"));
break;
case AstroObject.Name.SunStation:
otherChildren.Add(GameObject.Find("SS_Debris_Body"));
break;
case AstroObject.Name.GiantsDeep:
otherChildren.Add(GameObject.Find("BrambleIsland_Body"));
otherChildren.Add(GameObject.Find("GabbroIsland_Body"));
otherChildren.Add(GameObject.Find("QuantumIsland_Body"));
otherChildren.Add(GameObject.Find("StatueIsland_Body"));
otherChildren.Add(GameObject.Find("ConstructionYardIsland_Body"));
otherChildren.Add(GameObject.Find("GabbroShip_Body"));
break;
case AstroObject.Name.WhiteHole:
otherChildren.Add(GameObject.Find("WhiteholeStation_Body"));
otherChildren.Add(GameObject.Find("WhiteholeStationSuperstructure_Body"));
break;
case AstroObject.Name.TimberHearth:
otherChildren.Add(GameObject.Find("MiningRig_Body"));
break;
case AstroObject.Name.DreamWorld:
otherChildren.Add(GameObject.Find("BackRaft_Body"));
otherChildren.Add(GameObject.Find("SealRaft_Body"));
break;
default:
break;
}
return otherChildren.ToArray();
} }
} }
} }