mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 03:32:47 +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()
|
protected override void ApplyToAttached()
|
||||||
{
|
{
|
||||||
ApplyToSector();
|
ApplyToSector();
|
||||||
|
if (!ReferenceTransform)
|
||||||
if (ReferenceTransform == null || transform.position == Vector3.zero)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,7 @@ namespace QSB.Syncs.Sectored
|
|||||||
|
|
||||||
protected void GetFromSector()
|
protected void GetFromSector()
|
||||||
{
|
{
|
||||||
if (ReferenceSector != null)
|
_sectorId = ReferenceSector?.ObjectId ?? -1;
|
||||||
{
|
|
||||||
_sectorId = ReferenceSector.ObjectId;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_sectorId = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ApplyToSector()
|
protected void ApplyToSector()
|
||||||
|
@ -50,28 +50,21 @@ namespace QSB.Syncs.Sectored.Rigidbodies
|
|||||||
protected override void GetFromAttached()
|
protected override void GetFromAttached()
|
||||||
{
|
{
|
||||||
GetFromSector();
|
GetFromSector();
|
||||||
|
if (!ReferenceTransform)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ReferenceTransform != null)
|
transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition());
|
||||||
{
|
transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation());
|
||||||
transform.position = ReferenceTransform.ToRelPos(AttachedRigidbody.GetPosition());
|
_relativeVelocity = ReferenceTransform.GetAttachedOWRigidbody().ToRelVel(AttachedRigidbody.GetVelocity(), AttachedRigidbody.GetPosition());
|
||||||
transform.rotation = ReferenceTransform.ToRelRot(AttachedRigidbody.GetRotation());
|
_relativeAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().ToRelAngVel(AttachedRigidbody.GetAngularVelocity());
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ApplyToAttached()
|
protected override void ApplyToAttached()
|
||||||
{
|
{
|
||||||
ApplyToSector();
|
ApplyToSector();
|
||||||
|
if (!ReferenceTransform)
|
||||||
if (ReferenceTransform == null || transform.position == Vector3.zero)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Mirror;
|
using QSB.Utility;
|
||||||
using QSB.Utility;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace QSB.Syncs.Sectored.Transforms
|
namespace QSB.Syncs.Sectored.Transforms
|
||||||
@ -12,36 +11,22 @@ namespace QSB.Syncs.Sectored.Transforms
|
|||||||
protected override Transform InitAttachedTransform()
|
protected override Transform InitAttachedTransform()
|
||||||
=> hasAuthority ? InitLocalTransform() : InitRemoteTransform();
|
=> hasAuthority ? InitLocalTransform() : InitRemoteTransform();
|
||||||
|
|
||||||
protected override void Deserialize(NetworkReader reader, bool initialState)
|
|
||||||
{
|
|
||||||
base.Deserialize(reader, initialState);
|
|
||||||
|
|
||||||
if (transform.position == Vector3.zero)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void GetFromAttached()
|
protected override void GetFromAttached()
|
||||||
{
|
{
|
||||||
GetFromSector();
|
GetFromSector();
|
||||||
|
if (!ReferenceTransform)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ReferenceTransform != null)
|
transform.position = ReferenceTransform.ToRelPos(AttachedTransform.position);
|
||||||
{
|
transform.rotation = ReferenceTransform.ToRelRot(AttachedTransform.rotation);
|
||||||
transform.position = ReferenceTransform.ToRelPos(AttachedTransform.position);
|
|
||||||
transform.rotation = ReferenceTransform.ToRelRot(AttachedTransform.rotation);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
transform.position = Vector3.zero;
|
|
||||||
transform.rotation = Quaternion.identity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ApplyToAttached()
|
protected override void ApplyToAttached()
|
||||||
{
|
{
|
||||||
ApplyToSector();
|
ApplyToSector();
|
||||||
|
if (!ReferenceTransform)
|
||||||
if (ReferenceTransform == null || transform.position == Vector3.zero)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user