quantum-space-buddies/QSB/TornadoSync/TornadoManager.cs
2021-12-04 06:21:11 -08:00

47 lines
1.4 KiB
C#

using QSB.TornadoSync.TransformSync;
using QSB.TornadoSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET;
using UnityEngine;
namespace QSB.TornadoSync
{
public class TornadoManager : WorldObjectManager
{
protected override void RebuildWorldObjects(OWScene scene)
{
QSBWorldSync.Init<QSBTornado, TornadoController>();
foreach (var transformSync in QSBWorldSync.GetWorldObjects<OccasionalTransformSync>())
{
QNetworkServer.Destroy(transformSync.gameObject);
}
// islands
foreach (var islandController in QSBWorldSync.GetWorldObjects<IslandController>())
{
var transformSync = Instantiate(QSBNetworkManager.Instance.OccasionalPrefab).GetComponent<OccasionalTransformSync>();
transformSync.InitBodyIndexes(islandController._islandBody, Locator._giantsDeep.GetOWRigidbody());
transformSync.gameObject.SpawnWithServerAuthority();
}
// cannon parts
foreach (var partName in new[]
{
"OrbitalProbeCannon_Body",
"CannonBarrel_Body",
"CannonMuzzle_Body",
"Debris_Body (1)",
"Debris_Body (2)"
})
{
var transformSync = Instantiate(QSBNetworkManager.Instance.OccasionalPrefab).GetComponent<OccasionalTransformSync>();
transformSync.InitBodyIndexes(GameObject.Find(partName).GetAttachedOWRigidbody(),
Locator._giantsDeep.GetOWRigidbody());
transformSync.gameObject.SpawnWithServerAuthority();
}
}
}
}