Exemple #1
0
        /// <summary>
        /// Sends the data to the specified user of all existing content on the map.
        /// </summary>
        /// <param name="user">User to send the map data to.</param>
        void SendMapData(User user)
        {
            using (var pw = ServerPacket.GetWriter())
            {
                // Tell the user to change the map
                ServerPacket.SetMap(pw, ID);
                user.Send(pw, ServerMessageType.Map);

                // Send dynamic entities
                foreach (var dynamicEntity in DynamicEntities)
                {
                    pw.Reset();
                    ServerPacket.CreateDynamicEntity(pw, dynamicEntity);
                    user.Send(pw, ServerMessageType.Map);

                    // Perform special synchronizations for Characters
                    var character = dynamicEntity as Character;
                    if (character != null)
                    {
                        character.SynchronizeSPTo(user);
                        character.SynchronizePaperdollTo(user);
                    }
                }

                // Now that the user know about the Map and every Entity on it, tell them which one is theirs
                pw.Reset();
                ServerPacket.SetUserChar(pw, user.MapEntityIndex);
                user.Send(pw, ServerMessageType.Map);
            }
        }