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(); } } } }
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; }
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)); }