48 lines
1.1 KiB
C#
Raw Normal View History

2021-05-15 14:10:51 +01:00
using QSB.Player;
using QSB.SectorSync;
using QSB.Syncs.RigidbodySync;
2021-05-10 20:26:44 +01:00
using QSB.Utility;
2021-04-11 17:05:02 +01:00
namespace QSB.ShipSync.TransformSync
{
public class ShipTransformSync : SectoredRigidbodySync
2020-12-02 21:29:53 +00:00
{
2021-05-10 14:30:38 +01:00
public static ShipTransformSync LocalInstance { get; private set; }
2020-12-02 21:29:53 +00:00
2021-05-10 14:32:47 +01:00
public override bool IsReady
=> Locator.GetShipBody() != null;
2021-05-10 14:30:38 +01:00
2021-05-10 20:26:44 +01:00
public override void Start()
{
DebugLog.DebugWrite($"START!");
base.Start();
LocalInstance = this;
}
2020-12-02 21:29:53 +00:00
protected override OWRigidbody GetRigidbody()
2021-03-09 19:45:00 +00:00
{
2021-05-15 14:10:51 +01:00
SectorSync.Init(Locator.GetShipDetector().GetComponent<SectorDetector>(), this);
return Locator.GetShipBody();
2021-05-10 20:26:44 +01:00
}
2021-05-15 14:10:51 +01:00
protected override void UpdateTransform()
{
if (HasAuthority && ShipManager.Instance.CurrentFlyer != QSBPlayerManager.LocalPlayerId)
{
return;
}
if (!HasAuthority && ShipManager.Instance.CurrentFlyer == QSBPlayerManager.LocalPlayerId)
{
return;
}
base.UpdateTransform();
}
public override TargetType Type => TargetType.Ship;
public override bool UseInterpolation => true;
protected override float DistanceLeeway => 20f;
2020-12-02 21:29:53 +00:00
}
2020-12-03 08:28:05 +00:00
}