ReadMovementInfo() public static méthode

public static ReadMovementInfo ( WowPacketParser.Misc.Packet packet, WowGuid guid, object index = null ) : MovementInfo
packet WowPacketParser.Misc.Packet
guid WowPacketParser.Misc.WowGuid
index object
Résultat WowPacketParser.Misc.MovementInfo
        public static void HandleChangeSeatsOnControlledVehicle(Packet packet)
        {
            var guid = packet.ReadPackedGuid("Vehicle GUID");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_3a_11723))
            {
                MovementHandler.ReadMovementInfo(ref packet, guid);
            }

            packet.ReadPackedGuid("Accessory GUID");
            packet.ReadByte("Seat");
        }
        public static MovementInfo ReadMovementUpdateBlock(ref Packet packet, Guid guid, int index)
        {
            var moveInfo = new MovementInfo();

            var flagsTypeCode = ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767) ? TypeCode.UInt16 : TypeCode.Byte;
            var flags         = packet.ReadEnum <UpdateFlag>("[" + index + "] Update Flags", flagsTypeCode);

            if (flags.HasAnyFlag(UpdateFlag.Living))
            {
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333))
                {
                    moveInfo = MovementHandler.ReadMovementInfo420(ref packet, guid, index);
                }
                else
                {
                    moveInfo = MovementHandler.ReadMovementInfo(ref packet, guid, index);
                }
                var moveFlags = moveInfo.Flags;

                var speedCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056) ? 9 : 8;
                int speedShift;
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914) &&
                    ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545))
                {
                    speedShift = 1;  // enums shifted by one
                }
                else
                {
                    speedShift = 0;
                }

                for (var i = 0; i < speedCount - speedShift; i++)
                {
                    var speedType = (SpeedType)(i + speedShift);
                    var speed     = packet.ReadSingle("[" + index + "] " + speedType + " Speed");

                    switch (speedType)
                    {
                    case SpeedType.Walk:
                    {
                        moveInfo.WalkSpeed = speed / 2.5f;
                        break;
                    }

                    case SpeedType.Run:
                    {
                        moveInfo.RunSpeed = speed / 7.0f;
                        break;
                    }
                    }
                }

                // this is incorrect for certain objects but I can't figure out why
                if (moveFlags.HasAnyFlag(MovementFlag.SplineEnabled) || moveInfo.HasSplineData)
                {
                    var splineFlags = packet.ReadEnum <SplineFlag>("Spline Flags", TypeCode.Int32, index);

                    // HACK: Fix splineflags for next ifs. Need to use different enum for TBC
                    if (ClientVersion.RemovedInVersion(ClientType.WrathOfTheLichKing))
                    {
                        splineFlags = (SplineFlag)((int)splineFlags >> 1);
                    }

                    if (splineFlags.HasAnyFlag(SplineFlag.FinalTarget))
                    {
                        packet.ReadGuid("Final Spline Target GUID", index);
                    }
                    else if (splineFlags.HasAnyFlag(SplineFlag.FinalOrientation))
                    {
                        packet.ReadSingle("Final Spline Orientation", index);
                    }
                    else if (splineFlags.HasAnyFlag(SplineFlag.FinalPoint))
                    {
                        packet.ReadVector3("Final Spline Coords", index);
                    }

                    packet.ReadInt32("Spline Time", index);
                    packet.ReadInt32("Spline Full Time", index);
                    packet.ReadInt32("Spline Unk Int32 1", index);

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
                    {
                        packet.ReadSingle("Spline Duration Multiplier", index);
                        packet.ReadSingle("Spline Unit Interval", index);
                        packet.ReadSingle("Spline Unk Float 2", index);
                        packet.ReadInt32("Spline Height Time", index);
                    }

                    var splineCount = packet.ReadInt32();
                    for (var i = 0; i < splineCount; i++)
                    {
                        packet.ReadVector3("Spline Waypoint", index, i);
                    }

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
                    {
                        packet.ReadEnum <SplineMode>("Spline Mode", TypeCode.Byte, index);
                    }

                    packet.ReadVector3("Spline Endpoint", index);
                }
            }
            else // !UpdateFlag.Living
            {
                if (flags.HasAnyFlag(UpdateFlag.GOPosition))
                {
                    packet.ReadPackedGuid("GO Position GUID", index);

                    moveInfo.Position = packet.ReadVector3("[" + index + "] GO Position");
                    packet.ReadVector3("GO Transport Position", index);

                    moveInfo.Orientation = packet.ReadSingle("[" + index + "] GO Orientation");
                    packet.ReadSingle("GO Transport Orientation", index);
                }
                else if (flags.HasAnyFlag(UpdateFlag.StationaryObject))
                {
                    packet.ReadVector4("Stationary Position", index);
                }
            }

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545))
            {
                if (flags.HasAnyFlag(UpdateFlag.Unknown1))
                {
                    packet.ReadInt32("Unk Int32", index);
                }

                if (flags.HasAnyFlag(UpdateFlag.LowGuid))
                {
                    packet.ReadInt32("Low GUID", index);
                }
            }

            if (flags.HasAnyFlag(UpdateFlag.AttackingTarget))
            {
                packet.ReadPackedGuid("Target GUID", index);
            }

            if (flags.HasAnyFlag(UpdateFlag.Transport))
            {
                packet.ReadInt32("Transport Movement Time (ms)", index);
            }

            if (flags.HasAnyFlag(UpdateFlag.Vehicle))
            {
                moveInfo.VehicleId = packet.ReadUInt32("[" + index + "] Vehicle ID");
                packet.ReadSingle("Vehicle Orientation", index);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545))
            {
                if (flags.HasAnyFlag(UpdateFlag.AnimKits))
                {
                    packet.ReadInt16("Unk Int16", index);
                    packet.ReadInt16("Unk Int16", index);
                    packet.ReadInt16("Unk Int16", index);
                }
            }

            if (flags.HasAnyFlag(UpdateFlag.GORotation))
            {
                packet.ReadPackedQuaternion("GO Rotation", index);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545))
            {
                if (flags.HasAnyFlag(UpdateFlag.TransportUnkArray))
                {
                    var count = packet.ReadByte("Count", index);
                    for (var i = 0; i < count; i++)
                    {
                        packet.ReadInt32("Unk Int32", index, count);
                    }
                }
            }

            // Initialize fields that are not used by GOs
            if (guid.GetObjectType() == ObjectType.GameObject)
            {
                moveInfo.VehicleId = 0;
                moveInfo.WalkSpeed = 0;
                moveInfo.RunSpeed  = 0;
            }

            return(moveInfo);
        }