MudCompiler:
- Removed External Script compilation support for now. I'll add it back once I provide SourceFile and SourceCode compiling support to the MudScriptCompiler. At the moment only Whole Directory compiling is supported. MudDesigner: - Removed all of the source code, with the exception of the designer generated source, from frmProjectManager. It will need to be re-wrote due to the removal of the MudScriptEngine. MudEngine: - Deleted Scripting.GameObject - Deleted Scripting.GameObjectCollection - Deleted Scripting.ScriptEngine - Deleted classes were replaced by the rScript engine. Only class needed now is the MudScriptCompiler, which handles all of the custom MudEngine script compiling, using the rScript Engine. - Removed old Scripting.ScriptEngine references from within GameManagement.Game - GameManagement.Game no longer checks to see if MudEngine.dll exists. If it didn't exist, the engine wouldn't be running to perform that check in the first place. - GameManagement.Game no longer adds MudEngine.dll as a referenced assembly. The MudScriptCompiler handles that during compilation. - MudScriptCompiler.Compile() always returns false when SourceFile or SourceCode is passed as an argument. Only Script Directories can be compiled at this time. MudGame: - Removed references to Scripting.ScriptEngine from MudGame.Program - Re-wrote how scripted Type's that inherit and replace MudEngine.GameManagement.Game. Scripts are compiled prior to Game.Start() being invoked, allowing GameManagement.Game to be replaced with an inherited class from a compiled script. TODO: Look at a way to prevent Game.Start() from compiling the scripts again, as they have already been compiled once. It's not a big hit on startup time, but it needs to be wrote the proper way.
This commit is contained in:
parent
7a0d1c5a74
commit
3f73247d0e
10 changed files with 38 additions and 689 deletions
|
@ -15,7 +15,6 @@ namespace MudGame
|
|||
static class Program
|
||||
{
|
||||
const String SettingsFile = "Settings.ini";
|
||||
static dynamic _Game;
|
||||
|
||||
static void Main(String[] args)
|
||||
{
|
||||
|
@ -45,49 +44,32 @@ namespace MudGame
|
|||
Log.FlushMessages();
|
||||
|
||||
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 = new ScriptEngine(game, ScriptEngine.ScriptTypes.Both);
|
||||
|
||||
//scriptEngine.CompileScripts();
|
||||
Log.Write("Initializing Script Engine for Script Compilation...", true);
|
||||
scriptEngine.Initialize();
|
||||
|
||||
GameObject obj = scriptEngine.GetObjectOf("Game");
|
||||
//Console.WriteLine(Log.GetMessages());
|
||||
//Log.FlushMessages();
|
||||
|
||||
if (obj == null)
|
||||
//Search for a custom Game Type before we launch our game.
|
||||
//Compile the scripts
|
||||
rScripting.CompileEngine compiler = new rScripting.CompileEngine(".cs");
|
||||
compiler.Compiler = "MudScriptCompiler";
|
||||
if (!compiler.Compile("Scripts"))
|
||||
{
|
||||
game = new Game();
|
||||
obj = new GameObject(game, "Game");
|
||||
scriptEngine = new ScriptEngine((Game)obj.Instance, ScriptEngine.ScriptTypes.Both);
|
||||
Log.Write("Failed compiling script files.");
|
||||
Log.Write(compiler.Errors);
|
||||
}
|
||||
else
|
||||
|
||||
//If there were errors during compilation, then skip the custom scripts and use the default Game Type.
|
||||
if (!compiler.HasErrors)
|
||||
{
|
||||
game = (Game)obj.Instance;
|
||||
scriptEngine = new ScriptEngine(game, ScriptEngine.ScriptTypes.Both);
|
||||
//Search the scripts for a Type inheriting from Game
|
||||
rScripting.LateBinding.ScriptFactory factory = new rScripting.LateBinding.ScriptFactory(compiler.CompiledAssembly);
|
||||
foreach (Type t in compiler.CompiledAssembly.GetTypes())
|
||||
{
|
||||
if (t.BaseType.Name == "Game")
|
||||
{
|
||||
rScripting.LateBinding.ScriptObject obj = factory.GetScript(t.Name);
|
||||
game = (Game)obj.Instance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Force TCP
|
||||
game.ServerType = ProtocolType.Tcp;
|
||||
|
||||
//Setup the scripting engine and load our script library
|
||||
//MUST be called before game.Start()
|
||||
//scriptEngine.Initialize();
|
||||
//game.scriptEngine = scriptEngine; //Pass this script engine off to the game to use now.
|
||||
|
||||
|
||||
Log.Write("");
|
||||
Log.Write("Starting " + obj.GetProperty().GameTitle + "...", true);
|
||||
Log.Write("");
|
||||
//Console.WriteLine(Log.GetMessages());
|
||||
//Log.FlushMessages();
|
||||
*/
|
||||
|
||||
//Server is only enabled if the option is in the settings file
|
||||
//Allows developers to remove the option from the settings file and letting
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue