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

44 lines
1.1 KiB
C#
Raw Normal View History

2022-05-28 19:39:42 +00:00
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();
}
2022-08-28 04:56:18 +00:00
// Is 0 by default -> 2D
QSBWorldSync.GetUnityObject<RemoteFlightConsole>()._consoleAudio.spatialBlend = 1;
}
public override void UnbuildWorldObjects()
2022-05-28 19:39:42 +00:00
{
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);
}
}
}
}