mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-04 02:47:22 +00:00
UseReliableRpc for ship/raft when ur inside/riding
This commit is contained in:
parent
00b5c4a4f2
commit
f9dfb2e871
@ -10,7 +10,9 @@ namespace QSB.EchoesOfTheEye.RaftSync.TransformSync;
|
||||
|
||||
public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviour
|
||||
{
|
||||
protected override bool UseInterpolation => Locator.GetPlayerController().GetGroundBody() != AttachedRigidbody;
|
||||
private bool IsRidingRaft => Locator.GetPlayerController() && Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody;
|
||||
protected override bool UseInterpolation => !IsRidingRaft;
|
||||
protected override bool UseReliableRpc => IsRidingRaft;
|
||||
|
||||
private float _lastSetPositionTime;
|
||||
private const float ForcePositionAfterTime = 1;
|
||||
@ -77,8 +79,7 @@ public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviou
|
||||
var targetPos = ReferenceTransform.FromRelPos(UseInterpolation ? SmoothPosition : transform.position);
|
||||
var targetRot = ReferenceTransform.FromRelRot(UseInterpolation ? SmoothRotation : transform.rotation);
|
||||
|
||||
var onRaft = Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody;
|
||||
if (onRaft)
|
||||
if (IsRidingRaft)
|
||||
{
|
||||
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ public class ShipTransformSync : SectoredRigidbodySync
|
||||
var targetPos = ReferenceTransform.FromRelPos(UseInterpolation ? SmoothPosition : transform.position);
|
||||
var targetRot = ReferenceTransform.FromRelRot(UseInterpolation ? SmoothRotation : transform.rotation);
|
||||
|
||||
if (PlayerState.IsInsideShip())
|
||||
if (IsInsideShip)
|
||||
{
|
||||
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
|
||||
{
|
||||
@ -98,5 +98,7 @@ public class ShipTransformSync : SectoredRigidbodySync
|
||||
rigidbody._currentVelocity = newVelocity;
|
||||
}
|
||||
|
||||
protected override bool UseInterpolation => !PlayerState.IsInsideShip();
|
||||
private static bool IsInsideShip => PlayerState.IsInsideShip();
|
||||
protected override bool UseInterpolation => !IsInsideShip;
|
||||
protected override bool UseReliableRpc => IsInsideShip;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user