Esempio n. 1
0
 public void ApplyState(NetStream state)
 {
     if (syncPosition == NetBodySyncPosition.Relative || syncPosition == NetBodySyncPosition.Absolute || syncPosition == NetBodySyncPosition.Local || syncPosition == NetBodySyncPosition.World)
     {
         Vector3 target = NetVector3.Read(state, posfull).Dequantize(posRange);
         ApplyPositionState(target);
     }
     if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
     {
         NetQuaternion netQuaternion = appliedRot = NetQuaternion.Read(state, rotfull);
         Quaternion    target2       = netQuaternion.Dequantize();
         ApplyQuaternionState(target2);
     }
     else if (syncRotation == NetBodySyncRotation.EulerX || syncRotation == NetBodySyncRotation.EulerY || syncRotation == NetBodySyncRotation.EulerZ)
     {
         float diff = eulerEncoder.ApplyState(state);
         ApplyEulerState(diff);
     }
     if (body != null)
     {
         Rigidbody rigidbody = body;
         Vector3   vector    = Vector3.zero;
         body.velocity             = vector;
         rigidbody.angularVelocity = vector;
     }
     if (syncLocalScale)
     {
         Vector3 localScale = NetVector3.Read(state, posfull).Dequantize(posRange);
         base.transform.localScale = localScale;
     }
 }
Esempio n. 2
0
        public void ApplySnapshot(NetStream stream)
        {
            NetVector3    netVector     = NetVector3.Read(stream, 18);
            NetQuaternion netQuaternion = NetQuaternion.Read(stream, 9);

            netPos = netVector.Dequantize(500f);
            netRot = netQuaternion.Dequantize();
            base.transform.localPosition = netPos;
            base.transform.localRotation = netRot;
        }
Esempio n. 3
0
 public void ApplyLerpedState(NetStream state0, NetStream state1, float mix)
 {
     if (syncPosition == NetBodySyncPosition.Relative || syncPosition == NetBodySyncPosition.Absolute || syncPosition == NetBodySyncPosition.Local || syncPosition == NetBodySyncPosition.World)
     {
         Vector3 a      = NetVector3.Read(state0, posfull).Dequantize(posRange);
         Vector3 vector = NetVector3.Read(state1, posfull).Dequantize(posRange);
         if ((a - vector).sqrMagnitude > 15f)
         {
             a = vector;
         }
         Vector3 target = Vector3.Lerp(a, vector, mix);
         ApplyPositionState(target);
     }
     if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
     {
         Quaternion    a2            = NetQuaternion.Read(state0, rotfull).Dequantize();
         NetQuaternion netQuaternion = appliedRot = NetQuaternion.Read(state1, rotfull);
         Quaternion    b             = netQuaternion.Dequantize();
         Quaternion    target2       = Quaternion.Slerp(a2, b, mix);
         ApplyQuaternionState(target2);
     }
     else if (syncRotation == NetBodySyncRotation.EulerX || syncRotation == NetBodySyncRotation.EulerY || syncRotation == NetBodySyncRotation.EulerZ)
     {
         float diff = eulerEncoder.ApplyLerpedState(state0, state1, mix);
         ApplyEulerState(diff);
     }
     if (body != null)
     {
         Rigidbody rigidbody = body;
         Vector3   vector2   = Vector3.zero;
         body.velocity             = vector2;
         rigidbody.angularVelocity = vector2;
     }
     if (syncLocalScale && (syncPosition == NetBodySyncPosition.Relative || syncPosition == NetBodySyncPosition.Absolute || syncPosition == NetBodySyncPosition.Local || syncPosition == NetBodySyncPosition.World))
     {
         Vector3 a3         = NetVector3.Read(state0, posfull).Dequantize(posRange);
         Vector3 b2         = NetVector3.Read(state1, posfull).Dequantize(posRange);
         Vector3 localScale = Vector3.Lerp(a3, b2, mix);
         base.transform.localScale = localScale;
     }
 }