36 lines
1.2 KiB
C#
Raw Normal View History

2022-05-14 12:18:48 +01:00
using QSB.ShipSync.WorldObjects;
using QSB.Syncs.Sectored.Rigidbodies;
using QSB.Utility.LinkedWorldObject;
using QSB.WorldSync;
namespace QSB.ShipSync.TransformSync;
internal class ShipLegTransformSync : SectoredRigidbodySync, ILinkedNetworkBehaviour
{
/// <summary>
/// normally prints error when attached object is null.
/// this overrides it so that doesn't happen, since the module can be destroyed.
/// </summary>
protected override bool CheckValid()
=> AttachedTransform
2022-05-19 15:31:05 -07:00
&& base.CheckValid();
2022-05-14 12:18:48 +01:00
2022-08-24 08:15:42 +01:00
protected override bool CheckReady()
=> base.CheckReady()
2022-08-24 13:26:32 -07:00
&& _qsbModule != null // not sure how either of these can be null, but i guess better safe than sorry
&& _qsbModule.AttachedObject != null
&& _qsbModule.AttachedObject.isDetached;
2022-05-14 12:18:48 +01:00
protected override bool UseInterpolation => true;
private QSBShipDetachableLeg _qsbModule;
public void SetWorldObject(IWorldObject worldObject) => _qsbModule = (QSBShipDetachableLeg)worldObject;
protected override OWRigidbody InitAttachedRigidbody()
{
var owRigidbody = _qsbModule.AttachedObject.GetComponent<OWRigidbody>();
SectorDetector.Init(owRigidbody.transform.Find("DetectorVolume").GetComponent<SectorDetector>());
return owRigidbody;
}
}