Example #1
0
 public void Start()
 {
     if (!isStarted)
     {
         isStarted = true;
         if (NetGame.isClient)
         {
             hasNetSetActive = (GetComponent <NetSetActive>() != null);
         }
         NetBodyResetOverride component = GetComponent <NetBodyResetOverride>();
         if ((bool)component)
         {
             mResetFramesAdditionalDelay = component.FramesDelay;
         }
         body        = GetComponent <Rigidbody>();
         isKinematic = body.isKinematic;
         if (syncPosition == NetBodySyncPosition.Relative)
         {
             posRange = 10f;
             posfull -= 6;
         }
         if (syncPosition == NetBodySyncPosition.Local)
         {
             posRange = 10f;
             posfull -= 6;
         }
         if (posRangeOverride != 0f)
         {
             posRange = posRangeOverride;
         }
         eulerEncoder.fullBits   = (ushort)(eulerEncoder.fullBits + rotPrecision);
         eulerEncoder.deltaSmall = (ushort)(eulerEncoder.deltaSmall + rotPrecision);
         eulerEncoder.deltaLarge = (ushort)(eulerEncoder.deltaLarge + rotPrecision);
         possmall        = (ushort)(possmall + posPrecision);
         poslarge        = (ushort)(poslarge + posPrecision);
         posfull         = (ushort)(posfull + posPrecision);
         rotfull         = (ushort)(rotfull + rotPrecision);
         rotsmall        = (ushort)(rotsmall + rotPrecision);
         rotlarge        = (ushort)(rotlarge + rotPrecision);
         startPos        = base.transform.position;
         startRot        = base.transform.rotation;
         startLocalScale = base.transform.localScale;
         if (syncPosition == NetBodySyncPosition.Relative)
         {
             basePos = base.transform.position - relativeTo.position;
         }
         else if (syncPosition == NetBodySyncPosition.Absolute)
         {
             basePos = Vector3.zero;
         }
         else
         {
             basePos = ((syncPosition != NetBodySyncPosition.Local) ? base.transform.position : base.transform.localPosition);
         }
         if (syncRotation == NetBodySyncRotation.Relative)
         {
             baseRot = Quaternion.Inverse(relativeTo.rotation) * base.transform.rotation;
         }
         else if (syncRotation == NetBodySyncRotation.Absolute)
         {
             baseRot = Quaternion.identity;
         }
         else
         {
             baseRot = ((syncRotation != NetBodySyncRotation.Local && syncRotation != NetBodySyncRotation.EulerX && syncRotation != NetBodySyncRotation.EulerY && syncRotation != NetBodySyncRotation.EulerZ) ? base.transform.rotation : base.transform.localRotation);
         }
         baseRotInv = Quaternion.Inverse(baseRot);
         zero       = NetVector3.Quantize(Vector3.zero, posRange, posfull);
         identity   = NetQuaternion.Quantize(Quaternion.identity, rotfull);
         if (!disableSleep)
         {
             sleep = new NetBodySleep(body);
         }
     }
 }