Ejemplo 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");
            }
        }
Ejemplo n.º 2
0
		public void SendMove(float walkForward, float walkRight, float cameraPitch, float cameraYaw, float leftExtend, float rightExtend, bool jump, bool playDead, bool shooting)
		{
			if (host != null && host.isReady)
			{
				NetStream netStream = NetGame.BeginMessage(NetMsgId.Move);
				try
				{
					netStream.WriteNetId(netId);
					netStream.Write(NetFloat.Quantize(walkForward, 1f, 8), 8);
					netStream.Write(NetFloat.Quantize(walkRight, 1f, 8), 8);
					netStream.Write(NetFloat.Quantize(Math2d.NormalizeAngleDeg(cameraPitch), 180f, 9), 9);
					netStream.Write(NetFloat.Quantize(Math2d.NormalizeAngleDeg(cameraYaw), 180f, 9), 9);
					netStream.Write(NetFloat.Quantize(leftExtend, 1f, 5), 5);
					netStream.Write(NetFloat.Quantize(rightExtend, 1f, 5), 5);
					netStream.Write(jump);
					netStream.Write(playDead);
					netStream.Write(shooting);
					NetGame.instance.SendUnreliableToServer(netStream, -1);
				}
				finally
				{
					if (netStream != null)
					{
						netStream = netStream.Release();
					}
				}
			}
		}
Ejemplo n.º 3
0
 public NetQuaternion(byte sel, float a, float b, float c, float drop, ushort bits)
 {
     if (drop < 0f)
     {
         a = 0f - a;
         b = 0f - b;
         c = 0f - c;
     }
     this.sel  = sel;
     x         = NetFloat.Quantize(a, 0.707107f, bits);
     y         = NetFloat.Quantize(b, 0.707107f, bits);
     z         = NetFloat.Quantize(c, 0.707107f, bits);
     this.bits = bits;
 }
Ejemplo n.º 4
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.º 5
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)})");
 }
Ejemplo n.º 6
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)));
 }
Ejemplo n.º 7
0
 public Vector3 Dequantize(float range)
 {
     return(new Vector3(NetFloat.Dequantize(x, range, bits), NetFloat.Dequantize(y, range, bits), NetFloat.Dequantize(z, range, bits)));
 }
Ejemplo n.º 8
0
 public static NetVector3 Quantize(Vector3 vec, Vector3 range, ushort bits)
 {
     return(new NetVector3(NetFloat.Quantize(vec.x, range.x, bits), NetFloat.Quantize(vec.y, range.y, bits), NetFloat.Quantize(vec.z, range.z, bits), bits));
 }