Example #1
0
        public void CalculateDelta(NetStream state0, NetStream state1, NetStream delta)
        {
            bool          flag           = false;
            NetVector3    netVector      = default(NetVector3);
            NetVector3    netVector2     = default(NetVector3);
            NetQuaternion netQuaternion  = default(NetQuaternion);
            NetQuaternion netQuaternion2 = default(NetQuaternion);

            if (syncPosition == NetBodySyncPosition.Relative || syncPosition == NetBodySyncPosition.Absolute || syncPosition == NetBodySyncPosition.Local || syncPosition == NetBodySyncPosition.World || syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
            {
                if (syncPosition != 0)
                {
                    netVector  = ((state0 != null) ? NetVector3.Read(state0, posfull) : zero);
                    netVector2 = NetVector3.Read(state1, posfull);
                    flag      |= (netVector2 != netVector);
                }
                if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
                {
                    netQuaternion  = ((state0 != null) ? NetQuaternion.Read(state0, rotfull) : identity);
                    netQuaternion2 = NetQuaternion.Read(state1, rotfull);
                    flag          |= (netQuaternion2 != netQuaternion);
                }
                if (flag)
                {
                    delta.Write(v: true);
                    if (syncPosition != 0)
                    {
                        NetVector3.Delta(netVector, netVector2, poslarge).Write(delta, possmall, poslarge, posfull);
                    }
                    if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
                    {
                        NetQuaternion.Delta(netQuaternion, netQuaternion2, rotlarge).Write(delta, rotsmall, rotlarge, rotfull);
                    }
                }
                else
                {
                    delta.Write(v: false);
                }
            }
            if (syncRotation == NetBodySyncRotation.EulerX || syncRotation == NetBodySyncRotation.EulerY || syncRotation == NetBodySyncRotation.EulerZ)
            {
                eulerEncoder.CalculateDelta(state0, state1, delta);
            }
            if (syncLocalScale)
            {
                NetVector3 netVector3 = default(NetVector3);
                NetVector3 netVector4 = default(NetVector3);
                netVector3 = ((state0 != null) ? NetVector3.Read(state0, posfull) : zero);
                netVector4 = NetVector3.Read(state1, posfull);
                if (netVector4 != netVector3)
                {
                    delta.Write(v: true);
                    NetVector3.Delta(netVector3, netVector4, poslarge).Write(delta, possmall, poslarge, posfull);
                }
                else
                {
                    delta.Write(v: false);
                }
            }
        }
Example #2
0
        public bool CalculateDelta(NetStream state0, NetStream state1, NetStream delta, bool writeChanged = true)
        {
            NetVector3 netVector  = (state0 != null) ? NetVector3.Read(state0, fullBits) : NetVector3.Quantize(startPos, range, fullBits);
            NetVector3 netVector2 = NetVector3.Read(state1, fullBits);

            if (netVector == netVector2)
            {
                if (writeChanged)
                {
                    delta.Write(v: false);
                }
                return(false);
            }
            if (writeChanged)
            {
                delta.Write(v: true);
            }
            NetVector3.Delta(netVector, netVector2, deltaLarge).Write(delta, deltaSmall, deltaLarge, fullBits);
            return(true);
        }
Example #3
0
        public void WriteDelta(NetStream stream, NetStream reference, NetStream fullStream)
        {
            netPos = base.transform.localPosition;
            NetVector3 netVector  = NetVector3.Quantize(netPos, 500f, 18);
            NetVector3 netVector2 = (reference != null) ? NetVector3.Read(reference, 18) : default(NetVector3);

            netRot = base.transform.localRotation;
            NetQuaternion netQuaternion  = NetQuaternion.Quantize(netRot, 9);
            NetQuaternion netQuaternion2 = (reference != null) ? NetQuaternion.Read(reference, 9) : default(NetQuaternion);

            if (netVector != netVector2 || netQuaternion != netQuaternion2)
            {
                stream.Write(v: true);
                NetVector3.Delta(netVector2, netVector, 9).Write(stream, 5, 9, 18);
                NetQuaternion.Delta(netQuaternion2, netQuaternion, 8).Write(stream, 5, 8, 9);
            }
            else
            {
                stream.Write(v: false);
            }
            netVector.Write(fullStream);
            netQuaternion.Write(fullStream);
        }