Beispiel #1
0
        public static SplineInfo Read(BinaryReader gr)
        {
            var spline = new SplineInfo();
            spline.Flags = (SplineFlags)gr.ReadUInt32();

            if (spline.Flags.HasFlag(SplineFlags.FINALPOINT))
            {
                spline.Point = gr.ReadCoords3();
            }

            if (spline.Flags.HasFlag(SplineFlags.FINALTARGET))
            {
                spline.Guid = gr.ReadUInt64();
            }

            if (spline.Flags.HasFlag(SplineFlags.FINALORIENT))
            {
                spline.Rotation = gr.ReadSingle();
            }

            spline.CurrentTime = gr.ReadUInt32();
            spline.FullTime = gr.ReadUInt32();
            spline.Unknown1 = gr.ReadUInt32();

            spline.DurationMultiplier = gr.ReadSingle();
            spline.UnknownFloat2 = gr.ReadSingle();
            spline.UnknownFloat3 = gr.ReadSingle();

            spline.Unknown2 = gr.ReadUInt32();

            spline.Count = gr.ReadUInt32();

            for (uint i = 0; i < spline.Count; ++i)
            {
                spline.splines.Add(gr.ReadCoords3());
            }

            spline.SplineMode = (SplineMode)gr.ReadByte();

            spline.EndPoint = gr.ReadCoords3();
            return spline;
        }
 public static TransportInfo Read(BinaryReader reader, MovementFlags2 flags2)
 {
     var tInfo = new TransportInfo();
     tInfo.Guid = reader.ReadUInt64();
     tInfo.Position = reader.ReadCoords3();
     tInfo.Facing = reader.ReadSingle();
     tInfo.Time = reader.ReadUInt32();
     tInfo.Seat = reader.ReadByte();
     if (flags2.HasFlag(MovementFlags2.InterpolateMove))
         tInfo.Time2 = reader.ReadUInt32();
     return tInfo;
 }
Beispiel #3
0
        public static MovementInfo Read(BinaryReader gr)
        {
            var movement = new MovementInfo();

            movement.UpdateFlags = (UpdateFlags)gr.ReadUInt16();

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_LIVING))
            {
                movement.Flags = (MovementFlags)gr.ReadUInt32();
                movement.Flags2 = (MovementFlags2)gr.ReadUInt16();
                movement.TimeStamp = gr.ReadUInt32();

                movement.Position = gr.ReadCoords3();
                movement.Facing = gr.ReadSingle();

                if (movement.Flags.HasFlag(MovementFlags.ONTRANSPORT))
                {
                    movement.Transport = TransportInfo.Read(gr, movement.Flags2);
                }

                if (movement.Flags.HasFlag(MovementFlags.SWIMMING) || movement.Flags.HasFlag(MovementFlags.FLYING) ||
                    movement.Flags2.HasFlag(MovementFlags2.AlwaysAllowPitching))
                {
                    movement.Pitch = gr.ReadSingle();
                }

                movement.FallTime = gr.ReadUInt32();

                if (movement.Flags.HasFlag(MovementFlags.FALLING))
                {
                    movement.FallVelocity = gr.ReadSingle();
                    movement.FallCosAngle = gr.ReadSingle();
                    movement.FallSinAngle = gr.ReadSingle();
                    movement.FallSpeed = gr.ReadSingle();
                }

                if (movement.Flags.HasFlag(MovementFlags.SPLINEELEVATION))
                {
                    movement.SplineElevation = gr.ReadSingle();
                }

                for (byte i = 0; i < movement.speeds.Length; ++i)
                    movement.speeds[i] = gr.ReadSingle();

                if (movement.Flags.HasFlag(MovementFlags.SPLINEENABLED))
                {
                    movement.Spline = SplineInfo.Read(gr);
                }
            }
            else
            {
                if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_GO_POSITION))
                {
                    movement.Transport.Guid = gr.ReadPackedGuid();
                    movement.Position = gr.ReadCoords3();
                    movement.Transport.Position = gr.ReadCoords3();
                    movement.Facing = gr.ReadSingle();
                    movement.Transport.Facing = gr.ReadSingle();
                }
                else if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_HAS_POSITION))
                {
                    movement.Position = gr.ReadCoords3();
                    movement.Facing = gr.ReadSingle();
                }
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_LOWGUID))
            {
                movement.LowGuid = gr.ReadUInt32();
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_HIGHGUID))
            {
                movement.HighGuid = gr.ReadUInt32();
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_TARGET_GUID))
            {
                movement.AttackingTarget = gr.ReadPackedGuid();
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_TRANSPORT))
            {
                movement.TransportTime = gr.ReadUInt32();
            }

            // WotLK
            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_VEHICLE))
            {
                movement.VehicleId = gr.ReadUInt32();
                movement.VehicleAimAdjustement = gr.ReadSingle();
            }

            // 3.1
            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_GO_ROTATION))
            {
                movement.GoRotationULong = gr.ReadUInt64();
            }
            return movement;
        }
Beispiel #4
0
        public static MovementInfo Read(BinaryReader gr)
        {
            var movementInfo = new MovementInfo();

            movementInfo.Flags = (MovementFlags)gr.ReadUInt32();
            movementInfo.Flags2 = (MovementFlags2)gr.ReadUInt16();
            movementInfo.TimeStamp = gr.ReadUInt32();

            movementInfo.Position = gr.ReadCoords3();
            movementInfo.Facing = gr.ReadSingle();

            if (movementInfo.Flags.HasFlag(MovementFlags.ONTRANSPORT))
            {
                movementInfo.Transport = TransportInfo.Read(gr, movementInfo.Flags2);
            }

            if (movementInfo.Flags.HasFlag(MovementFlags.SWIMMING) || movementInfo.Flags.HasFlag(MovementFlags.FLYING) ||
                movementInfo.Flags2.HasFlag(MovementFlags2.AlwaysAllowPitching))
            {
                movementInfo.Pitch = gr.ReadSingle();
            }

            movementInfo.FallTime = gr.ReadUInt32();

            if (movementInfo.Flags.HasFlag(MovementFlags.FALLING))
            {
                movementInfo.FallVelocity = gr.ReadSingle();
                movementInfo.FallCosAngle = gr.ReadSingle();
                movementInfo.FallSinAngle = gr.ReadSingle();
                movementInfo.FallSpeed = gr.ReadSingle();
            }

            if (movementInfo.Flags.HasFlag(MovementFlags.SPLINEELEVATION))
            {
                movementInfo.SplineElevation = gr.ReadSingle();
            }

            return movementInfo;
        }
Beispiel #5
0
        public void ReadMov(BinaryReader gr)
        {
            Object obj = this;

            Unit u = new Unit();
            if (obj)
            {
                if (obj.IsUnit() || obj.IsPlayer())
                {
                    u = (Unit)obj;

                }
                //else return null;
            }

            UpdateFlags = (UpdateFlags)gr.ReadUInt16();

            if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_LIVING))
            {
                Flags = (MovementFlags)gr.ReadUInt32();
                Flags2 = (MovementFlags2)gr.ReadUInt16();
                TimeStamp = gr.ReadUInt32();

                Position = gr.ReadCoords3();
                Facing = gr.ReadSingle()*Mathf.Rad2Deg;

                if (obj.IsUnit() || obj.IsPlayer() || obj)
                    ((WorldObject)obj).SetCoordinates(Position);

                if (Flags.HasFlag(MovementFlags.OnTransport))
                {
                    Transport = TransportInfo.Read(gr, Flags2);
                }

                if (Flags.HasFlag(MovementFlags.Swimming) || Flags.HasFlag(MovementFlags.Flying) ||
                    Flags2.HasFlag(MovementFlags2.AlwaysAllowPitching))
                {
                    Pitch = gr.ReadSingle();
                }

                FallTime = gr.ReadUInt32();

                if (Flags.HasFlag(MovementFlags.Falling))
                {
                    FallVelocity = gr.ReadSingle();
                    FallCosAngle = gr.ReadSingle();
                    FallSinAngle = gr.ReadSingle();
                    FallSpeed = gr.ReadSingle();
                }

                if (Flags.HasFlag(MovementFlags.SplineElevation))
                {
                    SplineElevation = gr.ReadSingle();
                }

                /*  for (byte i = 0; i < movement.speeds.Length; ++i)
                      movement.speeds[i] = gr.ReadSingle();*/

                speedWalk = gr.ReadSingle();
                speedRun = gr.ReadSingle();
                speedSwimBack = gr.ReadSingle();
                speedSwim = gr.ReadSingle();
                speedWalkBack = gr.ReadSingle();
                speedFly = gr.ReadSingle();
                speedFlyBack = gr.ReadSingle();
                speedTurn = gr.ReadSingle();
                speedPitchRate = gr.ReadSingle();

                u.SetCoordinates(Position);
                u.SetSpeed(UnitMoveType.MOVE_WALK, speedWalk);
                u.SetSpeed(UnitMoveType.MOVE_RUN, speedRun);
                u.SetSpeed(UnitMoveType.MOVE_SWIMBACK, speedSwimBack);
                u.SetSpeed(UnitMoveType.MOVE_SWIM, speedSwim);
                u.SetSpeed(UnitMoveType.MOVE_WALKBACK, speedWalkBack);
                u.SetSpeed(UnitMoveType.MOVE_TURN, speedTurn);
                u.SetSpeed(UnitMoveType.MOVE_FLY, speedFly);
                u.SetSpeed(UnitMoveType.MOVE_FLYBACK, speedFlyBack);
                u.SetSpeed(UnitMoveType.MOVE_PITCH_RATE, speedPitchRate);

                if (Flags.HasFlag(MovementFlags.SplineEnabled))
                {
                    Spline = SplineInfo.Read(gr);
                }
            }
            else
            {
                if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_GO_POSITION))
                {
                    Transport = new TransportInfo();
                    Transport.Guid = gr.ReadPackedGuid();
                    Position = gr.ReadCoords3();
                    Transport.Position = gr.ReadCoords3();
                    Facing = gr.ReadSingle() * Mathf.Rad2Deg;
                    Transport.Facing = gr.ReadSingle() * Mathf.Rad2Deg;
                    if (obj && obj.IsGameObject())
                        ((GO)obj).SetCoordinates(Position);
                }
                else if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_HAS_POSITION))
                {
                    Position = gr.ReadCoords3();
                    Facing = gr.ReadSingle() * Mathf.Rad2Deg;
                    if (obj && obj.IsWorldObject())
                        ((WorldObject)obj).SetCoordinates(Position);
                }
            }

            if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_LOWGUID))
            {
                LowGuid = gr.ReadUInt32();
            }

            if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_HIGHGUID))
            {
                HighGuid = gr.ReadUInt32();
            }

            if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_TARGET_GUID))
            {
                AttackingTarget = gr.ReadPackedGuid();
            }

            if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_TRANSPORT))
            {
                TransportTime = gr.ReadUInt32();
            }

            // WotLK
            if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_VEHICLE))
            {
                VehicleId = gr.ReadUInt32();
                VehicleAimAdjustement = gr.ReadSingle();
            }

            // 3.1
            if (UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_GO_ROTATION))
            {
                GoRotationULong = gr.ReadUInt64(); // fixme
            }
        }
Beispiel #6
0
        public static MovementBlock Read(BinaryReader gr)
        {
            var movement = new MovementBlock();

            movement.UpdateFlags = (UpdateFlags)gr.ReadUInt16();

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_LIVING))
            {
                movement.Movement = MovementInfo.Read(gr);

                for (byte i = 0; i < movement.speeds.Length; ++i)
                    movement.speeds[i] = gr.ReadSingle();

                if (movement.Movement.Flags.HasFlag(MovementFlags.SPLINEENABLED))
                {
                    movement.Spline = SplineInfo.Read(gr);
                }
            }
            else
            {
                if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_GO_POSITION))
                {
                    movement.Movement.Transport.Guid = gr.ReadPackedGuid();
                    movement.Movement.Position = gr.ReadCoords3();
                    movement.Movement.Transport.Position = gr.ReadCoords3();
                    movement.Movement.Facing = gr.ReadSingle();
                    movement.Movement.Transport.Facing = gr.ReadSingle();
                }
                else if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_HAS_POSITION))
                {
                    movement.Movement.Position = gr.ReadCoords3();
                    movement.Movement.Facing = gr.ReadSingle();
                }
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_LOWGUID))
            {
                movement.LowGuid = gr.ReadUInt32();
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_HIGHGUID))
            {
                movement.HighGuid = gr.ReadUInt32();
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_TARGET_GUID))
            {
                movement.AttackingTarget = gr.ReadPackedGuid();
            }

            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_TRANSPORT))
            {
                movement.TransportTime = gr.ReadUInt32();
            }

            // WotLK
            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_VEHICLE))
            {
                movement.VehicleId = gr.ReadUInt32();
                movement.VehicleAimAdjustement = gr.ReadSingle();
            }

            // 3.1
            if (movement.UpdateFlags.HasFlag(UpdateFlags.UPDATEFLAG_GO_ROTATION))
            {
                movement.GoRotationULong = gr.ReadUInt64();
            }
            return movement;
        }