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.
This commit is contained in:
parent
9792bfcd32
commit
bbd411fdd1
14 changed files with 35 additions and 77 deletions
|
@ -1,27 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using MudEngine.FileSystem;
|
|
||||||
using MudEngine.GameObjects.Characters;
|
|
||||||
using MudEngine.GameManagement;
|
|
||||||
using MudEngine.Commands;
|
|
||||||
using MudEngine.GameObjects.Environment;
|
|
||||||
|
|
||||||
namespace MudEngine.Commands
|
|
||||||
{
|
|
||||||
public class CommandClear : IGameCommand
|
|
||||||
{
|
|
||||||
public Boolean Override { get; set; }
|
|
||||||
public String Name { get; set; }
|
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
|
||||||
{
|
|
||||||
player.FlushConsole();
|
|
||||||
|
|
||||||
return new CommandResults();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@ namespace MudEngine.Commands
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
if (player.ActiveGame.IsMultiplayer)
|
if (player.ActiveGame.IsMultiplayer)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,6 @@ namespace MudEngine.Commands
|
||||||
player.Save(player.ActiveGame.DataPaths.Players);
|
player.Save(player.ActiveGame.DataPaths.Players);
|
||||||
player.ActiveGame.Shutdown();
|
player.ActiveGame.Shutdown();
|
||||||
}
|
}
|
||||||
return new CommandResults();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,9 @@ namespace MudEngine.Commands
|
||||||
|
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
|
|
||||||
public MudEngine.GameManagement.CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
player.Send(player.ActiveGame.WorldTime.GetCurrentWorldTime());
|
player.Send(player.ActiveGame.WorldTime.GetCurrentWorldTime());
|
||||||
|
|
||||||
return new GameManagement.CommandResults();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,12 @@ namespace MudEngine.Commands
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
String path = player.ActiveGame.DataPaths.Players;
|
String path = player.ActiveGame.DataPaths.Players;
|
||||||
String filename = Path.Combine(path, player.Filename);
|
String filename = Path.Combine(path, player.Filename);
|
||||||
|
|
||||||
player.Load(filename);
|
player.Load(filename);
|
||||||
|
|
||||||
return new CommandResults();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MudEngine.Commands
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
player.Send(player.ActiveGame.GameTitle);
|
player.Send(player.ActiveGame.GameTitle);
|
||||||
player.Send(player.ActiveGame.Version);
|
player.Send(player.ActiveGame.Version);
|
||||||
|
@ -131,8 +131,6 @@ namespace MudEngine.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CommandResults();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,12 @@ namespace MudEngine.Commands
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
if (player.CurrentRoom == null)
|
if (player.CurrentRoom == null)
|
||||||
{
|
{
|
||||||
return new CommandResults("Not within a created Room.");
|
player.Send("You are not within any Room.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.CurrentRoom.DetailedDescription.Count == 0)
|
if (player.CurrentRoom.DetailedDescription.Count == 0)
|
||||||
|
@ -33,8 +34,6 @@ namespace MudEngine.Commands
|
||||||
player.Send(entry);
|
player.Send(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CommandResults();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace MudEngine.Commands
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
if (player.Role == SecurityRoles.Admin)
|
if (player.Role == SecurityRoles.Admin)
|
||||||
{
|
{
|
||||||
|
@ -41,11 +41,13 @@ namespace MudEngine.Commands
|
||||||
player.ActiveGame.Server.Initialize(555, ref player.ActiveGame.PlayerCollection);
|
player.ActiveGame.Server.Initialize(555, ref player.ActiveGame.PlayerCollection);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Console.WriteLine("Server Restart Completed.");
|
Log.Write("Server Restart Completed.");
|
||||||
//This is never printed as CommandResults is no longer outputted to the player console, player.Send is used
|
//This is never printed as CommandResults is no longer outputted to the player console, player.Send is used
|
||||||
return new CommandResults("Server Restarted.");
|
player.Send("Server Restarted.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return new CommandResults("Access Denied.");
|
|
||||||
|
player.Send("Access Denied.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,22 +16,9 @@ namespace MudEngine.Commands
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (player.ActiveGame.PlayerCollection.Length != 0)
|
|
||||||
{
|
|
||||||
if (player.GetType().Name != "BaseCharacter")
|
|
||||||
{
|
|
||||||
Scripting.GameObject obj = player.ActiveGame.scriptEngine.GetObject(player.ActiveGame.PlayerCollection.GetType().Name);
|
|
||||||
|
|
||||||
obj.InvokeMethod("Save", new object[] { player.ActiveGame.DataPaths.Players });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else */
|
|
||||||
player.Save(player.ActiveGame.DataPaths.Players);
|
player.Save(player.ActiveGame.DataPaths.Players);
|
||||||
|
|
||||||
return new CommandResults();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,12 @@ namespace MudEngine.Commands
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM))
|
if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM))
|
||||||
{
|
{
|
||||||
player.ActiveGame.Save();
|
player.ActiveGame.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CommandResults();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,16 @@ namespace MudEngine.Commands
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
public Boolean Override { get; set; }
|
public Boolean Override { get; set; }
|
||||||
|
|
||||||
public CommandResults Execute(String command, BaseCharacter player)
|
public void Execute(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
String[] words = command.Split(' ');
|
String[] words = command.Split(' ');
|
||||||
List<String> directions = new List<String>();
|
List<String> directions = new List<String>();
|
||||||
|
|
||||||
if (words.Length == 1)
|
if (words.Length == 1)
|
||||||
return new CommandResults("No direction supplied");
|
{
|
||||||
|
player.Send("No direction provided!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (Door door in player.CurrentRoom.Doorways)
|
foreach (Door door in player.CurrentRoom.Doorways)
|
||||||
|
@ -38,13 +41,11 @@ namespace MudEngine.Commands
|
||||||
if (player.ActiveGame.AutoSave)
|
if (player.ActiveGame.AutoSave)
|
||||||
player.Save(player.ActiveGame.DataPaths.Players);
|
player.Save(player.ActiveGame.DataPaths.Players);
|
||||||
|
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.Send("Unable to travel in that direction.");
|
player.Send("Unable to travel in that direction.");
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace MudEngine.GameManagement
|
||||||
/// <param name="Name"></param>
|
/// <param name="Name"></param>
|
||||||
/// <param name="Parameter"></param>
|
/// <param name="Parameter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public CommandResults ExecuteCommand(String command, BaseCharacter player)
|
public void ExecuteCommand(String command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
String commandKey = command.Insert(0, "Command");
|
String commandKey = command.Insert(0, "Command");
|
||||||
|
|
||||||
|
@ -79,13 +79,10 @@ namespace MudEngine.GameManagement
|
||||||
if (commandKey.ToLower().Contains(key.ToLower()))
|
if (commandKey.ToLower().Contains(key.ToLower()))
|
||||||
{
|
{
|
||||||
IGameCommand cmd = CommandEngine.CommandCollection[key];
|
IGameCommand cmd = CommandEngine.CommandCollection[key];
|
||||||
return cmd.Execute(command, player);
|
cmd.Execute(command, player);
|
||||||
//return player.CommandSystem._Commands[key].Execute(command, player);
|
return;
|
||||||
//return player.Commands.ExecuteCommand[key.ToLower()]Execute(command, player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CommandResults();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadBaseCommands()
|
public static void LoadBaseCommands()
|
||||||
|
|
|
@ -19,6 +19,6 @@ namespace MudEngine.GameManagement
|
||||||
//Used to override commands with the same name
|
//Used to override commands with the same name
|
||||||
Boolean Override { get; set; }
|
Boolean Override { get; set; }
|
||||||
//Executes the command.
|
//Executes the command.
|
||||||
CommandResults Execute(String command, BaseCharacter player);
|
void Execute(String command, BaseCharacter player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
<Compile Include="Commands\CommandWalk.cs" />
|
<Compile Include="Commands\CommandWalk.cs" />
|
||||||
<Compile Include="Commands\CommandLoad.cs" />
|
<Compile Include="Commands\CommandLoad.cs" />
|
||||||
<Compile Include="Commands\CommandLogin.cs" />
|
<Compile Include="Commands\CommandLogin.cs" />
|
||||||
<Compile Include="Commands\CommandClear.cs" />
|
|
||||||
<Compile Include="Commands\CommandSaveWorld.cs" />
|
<Compile Include="Commands\CommandSaveWorld.cs" />
|
||||||
<Compile Include="FileSystem\SaveDataPaths.cs" />
|
<Compile Include="FileSystem\SaveDataPaths.cs" />
|
||||||
<Compile Include="GameManagement\CommandEngine.cs" />
|
<Compile Include="GameManagement\CommandEngine.cs" />
|
||||||
|
|
10
MudGame/bin/Debug/Scripts/CommandClear.cs
Normal file
10
MudGame/bin/Debug/Scripts/CommandClear.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
public class CommandClear : IGameCommand
|
||||||
|
{
|
||||||
|
public Boolean Override { get; set; }
|
||||||
|
public String Name { get; set; }
|
||||||
|
|
||||||
|
public void Execute(String command, BaseCharacter player)
|
||||||
|
{
|
||||||
|
player.FlushConsole();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue