diff --git a/QSB/ShipSync/TransformSync/ShipTransformSync.cs b/QSB/ShipSync/TransformSync/ShipTransformSync.cs index 15592695..770110b7 100644 --- a/QSB/ShipSync/TransformSync/ShipTransformSync.cs +++ b/QSB/ShipSync/TransformSync/ShipTransformSync.cs @@ -31,8 +31,7 @@ namespace QSB.ShipSync.TransformSync protected override void ApplyToAttached() { ApplyToSector(); - - if (ReferenceTransform == null || transform.position == Vector3.zero) + if (!ReferenceTransform) { return; } diff --git a/QSB/Syncs/Sectored/BaseSectoredSync.cs b/QSB/Syncs/Sectored/BaseSectoredSync.cs index 8a2345ba..1c55d4ed 100644 --- a/QSB/Syncs/Sectored/BaseSectoredSync.cs +++ b/QSB/Syncs/Sectored/BaseSectoredSync.cs @@ -48,14 +48,7 @@ namespace QSB.Syncs.Sectored protected void GetFromSector() { - if (ReferenceSector != null) - { - _sectorId = ReferenceSector.ObjectId; - } - else - { - _sectorId = -1; - } + _sectorId = ReferenceSector?.ObjectId ?? -1; } protected void ApplyToSector() diff --git a/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs b/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs index 9c806564..c41d1bef 100644 --- a/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs +++ b/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs @@ -50,28 +50,21 @@ namespace QSB.Syncs.Sectored.Rigidbodies protected override void GetFromAttached() { GetFromSector(); + if (!ReferenceTransform) + { + return; + } - if (ReferenceTransform != null) - { - transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition()); - transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation()); - _relativeVelocity = ReferenceTransform.GetAttachedOWRigidbody().ToRelVel(AttachedRigidbody.GetVelocity(), AttachedRigidbody.GetPosition()); - _relativeAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().ToRelAngVel(AttachedRigidbody.GetAngularVelocity()); - } - else - { - transform.position = Vector3.zero; - transform.rotation = Quaternion.identity; - _relativeVelocity = Vector3.zero; - _relativeAngularVelocity = Vector3.zero; - } + transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition()); + transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation()); + _relativeVelocity = ReferenceTransform.GetAttachedOWRigidbody().ToRelVel(AttachedRigidbody.GetVelocity(), AttachedRigidbody.GetPosition()); + _relativeAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().ToRelAngVel(AttachedRigidbody.GetAngularVelocity()); } protected override void ApplyToAttached() { ApplyToSector(); - - if (ReferenceTransform == null || transform.position == Vector3.zero) + if (!ReferenceTransform) { return; } diff --git a/QSB/Syncs/Sectored/Transforms/SectoredTransformSync.cs b/QSB/Syncs/Sectored/Transforms/SectoredTransformSync.cs index c6fe7eb4..0f296acb 100644 --- a/QSB/Syncs/Sectored/Transforms/SectoredTransformSync.cs +++ b/QSB/Syncs/Sectored/Transforms/SectoredTransformSync.cs @@ -1,5 +1,4 @@ -using Mirror; -using QSB.Utility; +using QSB.Utility; using UnityEngine; namespace QSB.Syncs.Sectored.Transforms @@ -12,36 +11,22 @@ namespace QSB.Syncs.Sectored.Transforms protected override Transform InitAttachedTransform() => hasAuthority ? InitLocalTransform() : InitRemoteTransform(); - protected override void Deserialize(NetworkReader reader, bool initialState) - { - base.Deserialize(reader, initialState); - - if (transform.position == Vector3.zero) - { - } - } - protected override void GetFromAttached() { GetFromSector(); + if (!ReferenceTransform) + { + return; + } - if (ReferenceTransform != null) - { - transform.position = ReferenceTransform.ToRelPos(AttachedTransform.position); - transform.rotation = ReferenceTransform.ToRelRot(AttachedTransform.rotation); - } - else - { - transform.position = Vector3.zero; - transform.rotation = Quaternion.identity; - } + transform.position = ReferenceTransform.ToRelPos(AttachedTransform.position); + transform.rotation = ReferenceTransform.ToRelRot(AttachedTransform.rotation); } protected override void ApplyToAttached() { ApplyToSector(); - - if (ReferenceTransform == null || transform.position == Vector3.zero) + if (!ReferenceTransform) { return; }