2021-12-05 02:34:00 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using QSB.TornadoSync.TransformSync;
|
2021-12-04 14:21:11 +00:00
|
|
|
|
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>();
|
|
|
|
|
|
2021-12-05 02:34:00 +00:00
|
|
|
|
if (!QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-04 14:21:11 +00:00
|
|
|
|
foreach (var transformSync in QSBWorldSync.GetWorldObjects<OccasionalTransformSync>())
|
|
|
|
|
{
|
|
|
|
|
QNetworkServer.Destroy(transformSync.gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 02:34:00 +00:00
|
|
|
|
// cannon parts
|
|
|
|
|
var mainCannonPart = GameObject.Find("OrbitalProbeCannon_Body").GetAttachedOWRigidbody();
|
2021-12-04 14:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
var transformSync = Instantiate(QSBNetworkManager.Instance.OccasionalPrefab).GetComponent<OccasionalTransformSync>();
|
2021-12-05 02:34:00 +00:00
|
|
|
|
transformSync.InitBodyIndexes(mainCannonPart, Locator._giantsDeep.GetOWRigidbody());
|
2021-12-04 14:21:11 +00:00
|
|
|
|
transformSync.gameObject.SpawnWithServerAuthority();
|
|
|
|
|
}
|
2021-12-05 02:34:00 +00:00
|
|
|
|
foreach (var cannonPartNames in new[]
|
2021-12-04 14:21:11 +00:00
|
|
|
|
{
|
|
|
|
|
"CannonBarrel_Body",
|
|
|
|
|
"CannonMuzzle_Body",
|
|
|
|
|
"Debris_Body (1)",
|
|
|
|
|
"Debris_Body (2)"
|
|
|
|
|
})
|
|
|
|
|
{
|
2021-12-05 02:34:00 +00:00
|
|
|
|
var cannonPart = GameObject.Find(cannonPartNames).GetAttachedOWRigidbody();
|
|
|
|
|
var transformSync = Instantiate(QSBNetworkManager.Instance.OccasionalPrefab).GetComponent<OccasionalTransformSync>();
|
|
|
|
|
transformSync.InitBodyIndexes(cannonPart, mainCannonPart);
|
|
|
|
|
transformSync.gameObject.SpawnWithServerAuthority();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// islands
|
|
|
|
|
var islandControllers = QSBWorldSync.GetWorldObjects<IslandController>().ToArray();
|
|
|
|
|
DebugLog.DebugWrite($"there are {islandControllers.Length} islandControllers");
|
|
|
|
|
foreach (var islandNames in new[]
|
|
|
|
|
{
|
|
|
|
|
"GabbroIsland_Body",
|
|
|
|
|
"StatueIsland_Body",
|
|
|
|
|
"ConstructionYardIsland_Body",
|
|
|
|
|
"BrambleIsland_Body"
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
var island = GameObject.Find(islandNames).GetAttachedOWRigidbody();
|
2021-12-04 14:21:11 +00:00
|
|
|
|
var transformSync = Instantiate(QSBNetworkManager.Instance.OccasionalPrefab).GetComponent<OccasionalTransformSync>();
|
2021-12-05 02:34:00 +00:00
|
|
|
|
transformSync.InitBodyIndexes(island, Locator._giantsDeep.GetOWRigidbody());
|
2021-12-04 14:21:11 +00:00
|
|
|
|
transformSync.gameObject.SpawnWithServerAuthority();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|