Began the pain staking process of replacing the old and ugly Mud Designer Script Engine with my new rScripting Engine.
rScripting can be found on Codeplex at http://rScript.Codeplex.com which is a complete script engine. Mud Designer will make use of it, and will allow me to just work on the Mud Designer engine, as my rScript is complete. I still had quiet a bit of work to do with the Mud Designers Script System.
This commit is contained in:
parent
f446c754fb
commit
ee532c5a03
6 changed files with 58 additions and 13 deletions
|
@ -76,8 +76,9 @@ namespace MudDesigner
|
||||||
{
|
{
|
||||||
String Env = _Game.DataPaths.Environment.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
String Env = _Game.DataPaths.Environment.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
||||||
String plyr = _Game.DataPaths.Players.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
String plyr = _Game.DataPaths.Players.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
||||||
|
String scrpt = _Game.DataPaths.Scripts.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
||||||
|
|
||||||
_Game.DataPaths = new SaveDataPaths(Env, plyr);
|
_Game.DataPaths = new SaveDataPaths(Env, plyr,scrpt);
|
||||||
|
|
||||||
_IsRenaming = true;
|
_IsRenaming = true;
|
||||||
_OldName = e.OldValue.ToString();
|
_OldName = e.OldValue.ToString();
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace MudDesigner
|
||||||
|
|
||||||
_Game.GameTitle = input.Input;
|
_Game.GameTitle = input.Input;
|
||||||
//Setup save data paths.
|
//Setup save data paths.
|
||||||
_Game.DataPaths = new SaveDataPaths(Path.Combine("Projects", _Game.GameTitle, _Game.DataPaths.Environment), Path.Combine("Projects", _Game.GameTitle, _Game.DataPaths.Players));
|
_Game.DataPaths = new SaveDataPaths(Path.Combine("Projects", _Game.GameTitle, _Game.DataPaths.Environment), Path.Combine("Projects", _Game.GameTitle, _Game.DataPaths.Players), Path.Combine("Projects", _Game.GameTitle, _Game.DataPath.Scripts));
|
||||||
|
|
||||||
_Game.Save();
|
_Game.Save();
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,28 @@ namespace MudEngine.FileSystem
|
||||||
_Environment = value;
|
_Environment = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String Scripts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _Scripts;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_Scripts = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String _Players;
|
private String _Players;
|
||||||
private String _Environment;
|
private String _Environment;
|
||||||
|
private String _Scripts;
|
||||||
|
|
||||||
public SaveDataPaths(String environment, String players)
|
public SaveDataPaths(String environment, String players, String scripts)
|
||||||
{
|
{
|
||||||
_Players = players;
|
_Players = players;
|
||||||
_Environment = environment;
|
_Environment = environment;
|
||||||
|
_Scripts = scripts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,9 @@ namespace MudEngine.GameManagement
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public ScriptEngine scriptEngine { get; internal set; }
|
public ScriptEngine scriptEngine { get; internal set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
public rScripting.CompileEngine Scripting { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets the path to the current project
|
/// Gets or Sets the path to the current project
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -198,13 +201,14 @@ namespace MudEngine.GameManagement
|
||||||
{
|
{
|
||||||
//Instance all of the Games Objects.
|
//Instance all of the Games Objects.
|
||||||
CurrencyList = new List<Currency>();
|
CurrencyList = new List<Currency>();
|
||||||
scriptEngine = new Scripting.ScriptEngine(this);
|
scriptEngine = new Scripting.ScriptEngine(this); //TODO - Remove
|
||||||
|
Scripting = new rScripting.CompileEngine(".cs");
|
||||||
World = new GameWorld(this);
|
World = new GameWorld(this);
|
||||||
WorldTime = new GameTime(this);
|
WorldTime = new GameTime(this);
|
||||||
InitialRealm = new Realm(this);
|
InitialRealm = new Realm(this);
|
||||||
|
|
||||||
//Prepare the Save Paths for all of our Game objects.
|
//Prepare the Save Paths for all of our Game objects.
|
||||||
DataPaths = new SaveDataPaths("World", "Players");
|
DataPaths = new SaveDataPaths("World", "Players", "Scripts");
|
||||||
|
|
||||||
//Setup default settings for the Game
|
//Setup default settings for the Game
|
||||||
GameTitle = "New Game";
|
GameTitle = "New Game";
|
||||||
|
@ -242,9 +246,18 @@ namespace MudEngine.GameManagement
|
||||||
if (!Directory.Exists(DataPaths.Players))
|
if (!Directory.Exists(DataPaths.Players))
|
||||||
Directory.CreateDirectory(DataPaths.Players);
|
Directory.CreateDirectory(DataPaths.Players);
|
||||||
|
|
||||||
//Load both pre-compiled and file based scripts
|
//Load both pre-compiled and file based scripts - TODO - Remove
|
||||||
scriptEngine.ScriptType = ScriptEngine.ScriptTypes.Both;
|
//scriptEngine.ScriptType = ScriptEngine.ScriptTypes.Both;
|
||||||
scriptEngine.Initialize();
|
//scriptEngine.Initialize();
|
||||||
|
|
||||||
|
//Instance the new scripting engine
|
||||||
|
Scripting.Compiler = "C#";
|
||||||
|
Scripting.AddAssemblyReference("MudEngine.dll");
|
||||||
|
if (!Scripting.Compile(DataPaths.Scripts))
|
||||||
|
{
|
||||||
|
Log.Write("CRITICAL ERROR: Game Script Repository failed to compile!");
|
||||||
|
Log.Write(Scripting.Errors);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a custom player script is loaded in the script engine, then the base commands are
|
* If a custom player script is loaded in the script engine, then the base commands are
|
||||||
|
@ -273,7 +286,7 @@ namespace MudEngine.GameManagement
|
||||||
}
|
}
|
||||||
else //Not multiplayer so we change the save locations
|
else //Not multiplayer so we change the save locations
|
||||||
{
|
{
|
||||||
SaveDataPaths paths = new SaveDataPaths("World", "Player");
|
SaveDataPaths paths = new SaveDataPaths("World", "Player", "Scripts");
|
||||||
DataPaths = paths;
|
DataPaths = paths;
|
||||||
PlayerCollection[0].Initialize();
|
PlayerCollection[0].Initialize();
|
||||||
}
|
}
|
||||||
|
@ -371,6 +384,8 @@ namespace MudEngine.GameManagement
|
||||||
FileManager.WriteLine(filename, this.CompanyName, "CompanyName");
|
FileManager.WriteLine(filename, this.CompanyName, "CompanyName");
|
||||||
FileManager.WriteLine(filename, this.DataPaths.Environment, "DataPathEnvironment");
|
FileManager.WriteLine(filename, this.DataPaths.Environment, "DataPathEnvironment");
|
||||||
FileManager.WriteLine(filename, this.DataPaths.Players, "DataPathPlayers");
|
FileManager.WriteLine(filename, this.DataPaths.Players, "DataPathPlayers");
|
||||||
|
FileManager.WriteLine(filename, this.DataPaths.Scripts, "DataPathScripts");
|
||||||
|
|
||||||
FileManager.WriteLine(filename, this.GameTitle, "GameTitle");
|
FileManager.WriteLine(filename, this.GameTitle, "GameTitle");
|
||||||
FileManager.WriteLine(filename, this.HideRoomNames.ToString(), "HideRoomNames");
|
FileManager.WriteLine(filename, this.HideRoomNames.ToString(), "HideRoomNames");
|
||||||
|
|
||||||
|
@ -417,7 +432,7 @@ namespace MudEngine.GameManagement
|
||||||
this.BaseCurrencyAmount = Convert.ToInt32(FileManager.GetData(filename, "BaseCurrencyAmount"));
|
this.BaseCurrencyAmount = Convert.ToInt32(FileManager.GetData(filename, "BaseCurrencyAmount"));
|
||||||
this.BaseCurrencyName = FileManager.GetData(filename, "BaseCurrencyName");
|
this.BaseCurrencyName = FileManager.GetData(filename, "BaseCurrencyName");
|
||||||
this.CompanyName = FileManager.GetData(filename, "CompanyName");
|
this.CompanyName = FileManager.GetData(filename, "CompanyName");
|
||||||
this.DataPaths = new SaveDataPaths(FileManager.GetData(filename, "DataPathEnvironment"), FileManager.GetData(filename, "DataPathPlayers"));
|
this.DataPaths = new SaveDataPaths(FileManager.GetData(filename, "DataPathEnvironment"), FileManager.GetData(filename, "DataPathPlayers"), FileManager.GetData(filename, "DataPathScripts"));
|
||||||
this.GameTitle = FileManager.GetData(filename, "GameTitle");
|
this.GameTitle = FileManager.GetData(filename, "GameTitle");
|
||||||
this.HideRoomNames = Convert.ToBoolean(FileManager.GetData(filename, "HideRoomNames"));
|
this.HideRoomNames = Convert.ToBoolean(FileManager.GetData(filename, "HideRoomNames"));
|
||||||
this.InitialRealm = new Realm(this);
|
this.InitialRealm = new Realm(this);
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="rScripting">
|
||||||
|
<HintPath>..\..\rScript\rScripting\bin\Release\rScripting.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
|
|
@ -15,10 +15,11 @@ namespace MudGame
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
const String SettingsFile = "Settings.ini";
|
const String SettingsFile = "Settings.ini";
|
||||||
|
static dynamic _Game;
|
||||||
|
|
||||||
static void Main(String[] args)
|
static void Main(String[] args)
|
||||||
{
|
{
|
||||||
dynamic game = new Game();
|
Game game = new Game();
|
||||||
|
|
||||||
//Re-create the settings file if it is missing. Don't push any log messages until we know that this is
|
//Re-create the settings file if it is missing. Don't push any log messages until we know that this is
|
||||||
//verbose or not
|
//verbose or not
|
||||||
|
@ -44,8 +45,14 @@ namespace MudGame
|
||||||
Log.FlushMessages();
|
Log.FlushMessages();
|
||||||
|
|
||||||
Log.Write("Launching...", true);
|
Log.Write("Launching...", true);
|
||||||
|
/* - Replaced with new startup sequence.
|
||||||
|
* Engine uses my rScript Scripting Engine instead of a custom Mud Designer script Engine.
|
||||||
|
* Easier to maintain, and works better.
|
||||||
|
*
|
||||||
|
* TODO - Remove Old Script Engine code.
|
||||||
|
*
|
||||||
ScriptEngine scriptEngine;
|
ScriptEngine scriptEngine;
|
||||||
scriptEngine = new ScriptEngine(new Game(), ScriptEngine.ScriptTypes.Both);
|
scriptEngine = new ScriptEngine(game, ScriptEngine.ScriptTypes.Both);
|
||||||
|
|
||||||
//scriptEngine.CompileScripts();
|
//scriptEngine.CompileScripts();
|
||||||
Log.Write("Initializing Script Engine for Script Compilation...", true);
|
Log.Write("Initializing Script Engine for Script Compilation...", true);
|
||||||
|
@ -73,11 +80,14 @@ namespace MudGame
|
||||||
//MUST be called before game.Start()
|
//MUST be called before game.Start()
|
||||||
//scriptEngine.Initialize();
|
//scriptEngine.Initialize();
|
||||||
//game.scriptEngine = scriptEngine; //Pass this script engine off to the game to use now.
|
//game.scriptEngine = scriptEngine; //Pass this script engine off to the game to use now.
|
||||||
|
|
||||||
|
|
||||||
Log.Write("");
|
Log.Write("");
|
||||||
Log.Write("Starting " + obj.GetProperty().GameTitle + "...", true);
|
Log.Write("Starting " + obj.GetProperty().GameTitle + "...", true);
|
||||||
Log.Write("");
|
Log.Write("");
|
||||||
//Console.WriteLine(Log.GetMessages());
|
//Console.WriteLine(Log.GetMessages());
|
||||||
//Log.FlushMessages();
|
//Log.FlushMessages();
|
||||||
|
*/
|
||||||
|
|
||||||
//Server is only enabled if the option is in the settings file
|
//Server is only enabled if the option is in the settings file
|
||||||
//Allows developers to remove the option from the settings file and letting
|
//Allows developers to remove the option from the settings file and letting
|
||||||
|
@ -91,6 +101,7 @@ namespace MudGame
|
||||||
else
|
else
|
||||||
game.IsMultiplayer = true;
|
game.IsMultiplayer = true;
|
||||||
|
|
||||||
|
//Start the game.
|
||||||
game.Start();
|
game.Start();
|
||||||
|
|
||||||
//Make sure the Game is in fact running.
|
//Make sure the Game is in fact running.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue