2021-12-06 03:09:23 -08:00
|
|
|
|
using QSB.TornadoSync.TransformSync;
|
2021-12-04 06:21:11 -08:00
|
|
|
|
using QSB.TornadoSync.WorldObjects;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using QSB.WorldSync;
|
2021-12-06 03:09:23 -08:00
|
|
|
|
using QuantumUNET;
|
2021-12-04 06:21:11 -08:00
|
|
|
|
|
|
|
|
|
namespace QSB.TornadoSync
|
|
|
|
|
{
|
|
|
|
|
public class TornadoManager : WorldObjectManager
|
|
|
|
|
{
|
2021-12-20 18:41:12 -08:00
|
|
|
|
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
|
|
|
|
|
2021-12-06 03:09:23 -08:00
|
|
|
|
protected override void RebuildWorldObjects(OWScene scene)
|
|
|
|
|
{
|
2021-12-04 06:21:11 -08:00
|
|
|
|
QSBWorldSync.Init<QSBTornado, TornadoController>();
|
|
|
|
|
|
2021-12-06 03:09:23 -08:00
|
|
|
|
if (!QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var transformSync in QSBWorldSync.GetUnityObjects<OccasionalTransformSync>())
|
|
|
|
|
{
|
|
|
|
|
QNetworkServer.Destroy(transformSync.gameObject);
|
|
|
|
|
}
|
2021-12-04 06:21:11 -08:00
|
|
|
|
|
2021-12-05 23:09:08 -08:00
|
|
|
|
var gdBody = Locator._giantsDeep.GetOWRigidbody();
|
2021-12-05 21:30:04 -08:00
|
|
|
|
// cannon
|
|
|
|
|
var cannon = Locator._orbitalProbeCannon.GetRequiredComponent<OrbitalProbeLaunchController>();
|
2021-12-06 03:09:23 -08:00
|
|
|
|
SpawnOccasional(cannon.GetAttachedOWRigidbody(), gdBody);
|
|
|
|
|
foreach (var proxy in cannon._realDebrisSectorProxies)
|
2021-12-04 06:21:11 -08:00
|
|
|
|
{
|
2021-12-06 03:09:23 -08:00
|
|
|
|
SpawnOccasional(proxy.transform.root.GetAttachedOWRigidbody(), gdBody);
|
2021-12-04 18:34:00 -08:00
|
|
|
|
}
|
2021-12-06 03:09:23 -08:00
|
|
|
|
SpawnOccasional(cannon._probeBody, gdBody);
|
2021-12-04 18:34:00 -08:00
|
|
|
|
|
|
|
|
|
// islands
|
2021-12-05 21:30:04 -08:00
|
|
|
|
foreach (var island in QSBWorldSync.GetUnityObjects<IslandController>())
|
2021-12-04 18:34:00 -08:00
|
|
|
|
{
|
2021-12-06 03:09:23 -08:00
|
|
|
|
SpawnOccasional(island._islandBody, gdBody);
|
2021-12-04 06:21:11 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-06 03:09:23 -08:00
|
|
|
|
|
|
|
|
|
private static void SpawnOccasional(OWRigidbody body, OWRigidbody refBody)
|
|
|
|
|
{
|
|
|
|
|
var transformSync = Instantiate(QSBNetworkManager.Instance.OccasionalPrefab).GetRequiredComponent<OccasionalTransformSync>();
|
|
|
|
|
transformSync.InitBodyIndexes(body, refBody);
|
|
|
|
|
transformSync.gameObject.SpawnWithServerAuthority();
|
|
|
|
|
}
|
2021-12-04 06:21:11 -08:00
|
|
|
|
}
|
|
|
|
|
}
|