mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-17 01:13:05 +00:00
simplify ReferenceTransform check
This commit is contained in:
parent
f035f64d10
commit
c3422177ab
@ -31,8 +31,7 @@ namespace QSB.ShipSync.TransformSync
|
||||
protected override void ApplyToAttached()
|
||||
{
|
||||
ApplyToSector();
|
||||
|
||||
if (ReferenceTransform == null || transform.position == Vector3.zero)
|
||||
if (!ReferenceTransform)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user