Ejemplo n.º 1
0
        public void AddDelta(NetStream state0, NetStream delta, NetStream result)
        {
            int num = state0?.ReadInt32(fullBits) ?? Quantize(0f, range, fullBits);

            if (!delta.ReadBool())
            {
                result.Write(num, fullBits);
                return;
            }
            int x;

            if (deltaSmall == fullBits)
            {
                x = delta.ReadInt32(fullBits);
            }
            else if (!delta.ReadBool())
            {
                x = delta.ReadInt32(fullBits);
            }
            else
            {
                int num2 = (deltaSmall != deltaLarge) ? delta.ReadInt32(deltaSmall, deltaLarge) : delta.ReadInt32(deltaLarge);
                x = num + num2;
            }
            result.Write(x, fullBits);
        }
Ejemplo n.º 2
0
 public void AddDelta(NetStream state0, NetStream delta, NetStream result)
 {
     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 (delta.ReadBool())
         {
             if (syncPosition != 0)
             {
                 NetVector3      from   = (state0 != null) ? NetVector3.Read(state0, posfull) : zero;
                 NetVector3Delta delta2 = NetVector3Delta.Read(delta, possmall, poslarge, posfull);
                 NetVector3.AddDelta(from, delta2).Write(result);
             }
             if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
             {
                 NetQuaternion      from2  = (state0 != null) ? NetQuaternion.Read(state0, rotfull) : identity;
                 NetQuaternionDelta delta3 = NetQuaternionDelta.Read(delta, rotsmall, rotlarge, rotfull);
                 NetQuaternion.AddDelta(from2, delta3).Write(result);
             }
         }
         else
         {
             if (syncPosition != 0)
             {
                 ((state0 != null) ? NetVector3.Read(state0, posfull) : zero).Write(result);
             }
             if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
             {
                 ((state0 != null) ? NetQuaternion.Read(state0, rotfull) : identity).Write(result);
             }
         }
     }
     if (syncRotation == NetBodySyncRotation.EulerX || syncRotation == NetBodySyncRotation.EulerY || syncRotation == NetBodySyncRotation.EulerZ)
     {
         eulerEncoder.AddDelta(state0, delta, result);
     }
     if (syncLocalScale)
     {
         if (delta.ReadBool())
         {
             NetVector3      from3  = (state0 != null) ? NetVector3.Read(state0, posfull) : zero;
             NetVector3Delta delta4 = NetVector3Delta.Read(delta, possmall, poslarge, posfull);
             NetVector3.AddDelta(from3, delta4).Write(result);
         }
         else
         {
             ((state0 != null) ? NetVector3.Read(state0, posfull) : zero).Write(result);
         }
     }
 }
Ejemplo n.º 3
0
		public void ReceiveMove(NetStream stream)
		{
			float b = NetFloat.Dequantize(stream.ReadInt32(8), 1f, 8);
			float b2 = NetFloat.Dequantize(stream.ReadInt32(8), 1f, 8);
			lock (moveLock)
			{
				moveFrames++;
				walkForward = Mathf.Lerp(walkForward, b, 1f / (float)moveFrames);
				walkRight = Mathf.Lerp(walkRight, b2, 1f / (float)moveFrames);
				cameraPitch = NetFloat.Dequantize(stream.ReadInt32(9), 180f, 9);
				cameraYaw = NetFloat.Dequantize(stream.ReadInt32(9), 180f, 9);
				if (moveFrames == 1)
				{
					leftExtend = (rightExtend = 0f);
					jump = (playDead = false);
					shooting = false;
				}
				leftExtend = Mathf.Max(leftExtend, NetFloat.Dequantize(stream.ReadInt32(5), 1f, 5));
				rightExtend = Mathf.Max(rightExtend, NetFloat.Dequantize(stream.ReadInt32(5), 1f, 5));
				jump |= stream.ReadBool();
				playDead |= stream.ReadBool();
				shooting |= stream.ReadBool();
				if (shooting)
				{
					Debug.LogError("shooting = true in NetPlayer.cs:357");
				}
				NetStream netStream = NetGame.BeginMessage(NetMsgId.Move);
				try
				{
					netStream.WriteNetId(netId);
					netStream.Write(holding);
					NetGame.instance.SendUnreliable(host, netStream, -1);
				}
				finally
				{
					if (netStream != null)
					{
						netStream = netStream.Release();
					}
				}
			}
		}
Ejemplo n.º 4
0
        public void AddDelta(NetStream state0, NetStream delta, NetStream result, bool readChanged = true)
        {
            NetVector3 from = (state0 != null) ? NetVector3.Read(state0, fullBits) : NetVector3.Quantize(startPos, range, fullBits);

            if (delta == null || (readChanged && !delta.ReadBool()))
            {
                from.Write(result);
                return;
            }
            NetVector3Delta delta2 = NetVector3Delta.Read(delta, deltaSmall, deltaLarge, fullBits);

            NetVector3.AddDelta(from, delta2).Write(result);
        }
Ejemplo n.º 5
0
        public static NetVector3Delta Read(NetStream stream, ushort bitsmall, ushort bitlarge, ushort bitfull)
        {
            NetVector3Delta netVector3Delta = default(NetVector3Delta);

            netVector3Delta.isRelative = stream.ReadBool();
            NetVector3Delta result = netVector3Delta;

            if (result.isRelative)
            {
                result.x = stream.ReadInt32(bitsmall, bitlarge);
                result.y = stream.ReadInt32(bitsmall, bitlarge);
                result.z = stream.ReadInt32(bitsmall, bitlarge);
            }
            else
            {
                result.x = stream.ReadInt32(bitfull);
                result.y = stream.ReadInt32(bitfull);
                result.z = stream.ReadInt32(bitfull);
            }
            return(result);
        }
Ejemplo n.º 6
0
        public void ReadDelta(NetStream stream, NetStream reference, NetStream fullStream)
        {
            bool          flag          = stream.ReadBool();
            NetVector3    netVector     = (reference != null) ? NetVector3.Read(reference, 18) : default(NetVector3);
            NetQuaternion netQuaternion = (reference != null) ? NetQuaternion.Read(reference, 9) : default(NetQuaternion);
            NetVector3    netVector2;
            NetQuaternion netQuaternion2;

            if (flag)
            {
                NetVector3Delta delta = NetVector3Delta.Read(stream, 5, 9, 18);
                netVector2 = NetVector3.AddDelta(netVector, delta);
                NetQuaternionDelta delta2 = NetQuaternionDelta.Read(stream, 5, 8, 9);
                netQuaternion2 = NetQuaternion.AddDelta(netQuaternion, delta2);
            }
            else
            {
                netVector2     = netVector;
                netQuaternion2 = netQuaternion;
            }
            netVector2.Write(fullStream);
            netQuaternion2.Write(fullStream);
        }
Ejemplo n.º 7
0
		public void ReceiveMoveAck(NetStream stream)
		{
			holding = stream.ReadBool();
		}