probe body doesn't exist on statue scene reload

This commit is contained in:
JohnCorby 2022-01-25 03:12:46 -08:00
parent 03cc8a84a0
commit a10c850a67

View File

@ -14,16 +14,6 @@ namespace QSB.TornadoSync
{
QSBWorldSync.Init<QSBTornado, TornadoController>();
if (QSBCore.IsHost)
{
foreach (var transformSync in QSBWorldSync.GetUnityObjects<OccasionalTransformSync>())
{
NetworkServer.Destroy(transformSync.gameObject);
}
}
OccasionalTransformSync.Bodies.Clear();
var gdBody = Locator._giantsDeep.GetOWRigidbody();
// cannon
var cannon = Locator._orbitalProbeCannon.GetRequiredComponent<OrbitalProbeLaunchController>();
@ -33,7 +23,10 @@ namespace QSB.TornadoSync
SpawnOccasional(proxy.transform.root.GetAttachedOWRigidbody(), gdBody);
}
SpawnOccasional(cannon._probeBody, gdBody);
if (cannon._probeBody)
{
SpawnOccasional(cannon._probeBody, gdBody);
}
// islands
foreach (var island in QSBWorldSync.GetUnityObjects<IslandController>().SortDeterministic())
@ -42,6 +35,19 @@ namespace QSB.TornadoSync
}
}
public override void UnbuildWorldObjects()
{
if (QSBCore.IsHost)
{
foreach (var transformSync in QSBWorldSync.GetUnityObjects<OccasionalTransformSync>())
{
NetworkServer.Destroy(transformSync.gameObject);
}
}
OccasionalTransformSync.Bodies.Clear();
}
private static void SpawnOccasional(OWRigidbody body, OWRigidbody refBody)
{
OccasionalTransformSync.Bodies.Add((body, refBody));