Skip to content

Commit 2705ffb

Browse files
author
Dorian Stoll
committedAug 16, 2017
Fix #197
1 parent 6882763 commit 2705ffb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎Kopernicus/Kopernicus/Configuration/Loader.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,16 @@ void IParserEventSubscriber.PostApply(ConfigNode node)
256256
body.Value.generatedBody.transform.parent = systemPrefab.transform;
257257

258258
// Delete ghost space centers
259-
if (!body.Value.generatedBody.celestialBody.isHomeWorld)
259+
if (!body.Value.generatedBody.celestialBody.isHomeWorld && body.Value.generatedBody.pqsVersion != null)
260260
{
261-
UnityEngine.Object.Destroy(body.Value.generatedBody.pqsVersion.GetComponentInChildren<SpaceCenter>());
261+
SpaceCenter[] centers = body.Value.generatedBody.pqsVersion.GetComponentsInChildren<SpaceCenter>(true);
262+
if (centers != null)
263+
{
264+
foreach (SpaceCenter c in centers)
265+
{
266+
UnityEngine.Object.Destroy(c);
267+
}
268+
}
262269
}
263270
}
264271

‎Kopernicus/Kopernicus/Injector.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void PostSpawnFixups()
118118
Debug.Log("[Kopernicus]: Post-Spawn");
119119

120120
// Fix the SpaceCenter
121-
SpaceCenter.Instance = PSystemManager.Instance.localBodies.First(cb => cb.isHomeWorld).GetComponentInChildren<SpaceCenter>();
121+
SpaceCenter.Instance = PSystemManager.Instance.localBodies.First(cb => cb.isHomeWorld).GetComponentsInChildren<SpaceCenter>(true).FirstOrDefault();
122122
SpaceCenter.Instance.Start();
123123

124124
// Fix the flight globals index of each body and patch it's SOI

0 commit comments

Comments
 (0)
Please sign in to comment.