mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 18:32:45 +00:00
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using QSB.Player;
|
|
using QSB.SectorSync;
|
|
using QSB.Syncs.RigidbodySync;
|
|
using QSB.Utility;
|
|
|
|
namespace QSB.ShipSync.TransformSync
|
|
{
|
|
public class ShipTransformSync : SectoredRigidbodySync
|
|
{
|
|
public static ShipTransformSync LocalInstance { get; private set; }
|
|
|
|
public override bool IsReady
|
|
=> Locator.GetShipBody() != null;
|
|
|
|
public override void Start()
|
|
{
|
|
DebugLog.DebugWrite($"START!");
|
|
base.Start();
|
|
LocalInstance = this;
|
|
}
|
|
|
|
protected override OWRigidbody GetRigidbody()
|
|
{
|
|
SectorSync.Init(Locator.GetShipDetector().GetComponent<SectorDetector>(), this);
|
|
return Locator.GetShipBody();
|
|
}
|
|
|
|
protected override void UpdateTransform()
|
|
{
|
|
if (HasAuthority && ShipManager.Instance.CurrentFlyer != QSBPlayerManager.LocalPlayerId && ShipManager.Instance.CurrentFlyer != uint.MaxValue)
|
|
{
|
|
DebugLog.ToConsole("Warning - Has authority, but is not current flyer!", OWML.Common.MessageType.Warning);
|
|
return;
|
|
}
|
|
|
|
if (!HasAuthority && ShipManager.Instance.CurrentFlyer == QSBPlayerManager.LocalPlayerId)
|
|
{
|
|
DebugLog.ToConsole($"Warning - Doesn't have authority, but is current flyer!", OWML.Common.MessageType.Warning);
|
|
return;
|
|
}
|
|
|
|
base.UpdateTransform();
|
|
}
|
|
|
|
public override TargetType Type => TargetType.Ship;
|
|
|
|
public override bool UseInterpolation => true;
|
|
protected override float DistanceLeeway => 20f;
|
|
}
|
|
} |