Esempio n. 1
0
        public static RealmPacketOut ConstructMultiWaypointMovePacket <T>(Unit movingUnit, uint moveTime,
                                                                          MonsterMoveFlags moveFlags, IEnumerable <T> waypoints) where T : IPathVertex
        {
            int            num    = waypoints.Count <T>();
            RealmPacketOut writer =
                new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_MONSTER_MOVE, 38 + num * 4 * 3);

            movingUnit.EntityId.WritePacked((BinaryWriter)writer);
            writer.Write(false);
            writer.Write(movingUnit.Position);
            writer.Write(Utility.GetSystemTime());
            writer.Write((byte)0);
            writer.Write((uint)moveFlags);
            if (moveFlags.HasFlag((Enum)MonsterMoveFlags.Flag_0x200000))
            {
                writer.Write((byte)0);
                writer.Write(0);
            }

            writer.Write(moveTime);
            if (moveFlags.HasFlag((Enum)MonsterMoveFlags.Flag_0x800))
            {
                writer.Write(0.0f);
                writer.Write(0);
            }

            writer.Write(num);
            if (moveFlags.HasAnyFlag(MonsterMoveFlags.Flag_0x2000_FullPoints_1 |
                                     MonsterMoveFlags.Flag_0x40000_FullPoints_2))
            {
                foreach (T waypoint in waypoints)
                {
                    IPathVertex pathVertex = (IPathVertex)waypoint;
                    writer.Write(pathVertex.Position);
                }
            }
            else
            {
                foreach (T waypoint in waypoints)
                {
                    IPathVertex pathVertex = (IPathVertex)waypoint;
                    writer.Write(pathVertex.Position.ToDeltaPacked(movingUnit.Position, waypoints.First <T>().Position));
                }
            }

            return(writer);
        }
Esempio n. 2
0
        public static RealmPacketOut ConstructMultiWaypointMovePacket <T>(Unit movingUnit, uint moveTime,
                                                                          MonsterMoveFlags moveFlags, IEnumerable <T> waypoints)
            where T : IPathVertex
        {
            var numWaypoints = waypoints.Count();
            var packet       = new RealmPacketOut(RealmServerOpCode.SMSG_MONSTER_MOVE,
                                                  (9 + 12 + 4 + 1 + 4 + 4 + 4 + (numWaypoints * 4 * 3)));


            movingUnit.EntityId.WritePacked(packet);
            //if (movingUnit.IsOnTransport)
            //{
            //  packet.OpCode = RealmServerOpCode.SMSG_MONSTER_MOVE_TRANSPORT;
            //  movingUnit.Transport.EntityId.WritePacked(packet);
            //  packet.Write((byte)movingUnit.TransportSeat);
            //}
            packet.Write(false);               // some boolean flag

            packet.Write(movingUnit.Position); // OnMonsterMove_serverLoc
            packet.Write(Utility.GetSystemTime());

            const MonsterMoveType moveType = MonsterMoveType.Normal;

            packet.Write((byte)moveType);
            switch (moveType)
            {
            case MonsterMoveType.Normal:
                break;
                // TODO: implement other cases
                //case MonsterMoveType.Stop:
                //    {
                //        return packet;
                //    }
                //case MonsterMoveType.FinalFacingPoint:
                //    {
                //        // OnMonsterMove_final_facingSpot
                //        packet.Write(0.0f);
                //        packet.Write(0.0f);
                //        packet.Write(0.0f);
                //    }
                //case MonsterMoveType.FinalFacingGuid:
                //    {
                //        packet.Write(0ul);
                //    }
                //case MonsterMoveType.FinalFacingAngle:
                //    {
                //        // OnMonsterMove_final_facingAngle
                //        packet.Write(movingUnit.Orientation);
                //    }
            }

            packet.Write((uint)moveFlags);
            if (moveFlags.HasFlag(MonsterMoveFlags.Flag_0x200000))
            {
                // TODO: what does this flag mean?
                packet.Write((byte)0);
                packet.Write(0);
            }

            packet.Write(moveTime);

            if (moveFlags.HasFlag(MonsterMoveFlags.Flag_0x800))
            {
                // TODO: what does this flag mean?
                packet.Write(0.0f);
                packet.Write(0);
            }

            packet.Write(numWaypoints);

            if (moveFlags.HasAnyFlag(MonsterMoveFlags.Flag_0x2000_FullPoints_1 | MonsterMoveFlags.Flag_0x40000_FullPoints_2))
            {
                foreach (IPathVertex waypoint in waypoints)
                {
                    packet.Write(waypoint.Position);                     // + 12*numWaypoints
                }
            }
            else
            {
                // OnMonsterMove_pathPoints_compressed
                foreach (IPathVertex waypoint in waypoints)
                {
                    packet.Write(waypoint.Position.ToDeltaPacked(movingUnit.Position, waypoints.First().Position));                     // + 12*numWaypoints
                }
            }

            return(packet);
        }