Example #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);
        }
Example #2
0
        public void CalculateDelta(NetStream state0, NetStream state1, NetStream delta)
        {
            int num  = state0?.ReadInt32(fullBits) ?? Quantize(0f, range, fullBits);
            int num2 = state1.ReadInt32(fullBits);

            if (num == num2)
            {
                delta.Write(v: false);
                return;
            }
            delta.Write(v: true);
            if (deltaSmall == fullBits)
            {
                delta.Write(num2, fullBits);
                return;
            }
            int num3 = num2 - num;
            int num4 = 1 << deltaLarge - 1;

            if (num3 < -num4 || num3 >= num4)
            {
                delta.Write(v: false);
                delta.Write(num2, fullBits);
                return;
            }
            delta.Write(v: true);
            if (deltaSmall == deltaLarge)
            {
                delta.Write(num3, deltaLarge);
            }
            else
            {
                delta.Write(num3, deltaSmall, deltaLarge);
            }
        }
Example #3
0
        public float ApplyLerpedState(NetStream state0, NetStream state1, float mix)
        {
            float a = Dequantize(state0.ReadInt32(fullBits), range, fullBits);
            float b = Dequantize(state1.ReadInt32(fullBits), range, fullBits);

            return(Mathf.Lerp(a, b, mix));
        }
Example #4
0
        public static NetQuaternionDelta Read(NetStream stream, ushort bitsmall, ushort bitlarge, ushort bitfull)
        {
            NetQuaternionDelta netQuaternionDelta = default(NetQuaternionDelta);

            netQuaternionDelta.isRelative = stream.ReadBool();
            netQuaternionDelta.sel        = (byte)(stream.ReadInt32(2) & 3);
            NetQuaternionDelta result = netQuaternionDelta;

            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);
        }
Example #5
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();
					}
				}
			}
		}
 public static NetQuaternion Read(NetStream stream, ushort bits)
 {
     return(new NetQuaternion((byte)(stream.ReadInt32(2) & 3), stream.ReadInt32(bits), stream.ReadInt32(bits), stream.ReadInt32(bits), bits));
 }
Example #7
0
 public static NetVector3 Read(NetStream stream, ushort bits)
 {
     return(new NetVector3(stream.ReadInt32(bits), stream.ReadInt32(bits), stream.ReadInt32(bits), bits));
 }
Example #8
0
 public float ApplyState(NetStream state)
 {
     return(Dequantize(state.ReadInt32(fullBits), range, fullBits));
 }