DataPaths now have values for the games Root directory and Script directory.
DataPath class is now completed and includes a new SetExtension() method for setting game object file extensions. Scripting support fully implemented. StandardGame now contains a Initialize() method for compiling scripts and searching for sub-classes of StandardGame Server app will now use a Scripted game class instead of the default StandardGame if one is present. StandardGame.Start() is now virtual so child classes can override it. Sample Game script created to show how to create a custom game script, including how to setup the game and create Rooms pragamatically. ScriptFactory has a new method for searching all scripts and scripts that inherit from a specified class. Renamed all of the Command scripts. They no longer start with 'Command'. Example: "CommandSay" has now become "Say". There is no need to preceed the command name with the word "Command" anymore.
This commit is contained in:
parent
c40d32e7ae
commit
8639403255
14 changed files with 323 additions and 69 deletions
|
@ -9,10 +9,12 @@ namespace MudEngine.DAL
|
|||
{
|
||||
public enum DataTypes
|
||||
{
|
||||
Root,
|
||||
Players,
|
||||
Environments,
|
||||
Characters,
|
||||
Equipment
|
||||
Equipment,
|
||||
Scripts,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -26,7 +28,17 @@ namespace MudEngine.DAL
|
|||
String assemblyFile = Path.GetFileName(path);
|
||||
this._InstallRoot = path.Substring(0, path.Length - assemblyFile.Length);
|
||||
|
||||
this.SetAbsolutePath(Path.Combine(this._InstallRoot, "Characters"), DataTypes.Characters);
|
||||
this.SetAbsolutePath(Path.Combine(this._InstallRoot, "Environments"), DataTypes.Environments);
|
||||
this.SetAbsolutePath(Path.Combine(this._InstallRoot, "Equipment"), DataTypes.Equipment);
|
||||
this.SetAbsolutePath(Path.Combine(this._InstallRoot, "Players"), DataTypes.Players);
|
||||
this.SetAbsolutePath(Path.Combine(this._InstallRoot, "GameScripts"), DataTypes.Scripts);
|
||||
|
||||
this.SetExtension(DataTypes.Characters, ".character");
|
||||
this.SetExtension(DataTypes.Environments, ".environment");
|
||||
this.SetExtension(DataTypes.Equipment, ".equipment");
|
||||
this.SetExtension(DataTypes.Players, ".player");
|
||||
this.SetExtension(DataTypes.Scripts, ".cs");
|
||||
}
|
||||
|
||||
public void SetAbsolutePath(String path, DataTypes objectType)
|
||||
|
@ -36,9 +48,21 @@ namespace MudEngine.DAL
|
|||
|
||||
switch (objectType)
|
||||
{
|
||||
case DataTypes.Characters:
|
||||
this._Characters = path;
|
||||
break;
|
||||
case DataTypes.Environments:
|
||||
this._Environments = path;
|
||||
break;
|
||||
case DataTypes.Equipment:
|
||||
this._Equipment = path;
|
||||
break;
|
||||
case DataTypes.Players:
|
||||
this._Players = path;
|
||||
break;
|
||||
case DataTypes.Scripts:
|
||||
this._Scripts = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,10 +72,23 @@ namespace MudEngine.DAL
|
|||
|
||||
public String GetPath(DataTypes objectType)
|
||||
{
|
||||
if (objectType == DataTypes.Players)
|
||||
return this._Players;
|
||||
else
|
||||
return String.Empty;
|
||||
switch (objectType)
|
||||
{
|
||||
case DataTypes.Root:
|
||||
return this._InstallRoot;
|
||||
case DataTypes.Characters:
|
||||
return this._Characters;
|
||||
case DataTypes.Environments:
|
||||
return this._Environments;
|
||||
case DataTypes.Equipment:
|
||||
return this._Equipment;
|
||||
case DataTypes.Players:
|
||||
return this._Players;
|
||||
case DataTypes.Scripts:
|
||||
return this._Scripts;
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
public String GetFilePath(DataTypes objectType, String filename)
|
||||
|
@ -60,9 +97,24 @@ namespace MudEngine.DAL
|
|||
|
||||
switch (objectType)
|
||||
{
|
||||
case DataTypes.Root:
|
||||
result = Path.Combine(this._InstallRoot, filename + this.GetExtension(DataTypes.Root));
|
||||
break;
|
||||
case DataTypes.Characters:
|
||||
result = Path.Combine(this._Characters, filename + this.GetExtension(DataTypes.Characters));
|
||||
break;
|
||||
case DataTypes.Environments:
|
||||
result = Path.Combine(this._Environments, filename + this.GetExtension(DataTypes.Environments));
|
||||
break;
|
||||
case DataTypes.Equipment:
|
||||
result = Path.Combine(this._Equipment, filename + this.GetExtension(DataTypes.Equipment));
|
||||
break;
|
||||
case DataTypes.Players:
|
||||
result = Path.Combine(this._Players, filename + this.GetExtension(DataTypes.Players));
|
||||
break;
|
||||
case DataTypes.Scripts:
|
||||
result = Path.Combine(this._Scripts, filename + this.GetExtension(DataTypes.Scripts));
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -74,18 +126,64 @@ namespace MudEngine.DAL
|
|||
|
||||
switch (objectType)
|
||||
{
|
||||
case DataTypes.Root:
|
||||
result = ".dat";
|
||||
break;
|
||||
case DataTypes.Characters:
|
||||
result = this._CharacterExt;
|
||||
break;
|
||||
case DataTypes.Environments:
|
||||
result = this._EnvironmentExt;
|
||||
break;
|
||||
case DataTypes.Equipment:
|
||||
result = this._EquipmentExt;
|
||||
break;
|
||||
case DataTypes.Scripts:
|
||||
result = this._ScriptExt;
|
||||
break;
|
||||
case DataTypes.Players:
|
||||
result = ".player";
|
||||
result = this._PlayersExt;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SetExtension(DataTypes objectType, String extension)
|
||||
{
|
||||
if (!extension.StartsWith("."))
|
||||
extension = extension.Insert(0, ".");
|
||||
|
||||
switch (objectType)
|
||||
{
|
||||
case DataTypes.Characters:
|
||||
this._CharacterExt = extension;
|
||||
break;
|
||||
case DataTypes.Environments:
|
||||
this._EnvironmentExt = extension;
|
||||
break;
|
||||
case DataTypes.Equipment:
|
||||
this._EquipmentExt = extension;
|
||||
break;
|
||||
case DataTypes.Players:
|
||||
this._PlayersExt = extension;
|
||||
break;
|
||||
case DataTypes.Scripts:
|
||||
this._ScriptExt = extension;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private String _InstallRoot;
|
||||
private String _Players;
|
||||
private String _PlayersExt;
|
||||
private String _Environments;
|
||||
private String _EnvironmentExt;
|
||||
private String _Characters;
|
||||
private String _CharacterExt;
|
||||
private String _Equipment;
|
||||
private String _EquipmentExt;
|
||||
private String _Scripts;
|
||||
private String _ScriptExt;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue