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

36 lines
1.2 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;
2023-07-28 18:30:57 +00:00
public class ShipModuleTransformSync : SectoredRigidbodySync, ILinkedNetworkBehaviour
2022-05-14 11:18:48 +00:00
{
/// <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
2022-08-24 07:15:42 +00:00
protected override bool CheckReady()
=> base.CheckReady()
2022-08-24 20:26:32 +00: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 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;
}
}