muddesigner/MudEngine/WinPC_Engine/GameScripts/Commands/CommandSay.cs
Scionwest_cp 27f7e31772 * Re-wrote the Server code again. Now much more reliable and passes all connections to the ConnectionManager properly.
* StandardCharacter re-wrote to support the new Server code.  Also added event method support for various states.
* ConnectionManager re-wrote to support the new server.
* Work on Log message importance started
* INetworked.Connect now requires a Socket as its parameter.
* StandardGame no longer has Properties for MaxConnections and MaxQueuedConnections.  This is handle via StandardGame.Start() parameters.
* CommandLogin command added.  Initial check-in and not fully implemented.
2012-03-03 11:17:01 -08:00

47 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Core.Interface;
using MudEngine.Game;
using MudEngine.Game.Characters;
using MudEngine.Networking;
namespace MudEngine.GameScripts.Commands
{
public class CommandSay : ICommand
{
public string Name { get; set; }
public string Description { get; set; }
public List<string> Help { get; set; }
public CommandSay()
{
this.Name = "Say";
this.Description = "Chat command that allows objects to communicate.";
}
public void Execute(string command, StandardCharacter character)
{
//Grab a reference to the character for simplifying access.
StandardGame game = character.Game;
//Remove the command "Say " from the string so we only have it's message
String message = command.Substring(3).Trim();
//Loop through each character on the server and broadcast the message.
//TODO: This should only broadcast to characters that are in the same Environment.
foreach (StandardCharacter c in character.Game.Server.ConnectionManager.GetConnectedCharacters())
{
//Only broadcast this message to those that are not the broadcastor.
if (c != character)
c.SendMessage(character.ToString() + " says: " + message);
}
//Send a different copy of the message to the broadcastor.
character.SendMessage("You say: " + message);
}
}
}