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 speechInfo = message.ReadSpeechInfo();

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

            // TODO: proper implementation.
            var msgStr = speechInfo.Speech.Message;

            if (msgStr.ToLower().StartsWith("test"))
            {
                this.Game.TestingViaCreatureSpeech(player, msgStr);
            }

            // TODO: implement all spells and speech related hooks.
            this.Game.NotifySpectatingPlayers(conn => new CreatureSpokeNotification(connection, player, speechInfo.Speech.Type, speechInfo.Speech.Message, speechInfo.Speech.ChannelId), player.Location);

            Console.WriteLine($"{player.Name}: {speechInfo.Speech.Message}");
        }