示例#1
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            List <WorldPlayer> players = new List <WorldPlayer>();

            bool isWorldReset = message.GetBoolean(0);

            uint index = 1;

            while (index + 2 < message.Count)
            {
                WorldPlayer player = worldCon.Players.GetPlayer(message.GetInt(index));
                if (player != null)
                {
                    if (!handled)
                    {
                        Vector loc = new Vector(message.GetInt(index + 1), message.GetInt(index + 2));
                        player.SetLocationInternal(loc);

                        if (!isWorldReset)
                        {
                            player.Respawn();
                        }
                    }

                    players.Add(player);
                }

                index += 3;
            }

            if (isWorldReset)
            {
                ResetEvent resetEvent = new ResetEvent()
                {
                    Raw = message
                };

                connectionBase.RaiseServerEvent <ResetEvent>(resetEvent);
            }
            else
            {
                for (int i = 0; i < players.Count; i++)
                {
                    KillEvent killEvent = new KillEvent()
                    {
                        Raw    = message,
                        Player = players[i]
                    };

                    connectionBase.RaiseServerEvent <KillEvent>(killEvent);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            Vector location = new Vector(message.GetInt(1), message.GetInt(2));

            if (!handled && player != null)
            {
                player.SetLocationInternal(location);
            }

            TeleportEvent teleportEvent = new TeleportEvent()
            {
                Raw      = message,
                Player   = player,
                Location = location
            };

            connectionBase.RaiseServerEvent <TeleportEvent>(teleportEvent);
        }