muddesigner/MudEngine/Commands/CommandWalk.cs
Scionwest_cp bbd411fdd1 MudEngine:
- Removed the need for the old CommandResult Type to be a returned value on all commands. Command.Execute() is now just void.
 - All commands updated to now return a value. They use player.Send() to direct messages to the player instead.
 - Removed CommandClear from the project and made it a script so that developers can see how to write custom command scripts.
2010-08-15 13:06:51 -07:00

51 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using MudEngine.GameObjects.Characters;
using MudEngine.GameManagement;
using MudEngine.GameObjects.Environment;
using MudEngine.GameObjects;
using MudEngine.FileSystem;
namespace MudEngine.Commands
{
public class CommandWalk : IGameCommand
{
public String Name { get; set; }
public Boolean Override { get; set; }
public void Execute(String command, BaseCharacter player)
{
String[] words = command.Split(' ');
List<String> directions = new List<String>();
if (words.Length == 1)
{
player.Send("No direction provided!");
return;
}
else
{
foreach (Door door in player.CurrentRoom.Doorways)
{
if (door.TravelDirection == TravelDirections.GetTravelDirectionValue(words[1]))
{
//Move the player into their new room
player.Move(door.TravelDirection);
player.CommandSystem.ExecuteCommand("Look", player);
if (player.ActiveGame.AutoSave)
player.Save(player.ActiveGame.DataPaths.Players);
return;
}
}
}
player.Send("Unable to travel in that direction.");
}
}
}