2021-05-15 14:10:51 +01:00
|
|
|
using QSB.Player;
|
|
|
|
using QSB.SectorSync;
|
2021-05-15 11:25:47 +01:00
|
|
|
using QSB.Syncs.RigidbodySync;
|
2021-05-10 20:26:44 +01:00
|
|
|
using QSB.Utility;
|
2021-07-11 16:18:47 +01:00
|
|
|
using QSB.WorldSync;
|
2021-07-07 23:54:09 +01:00
|
|
|
using UnityEngine;
|
2020-02-21 21:51:58 +01:00
|
|
|
|
2021-04-11 17:05:02 +01:00
|
|
|
namespace QSB.ShipSync.TransformSync
|
2020-02-21 21:51:58 +01:00
|
|
|
{
|
2021-05-15 11:25:47 +01:00
|
|
|
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
|
2021-07-11 16:18:47 +01:00
|
|
|
=> Locator.GetShipBody() != null
|
|
|
|
&& WorldObjectManager.AllReady;
|
2021-05-10 14:30:38 +01:00
|
|
|
|
2021-05-10 20:26:44 +01:00
|
|
|
public override void Start()
|
|
|
|
{
|
|
|
|
base.Start();
|
|
|
|
LocalInstance = this;
|
|
|
|
}
|
2020-12-02 21:29:53 +00:00
|
|
|
|
2021-07-07 23:54:09 +01:00
|
|
|
protected override Component InitLocalTransform() => throw new System.NotImplementedException();
|
|
|
|
protected override Component InitRemoteTransform() => throw new System.NotImplementedException();
|
2021-07-07 22:12:41 +01:00
|
|
|
|
2021-05-15 11:25:47 +01: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);
|
2021-05-15 11:25:47 +01:00
|
|
|
return Locator.GetShipBody();
|
2021-05-10 20:26:44 +01:00
|
|
|
}
|
2021-05-15 14:10:51 +01:00
|
|
|
|
2021-07-11 16:18:47 +01:00
|
|
|
protected override bool UpdateTransform()
|
2021-05-15 14:10:51 +01:00
|
|
|
{
|
2021-06-13 20:51:01 +01:00
|
|
|
if (HasAuthority && ShipManager.Instance.CurrentFlyer != QSBPlayerManager.LocalPlayerId && ShipManager.Instance.CurrentFlyer != uint.MaxValue)
|
2021-05-15 14:10:51 +01:00
|
|
|
{
|
2021-06-15 18:57:03 +01:00
|
|
|
DebugLog.ToConsole("Warning - Has authority, but is not current flyer!", OWML.Common.MessageType.Warning);
|
2021-07-11 16:18:47 +01:00
|
|
|
return false;
|
2021-05-15 14:10:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!HasAuthority && ShipManager.Instance.CurrentFlyer == QSBPlayerManager.LocalPlayerId)
|
|
|
|
{
|
2021-06-15 18:57:03 +01:00
|
|
|
DebugLog.ToConsole($"Warning - Doesn't have authority, but is current flyer!", OWML.Common.MessageType.Warning);
|
2021-07-11 16:18:47 +01:00
|
|
|
return false;
|
2021-05-15 14:10:51 +01:00
|
|
|
}
|
|
|
|
|
2021-07-11 16:18:47 +01:00
|
|
|
return base.UpdateTransform();
|
2021-05-15 14:10:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override TargetType Type => TargetType.Ship;
|
|
|
|
|
|
|
|
public override bool UseInterpolation => true;
|
2021-05-26 20:43:00 +01:00
|
|
|
protected override float DistanceLeeway => 20f;
|
2020-12-02 21:29:53 +00:00
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
}
|