Exemplo n.º 1
0
        public Quaternion Dequantize()
        {
            float num  = NetFloat.Dequantize(x, 0.707107f, bits);
            float num2 = NetFloat.Dequantize(y, 0.707107f, bits);
            float num3 = NetFloat.Dequantize(z, 0.707107f, bits);
            float w    = Mathf.Sqrt(1f - num * num - num2 * num2 - num3 * num3);

            switch (sel)
            {
            case 0:
                return(new Quaternion(w, num, num2, num3));

            case 1:
                return(new Quaternion(num, w, num2, num3));

            case 2:
                return(new Quaternion(num, num2, w, num3));

            case 3:
                return(new Quaternion(num, num2, num3, w));

            default:
                throw new InvalidOperationException("can't get here");
            }
        }
Exemplo n.º 2
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();
					}
				}
			}
		}
Exemplo n.º 3
0
 public Vector3 Dequantize(Vector3 range)
 {
     return(new Vector3(NetFloat.Dequantize(x, range.x, bits), NetFloat.Dequantize(y, range.y, bits), NetFloat.Dequantize(z, range.z, bits)));
 }
Exemplo n.º 4
0
 public override string ToString()
 {
     return($"{isRelative} ({x},{y},{z}) ({NetFloat.Dequantize(x, 500f, 18)},{NetFloat.Dequantize(y, 500f, 18)},{NetFloat.Dequantize(z, 500f, 18)})");
 }
Exemplo n.º 5
0
 public Vector3 Dequantize(float range)
 {
     return(new Vector3(NetFloat.Dequantize(x, range, bits), NetFloat.Dequantize(y, range, bits), NetFloat.Dequantize(z, range, bits)));
 }