diff --git a/MudDesigner/frmDesigner.cs b/MudDesigner/frmDesigner.cs index 4a28c31..5e4393d 100644 --- a/MudDesigner/frmDesigner.cs +++ b/MudDesigner/frmDesigner.cs @@ -76,8 +76,9 @@ namespace MudDesigner { 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 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; _OldName = e.OldValue.ToString(); diff --git a/MudDesigner/frmProjectManager.cs b/MudDesigner/frmProjectManager.cs index e0aa2fa..78eb5e3 100644 --- a/MudDesigner/frmProjectManager.cs +++ b/MudDesigner/frmProjectManager.cs @@ -106,7 +106,7 @@ namespace MudDesigner _Game.GameTitle = input.Input; //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(); diff --git a/MudEngine/FileSystem/SaveDataPaths.cs b/MudEngine/FileSystem/SaveDataPaths.cs index 4159267..174fa60 100644 --- a/MudEngine/FileSystem/SaveDataPaths.cs +++ b/MudEngine/FileSystem/SaveDataPaths.cs @@ -30,13 +30,28 @@ namespace MudEngine.FileSystem _Environment = value; } } + + public String Scripts + { + get + { + return _Scripts; + } + set + { + _Scripts = value; + } + } + private String _Players; private String _Environment; + private String _Scripts; - public SaveDataPaths(String environment, String players) + public SaveDataPaths(String environment, String players, String scripts) { _Players = players; _Environment = environment; + _Scripts = scripts; } } } diff --git a/MudEngine/GameManagement/Game.cs b/MudEngine/GameManagement/Game.cs index 2f60d7c..a4e4e90 100644 --- a/MudEngine/GameManagement/Game.cs +++ b/MudEngine/GameManagement/Game.cs @@ -59,6 +59,9 @@ namespace MudEngine.GameManagement [Browsable(false)] public ScriptEngine scriptEngine { get; internal set; } + [Browsable(false)] + public rScripting.CompileEngine Scripting { get; internal set; } + /// /// Gets or Sets the path to the current project /// @@ -198,13 +201,14 @@ namespace MudEngine.GameManagement { //Instance all of the Games Objects. CurrencyList = new List(); - scriptEngine = new Scripting.ScriptEngine(this); + scriptEngine = new Scripting.ScriptEngine(this); //TODO - Remove + Scripting = new rScripting.CompileEngine(".cs"); World = new GameWorld(this); WorldTime = new GameTime(this); InitialRealm = new Realm(this); //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 GameTitle = "New Game"; @@ -242,10 +246,19 @@ namespace MudEngine.GameManagement if (!Directory.Exists(DataPaths.Players)) Directory.CreateDirectory(DataPaths.Players); - //Load both pre-compiled and file based scripts - scriptEngine.ScriptType = ScriptEngine.ScriptTypes.Both; - scriptEngine.Initialize(); + //Load both pre-compiled and file based scripts - TODO - Remove + //scriptEngine.ScriptType = ScriptEngine.ScriptTypes.Both; + //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 * loaded when the script is instanced automatically. If there is no script then these @@ -273,7 +286,7 @@ namespace MudEngine.GameManagement } else //Not multiplayer so we change the save locations { - SaveDataPaths paths = new SaveDataPaths("World", "Player"); + SaveDataPaths paths = new SaveDataPaths("World", "Player", "Scripts"); DataPaths = paths; PlayerCollection[0].Initialize(); } @@ -371,6 +384,8 @@ namespace MudEngine.GameManagement FileManager.WriteLine(filename, this.CompanyName, "CompanyName"); FileManager.WriteLine(filename, this.DataPaths.Environment, "DataPathEnvironment"); FileManager.WriteLine(filename, this.DataPaths.Players, "DataPathPlayers"); + FileManager.WriteLine(filename, this.DataPaths.Scripts, "DataPathScripts"); + FileManager.WriteLine(filename, this.GameTitle, "GameTitle"); FileManager.WriteLine(filename, this.HideRoomNames.ToString(), "HideRoomNames"); @@ -417,7 +432,7 @@ namespace MudEngine.GameManagement this.BaseCurrencyAmount = Convert.ToInt32(FileManager.GetData(filename, "BaseCurrencyAmount")); this.BaseCurrencyName = FileManager.GetData(filename, "BaseCurrencyName"); 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.HideRoomNames = Convert.ToBoolean(FileManager.GetData(filename, "HideRoomNames")); this.InitialRealm = new Realm(this); diff --git a/MudEngine/MudEngine.csproj b/MudEngine/MudEngine.csproj index 03e0e11..e8b6b58 100644 --- a/MudEngine/MudEngine.csproj +++ b/MudEngine/MudEngine.csproj @@ -36,6 +36,9 @@ + + ..\..\rScript\rScripting\bin\Release\rScripting.dll + 3.5 diff --git a/MudGame/Program.cs b/MudGame/Program.cs index fd9f3f8..916796f 100644 --- a/MudGame/Program.cs +++ b/MudGame/Program.cs @@ -15,10 +15,11 @@ namespace MudGame static class Program { const String SettingsFile = "Settings.ini"; - + static dynamic _Game; + 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 //verbose or not @@ -44,8 +45,14 @@ 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(new Game(), ScriptEngine.ScriptTypes.Both); + scriptEngine = new ScriptEngine(game, ScriptEngine.ScriptTypes.Both); //scriptEngine.CompileScripts(); Log.Write("Initializing Script Engine for Script Compilation...", true); @@ -73,11 +80,14 @@ namespace MudGame //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 @@ -91,6 +101,7 @@ namespace MudGame else game.IsMultiplayer = true; + //Start the game. game.Start(); //Make sure the Game is in fact running.