Example #1
0
        /// <summary>
        /// Handles the contents of a network message.
        /// </summary>
        /// <param name="message">The message to handle.</param>
        /// <param name="connection">A reference to the connection from where this message is comming from, for context.</param>
        public override void HandleRequest(INetworkMessage message, IConnection connection)
        {
            var outfitInfo = message.ReadOutfitInfo();

            if (!(this.Game.GetCreatureWithId(connection.PlayerId) is IPlayer player))
            {
                return;
            }

            // TODO: check if player actually has permissions to change outfit.
            player.SetOutfit(outfitInfo.Outfit);

            this.Game.NotifySpectatingPlayers(conn => new CreatureChangedOutfitNotification(conn, player), player.Location);
        }