quantum-space-buddies/QSB/ShipSync/TransformSync/ShipModuleTransformSync.cs

32 lines
1.1 KiB
C#
Raw Normal View History

2022-05-14 11:18:48 +00:00
using QSB.ShipSync.WorldObjects;
using QSB.Syncs.Sectored.Rigidbodies;
using QSB.Utility.LinkedWorldObject;
using QSB.WorldSync;
namespace QSB.ShipSync.TransformSync;
internal class ShipModuleTransformSync : 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 22:31:05 +00:00
&& base.CheckValid();
2022-05-14 11:18:48 +00:00
protected override bool CheckReady() => base.CheckReady() && _qsbModule.AttachedObject.isDetached;
2022-05-14 11:18:48 +00:00
protected override bool UseInterpolation => true;
private QSBShipDetachableModule _qsbModule;
public void SetWorldObject(IWorldObject worldObject) => _qsbModule = (QSBShipDetachableModule)worldObject;
protected override OWRigidbody InitAttachedRigidbody()
{
var owRigidbody = _qsbModule.AttachedObject.GetComponent<OWRigidbody>();
SectorDetector.Init(owRigidbody.transform.Find("DetectorVolume").GetComponent<SectorDetector>());
return owRigidbody;
}
}