quantum-space-buddies/QSB/TornadoSync/TornadoManager.cs

53 lines
1.5 KiB
C#
Raw Normal View History

using Mirror;
using QSB.TornadoSync.TransformSync;
2021-12-04 14:21:11 +00:00
using QSB.TornadoSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
namespace QSB.TornadoSync
{
public class TornadoManager : WorldObjectManager
{
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
public override void BuildWorldObjects(OWScene scene)
{
2021-12-04 14:21:11 +00:00
QSBWorldSync.Init<QSBTornado, TornadoController>();
if (!QSBCore.IsHost)
{
return;
}
foreach (var transformSync in QSBWorldSync.GetUnityObjects<OccasionalTransformSync>())
{
NetworkServer.Destroy(transformSync.gameObject);
}
2021-12-04 14:21:11 +00:00
var gdBody = Locator._giantsDeep.GetOWRigidbody();
2021-12-06 05:30:04 +00:00
// cannon
var cannon = Locator._orbitalProbeCannon.GetRequiredComponent<OrbitalProbeLaunchController>();
SpawnOccasional(cannon.GetAttachedOWRigidbody(), gdBody);
foreach (var proxy in cannon._realDebrisSectorProxies)
2021-12-04 14:21:11 +00:00
{
SpawnOccasional(proxy.transform.root.GetAttachedOWRigidbody(), gdBody);
}
2022-01-01 22:19:10 +00:00
SpawnOccasional(cannon._probeBody, gdBody);
// islands
2021-12-06 05:30:04 +00:00
foreach (var island in QSBWorldSync.GetUnityObjects<IslandController>())
{
SpawnOccasional(island._islandBody, gdBody);
2021-12-04 14:21:11 +00:00
}
}
private static void SpawnOccasional(OWRigidbody body, OWRigidbody refBody)
{
2022-01-15 06:25:23 +00:00
var transformSync = Instantiate(QSBNetworkManager.singleton.OccasionalPrefab).GetRequiredComponent<OccasionalTransformSync>();
transformSync.InitBodyIndexes(body, refBody);
transformSync.gameObject.SpawnWithServerAuthority();
}
2021-12-04 14:21:11 +00:00
}
}