예제 #1
0
        public void Read(byte[] data, int size)
        {
            PacketIn pIn = new PacketIn(data, 0, size);
            //pIn.SetBuffer(buffer, size);
            //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();

            //PID = pIn.GetInt16();
            //data4 = pIn.ReadByte();
            //MoveVelocity = pIn.GetIntClamped(-127, 325);
            //FallTime = pIn.GetIntClamped(-2000, 500);

            // 10 -1 92
            List <string> lst = new List <string>();

            for (int i = 0; i < 15; i++)
            {
                if (i > 10)
                {
                    lst.Add(i.ToString() + " " + pIn.ReadByte().ToString().PadLeft(3));
                }
            }

            Log.Error("", string.Join(", ", lst));
            //pIn.Skip(7);
            byte test = (byte)pIn.ReadByte();

            HasEnemyTarget = test & 64;
            //pIn.ReadByte(); //2 or 3 readbyte here seems to give some correct data and would correspond with the original readint(2) of freefall
            //pIn.ReadByte();
            FreeFall = test & 0x1F; //3F pIn.ReadByte() & 48; //BitConverter.ToInt16(pIn.Read(2), 0);
            //Log.Error("freefall", Convert.ToString(test, 2));
            //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();
            Action = BitConverter.ToInt16(pIn.Read(2), 0); //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();
            Strafe = BitConverter.ToInt16(pIn.Read(3), 0); //pIn.ReadByte();

            if (HasEnemyTarget > 0 && data4 == 0)
            {
                data32 = pIn.ReadByte();
            }

            if (data4 == 0)
            {
                Heartbeat = BitConverter.ToInt16(pIn.Read(3), 0); //pIn.ReadByte();
            }
            HasPosition = pIn.ReadByte();

            if (HasPosition > 0)
            {
                Heading           = pIn.GetUint16(); // pIn.GetAngleRad(12);
                HasPositionChange = pIn.ReadByte();
                Grounded          = pIn.ReadByte();

                if (HasPositionChange == 0)
                {
                    X = pIn.GetInt16();
                    Y = pIn.GetInt16();
                }
            }

            if (HasEnemyTarget > 0 && data4 == 0)
            {
                data60 = pIn.ReadByte();
            }

            if (HasPosition > 0)
            {
                if (HasPositionChange == 0)
                {
                    ZoneID = BitConverter.ToInt16(pIn.Read(9), 0); //pIn.GetInt16(); // (9)
                    Z      = pIn.GetInt16();
                }
                else
                {
                    data72 = pIn.GetUint16();
                }
            }

            if (HasPosition > 0 && HasPositionChange > 0)
            {
                data76 = pIn.GetUint16();
                data80 = pIn.GetUint16();
                data84 = BitConverter.ToInt16(pIn.Read(9), 0); //pIn.GetInt16(); // (9)
            }

            if (HasEnemyTarget > 0)
            {
                if (data4 == 0)
                {
                    TargetLos = pIn.ReadByte();
                    data89    = pIn.ReadByte();
                    data90    = pIn.ReadByte();
                    data91    = pIn.ReadByte();
                    data92    = pIn.ReadByte();
                }
            }

            if ((data4 > 0) || (GroundType = BitConverter.ToInt16(pIn.Read(3), 0)) != 0) // (3)
            {
                data100   = pIn.ReadByte();
                Floating2 = pIn.ReadByte();
                data102   = pIn.ReadByte();
                data103   = pIn.ReadByte();
            }

            data104 = pIn.ReadByte();

            if (data4 == 0)
            {
                data105 = pIn.ReadByte();
            }

            data106 = pIn.ReadByte();
            data107 = pIn.ReadByte();
        }