mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Make remove children go last and on any body
This commit is contained in:
parent
90ef0e4beb
commit
56b439be66
@ -277,27 +277,6 @@ namespace NewHorizons.Handlers
|
||||
UpdateBodyOrbit(body, go);
|
||||
}
|
||||
|
||||
if (body.Config.removeChildren != null)
|
||||
{
|
||||
var goPath = go.transform.GetPath();
|
||||
var transforms = go.GetComponentsInChildren<Transform>(true);
|
||||
foreach (var childPath in body.Config.removeChildren)
|
||||
{
|
||||
// Multiple children can have the same path so we delete all that match
|
||||
var path = $"{goPath}/{childPath}";
|
||||
|
||||
var flag = true;
|
||||
foreach (var childObj in transforms.Where(x => x.GetPath() == path))
|
||||
{
|
||||
flag = false;
|
||||
// idk why we wait here but we do
|
||||
Delay.FireInNUpdates(() => childObj.gameObject.SetActive(false), 2);
|
||||
}
|
||||
|
||||
if (flag) Logger.LogWarning($"Couldn't find \"{childPath}\".");
|
||||
}
|
||||
}
|
||||
|
||||
// Do stuff that's shared between generating new planets and updating old ones
|
||||
go = SharedGenerateBody(body, go, sector, rb);
|
||||
|
||||
@ -589,6 +568,9 @@ namespace NewHorizons.Handlers
|
||||
SupernovaEffectBuilder.Make(go, sector, body.Config, procGen, ambientLight, fog, atmosphere, null, fog?._fogImpostor);
|
||||
}
|
||||
|
||||
// We allow removing children afterwards so you can also take bits off of the modules you used
|
||||
if (body.Config.removeChildren != null) RemoveChildren(go, body);
|
||||
|
||||
return go;
|
||||
}
|
||||
|
||||
@ -735,5 +717,26 @@ namespace NewHorizons.Handlers
|
||||
Main.FurthestOrbit = go.transform.position.magnitude + 30000f;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RemoveChildren(GameObject go, NewHorizonsBody body)
|
||||
{
|
||||
var goPath = go.transform.GetPath();
|
||||
var transforms = go.GetComponentsInChildren<Transform>(true);
|
||||
foreach (var childPath in body.Config.removeChildren)
|
||||
{
|
||||
// Multiple children can have the same path so we delete all that match
|
||||
var path = $"{goPath}/{childPath}";
|
||||
|
||||
var flag = true;
|
||||
foreach (var childObj in transforms.Where(x => x.GetPath() == path))
|
||||
{
|
||||
flag = false;
|
||||
// idk why we wait here but we do
|
||||
Delay.FireInNUpdates(() => childObj.gameObject.SetActive(false), 2);
|
||||
}
|
||||
|
||||
if (flag) Logger.LogWarning($"Couldn't find \"{childPath}\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user