quantum-space-buddies/QSB/ModelShip/ModelShipManager.cs

41 lines
1.0 KiB
C#

using Cysharp.Threading.Tasks;
using Mirror;
using OWML.Common;
using QSB.ModelShip.TransformSync;
using QSB.Utility;
using QSB.WorldSync;
using System.Threading;
namespace QSB.ModelShip;
internal class ModelShipManager : WorldObjectManager
{
public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem;
public override bool DlcOnly => false;
public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct)
{
if (QSBCore.IsHost)
{
Instantiate(QSBNetworkManager.singleton.ModelShipPrefab).SpawnWithServerAuthority();
}
}
public override void UnbuildWorldObjects()
{
if (QSBCore.IsHost)
{
if (ModelShipTransformSync.LocalInstance != null)
{
if (ModelShipTransformSync.LocalInstance.gameObject == null)
{
DebugLog.ToConsole($"Warning - ShipTransformSync's LocalInstance is not null, but it's gameobject is null!", MessageType.Warning);
return;
}
NetworkServer.Destroy(ModelShipTransformSync.LocalInstance.gameObject);
}
}
}
}