diff --git a/MUDCompiler/MUDCompiler.csproj b/MUDCompiler/MUDCompiler.csproj
index 3312af7..4690b6a 100644
--- a/MUDCompiler/MUDCompiler.csproj
+++ b/MUDCompiler/MUDCompiler.csproj
@@ -66,10 +66,6 @@
{498943A8-DF5A-4DB0-B506-0BFF44788657}
MudEngine
-
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}
- rScripting
-
diff --git a/MUDCompiler/Program.cs b/MUDCompiler/Program.cs
index aa77fc5..f4f8338 100644
--- a/MUDCompiler/Program.cs
+++ b/MUDCompiler/Program.cs
@@ -4,7 +4,6 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
-using MudEngine.Scripting;
namespace MUDCompiler
{
diff --git a/MUDCompiler/frmCompiler.cs b/MUDCompiler/frmCompiler.cs
index ade0e89..8ef7722 100644
--- a/MUDCompiler/frmCompiler.cs
+++ b/MUDCompiler/frmCompiler.cs
@@ -11,16 +11,18 @@ namespace MUDCompiler
{
public partial class frmCompiler : Form
{
- MudEngine.GameManagement.Game game = new MudEngine.GameManagement.Game();
+ //MudEngine.GameManagement.Game game = new MudEngine.GameManagement.Game();
public frmCompiler()
{
InitializeComponent();
+
+ MessageBox.Show("Mud Compiler application needs to be re-wrote to support Alpha 2.0");
}
private void openDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
{
- rScripting.CompileEngine engine = new rScripting.CompileEngine();
+/* rScripting.CompileEngine engine = new rScripting.CompileEngine();
FolderBrowserDialog browse = new FolderBrowserDialog();
browse.ShowDialog();
@@ -37,7 +39,7 @@ namespace MUDCompiler
txtConsole.Text = "Compiled without error.";
else
txtConsole.Text = engine.Errors;
- }
+*/ }
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -46,7 +48,7 @@ namespace MUDCompiler
private void openScriptToolStripMenuItem_Click(object sender, EventArgs e)
{
- rScripting.CompileEngine engine = new rScripting.CompileEngine();
+/* rScripting.CompileEngine engine = new rScripting.CompileEngine();
engine.Compiler = "MudScriptCompiler";
OpenFileDialog browse = new OpenFileDialog();
@@ -65,6 +67,6 @@ namespace MUDCompiler
txtConsole.Text = "Compiled without error.";
else
txtConsole.Text = engine.Errors;
- }
+*/ }
}
}
diff --git a/MudDesigner.sln b/MudDesigner.sln
index a615af1..8000ac3 100644
--- a/MudDesigner.sln
+++ b/MudDesigner.sln
@@ -11,11 +11,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudClient", "MudClient\MudC
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudDesigner", "MudDesigner\MudDesigner.csproj", "{5B18E552-26D0-4491-8BAC-FF80046F0B0F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rScripting", "rScripting\rScripting.csproj", "{BC1B32DA-7209-4B32-8171-A190EF21F5D6}"
-EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
- SccNumberOfProjects = 7
+ SccNumberOfProjects = 6
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs03
SccLocalPath0 = .
@@ -34,9 +32,6 @@ Global
SccProjectUniqueName5 = MudDesigner\\MudDesigner.csproj
SccProjectName5 = MudDesigner
SccLocalPath5 = MudDesigner
- SccProjectUniqueName6 = rScripting\\rScripting.csproj
- SccProjectName6 = rScripting
- SccLocalPath6 = rScripting
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -97,16 +92,6 @@ Global
{5B18E552-26D0-4491-8BAC-FF80046F0B0F}.Release|Mixed Platforms.Build.0 = Release|x86
{5B18E552-26D0-4491-8BAC-FF80046F0B0F}.Release|x86.ActiveCfg = Release|x86
{5B18E552-26D0-4491-8BAC-FF80046F0B0F}.Release|x86.Build.0 = Release|x86
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|x86.ActiveCfg = Debug|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Any CPU.Build.0 = Release|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/MudDesigner/MudDesigner.csproj b/MudDesigner/MudDesigner.csproj
index 9ced6a3..960c9c3 100644
--- a/MudDesigner/MudDesigner.csproj
+++ b/MudDesigner/MudDesigner.csproj
@@ -51,18 +51,6 @@
-
- Form
-
-
- frmDesigner.cs
-
-
- Form
-
-
- frmInputBox.cs
-
Form
@@ -71,12 +59,6 @@
-
- frmDesigner.cs
-
-
- frmInputBox.cs
-
frmProjectManager.cs
diff --git a/MudDesigner/frmDesigner.Designer.cs b/MudDesigner/frmDesigner.Designer.cs
deleted file mode 100644
index 8f6144b..0000000
--- a/MudDesigner/frmDesigner.Designer.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-namespace MudDesigner
-{
- partial class frmDesigner
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.statusStrip1 = new System.Windows.Forms.StatusStrip();
- this.menuStrip1 = new System.Windows.Forms.MenuStrip();
- this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.saveProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
- this.closeProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
- this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.createObjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.environmentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.realmToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.zoneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.roomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.splitContainer1 = new System.Windows.Forms.SplitContainer();
- this.txtCommand = new System.Windows.Forms.TextBox();
- this.txtConsole = new System.Windows.Forms.RichTextBox();
- this.splitContainer2 = new System.Windows.Forms.SplitContainer();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
- this.menuStrip1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
- this.splitContainer1.Panel1.SuspendLayout();
- this.splitContainer1.Panel2.SuspendLayout();
- this.splitContainer1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
- this.splitContainer2.Panel1.SuspendLayout();
- this.splitContainer2.Panel2.SuspendLayout();
- this.splitContainer2.SuspendLayout();
- this.SuspendLayout();
- //
- // statusStrip1
- //
- this.statusStrip1.Location = new System.Drawing.Point(0, 695);
- this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(993, 22);
- this.statusStrip1.TabIndex = 1;
- this.statusStrip1.Text = "statusStrip1";
- //
- // menuStrip1
- //
- this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.fileToolStripMenuItem,
- this.editToolStripMenuItem,
- this.createObjectToolStripMenuItem});
- this.menuStrip1.Location = new System.Drawing.Point(0, 0);
- this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(993, 24);
- this.menuStrip1.TabIndex = 2;
- this.menuStrip1.Text = "menuStrip1";
- //
- // fileToolStripMenuItem
- //
- this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.saveProjectToolStripMenuItem,
- this.toolStripMenuItem1,
- this.closeProjectToolStripMenuItem});
- this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
- this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
- this.fileToolStripMenuItem.Text = "File";
- //
- // saveProjectToolStripMenuItem
- //
- this.saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem";
- this.saveProjectToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
- this.saveProjectToolStripMenuItem.Text = "Save Project";
- //
- // toolStripMenuItem1
- //
- this.toolStripMenuItem1.Name = "toolStripMenuItem1";
- this.toolStripMenuItem1.Size = new System.Drawing.Size(140, 6);
- //
- // closeProjectToolStripMenuItem
- //
- this.closeProjectToolStripMenuItem.Name = "closeProjectToolStripMenuItem";
- this.closeProjectToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
- this.closeProjectToolStripMenuItem.Text = "Close Project";
- //
- // editToolStripMenuItem
- //
- this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.cutToolStripMenuItem,
- this.copyToolStripMenuItem,
- this.pasteToolStripMenuItem,
- this.toolStripMenuItem2,
- this.preferencesToolStripMenuItem});
- this.editToolStripMenuItem.Name = "editToolStripMenuItem";
- this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
- this.editToolStripMenuItem.Text = "Edit";
- //
- // cutToolStripMenuItem
- //
- this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
- this.cutToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
- this.cutToolStripMenuItem.Text = "Cut";
- //
- // copyToolStripMenuItem
- //
- this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
- this.copyToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
- this.copyToolStripMenuItem.Text = "Copy";
- //
- // pasteToolStripMenuItem
- //
- this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
- this.pasteToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
- this.pasteToolStripMenuItem.Text = "Paste";
- //
- // toolStripMenuItem2
- //
- this.toolStripMenuItem2.Name = "toolStripMenuItem2";
- this.toolStripMenuItem2.Size = new System.Drawing.Size(132, 6);
- //
- // preferencesToolStripMenuItem
- //
- this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem";
- this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
- this.preferencesToolStripMenuItem.Text = "Preferences";
- //
- // createObjectToolStripMenuItem
- //
- this.createObjectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.environmentToolStripMenuItem});
- this.createObjectToolStripMenuItem.Name = "createObjectToolStripMenuItem";
- this.createObjectToolStripMenuItem.Size = new System.Drawing.Size(91, 20);
- this.createObjectToolStripMenuItem.Text = "Create Object";
- //
- // environmentToolStripMenuItem
- //
- this.environmentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.realmToolStripMenuItem,
- this.zoneToolStripMenuItem,
- this.roomToolStripMenuItem});
- this.environmentToolStripMenuItem.Name = "environmentToolStripMenuItem";
- this.environmentToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
- this.environmentToolStripMenuItem.Text = "Environment";
- //
- // realmToolStripMenuItem
- //
- this.realmToolStripMenuItem.Name = "realmToolStripMenuItem";
- this.realmToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
- this.realmToolStripMenuItem.Text = "Realm";
- //
- // zoneToolStripMenuItem
- //
- this.zoneToolStripMenuItem.Name = "zoneToolStripMenuItem";
- this.zoneToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
- this.zoneToolStripMenuItem.Text = "Zone";
- //
- // roomToolStripMenuItem
- //
- this.roomToolStripMenuItem.Name = "roomToolStripMenuItem";
- this.roomToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
- this.roomToolStripMenuItem.Text = "Room";
- //
- // splitContainer1
- //
- this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.splitContainer1.Location = new System.Drawing.Point(0, 24);
- this.splitContainer1.Name = "splitContainer1";
- //
- // splitContainer1.Panel1
- //
- this.splitContainer1.Panel1.Controls.Add(this.txtCommand);
- this.splitContainer1.Panel1.Controls.Add(this.txtConsole);
- //
- // splitContainer1.Panel2
- //
- this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
- this.splitContainer1.Size = new System.Drawing.Size(993, 671);
- this.splitContainer1.SplitterDistance = 714;
- this.splitContainer1.TabIndex = 3;
- //
- // txtCommand
- //
- this.txtCommand.Location = new System.Drawing.Point(0, 324);
- this.txtCommand.Name = "txtCommand";
- this.txtCommand.Size = new System.Drawing.Size(698, 20);
- this.txtCommand.TabIndex = 1;
- this.txtCommand.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtCommand_KeyDown);
- //
- // txtConsole
- //
- this.txtConsole.Location = new System.Drawing.Point(0, 0);
- this.txtConsole.Name = "txtConsole";
- this.txtConsole.Size = new System.Drawing.Size(698, 318);
- this.txtConsole.TabIndex = 0;
- this.txtConsole.Text = "";
- //
- // splitContainer2
- //
- this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
- this.splitContainer2.Location = new System.Drawing.Point(0, 0);
- this.splitContainer2.Name = "splitContainer2";
- this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
- //
- // splitContainer2.Panel1
- //
- this.splitContainer2.Panel1.Controls.Add(this.groupBox1);
- //
- // splitContainer2.Panel2
- //
- this.splitContainer2.Panel2.Controls.Add(this.propertyGrid1);
- this.splitContainer2.Size = new System.Drawing.Size(273, 669);
- this.splitContainer2.SplitterDistance = 213;
- this.splitContainer2.TabIndex = 0;
- //
- // groupBox1
- //
- this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.groupBox1.Location = new System.Drawing.Point(0, 0);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(273, 213);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Project Settings";
- //
- // propertyGrid1
- //
- this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
- this.propertyGrid1.Name = "propertyGrid1";
- this.propertyGrid1.Size = new System.Drawing.Size(273, 452);
- this.propertyGrid1.TabIndex = 4;
- //
- // frmDesigner
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.ClientSize = new System.Drawing.Size(993, 717);
- this.Controls.Add(this.splitContainer1);
- this.Controls.Add(this.statusStrip1);
- this.Controls.Add(this.menuStrip1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MainMenuStrip = this.menuStrip1;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "frmDesigner";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "Mud Designer";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmDesigner_FormClosing);
- this.menuStrip1.ResumeLayout(false);
- this.menuStrip1.PerformLayout();
- this.splitContainer1.Panel1.ResumeLayout(false);
- this.splitContainer1.Panel1.PerformLayout();
- this.splitContainer1.Panel2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
- this.splitContainer1.ResumeLayout(false);
- this.splitContainer2.Panel1.ResumeLayout(false);
- this.splitContainer2.Panel2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
- this.splitContainer2.ResumeLayout(false);
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.StatusStrip statusStrip1;
- private System.Windows.Forms.MenuStrip menuStrip1;
- private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem saveProjectToolStripMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
- private System.Windows.Forms.ToolStripMenuItem closeProjectToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
- private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem createObjectToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem environmentToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem realmToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem zoneToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem roomToolStripMenuItem;
- private System.Windows.Forms.SplitContainer splitContainer1;
- private System.Windows.Forms.SplitContainer splitContainer2;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.PropertyGrid propertyGrid1;
- private System.Windows.Forms.TextBox txtCommand;
- private System.Windows.Forms.RichTextBox txtConsole;
-
- }
-}
\ No newline at end of file
diff --git a/MudDesigner/frmDesigner.cs b/MudDesigner/frmDesigner.cs
deleted file mode 100644
index 5e4393d..0000000
--- a/MudDesigner/frmDesigner.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Windows.Forms;
-using System.IO;
-using System.Threading;
-
-using MudEngine.GameManagement;
-using MudEngine.FileSystem;
-
-namespace MudDesigner
-{
- public partial class frmDesigner : Form
- {
- private Game _Game;
- private Client _Client;
- private Thread _ClientThread;
-
- private Boolean _IsRenaming;
- private String _OldName;
-
- private Boolean _TimeOut;
- private Object _SelectedObject;
-
- public frmDesigner(Game game, Client client)
- {
- InitializeComponent();
-
- _Game = game;
- _Client = client;
-
- MudEngine.GameObjects.Environment.Room r = new MudEngine.GameObjects.Environment.Room(_Game);
- this.propertyGrid1.SelectedObject = _Game;
-
- _TimeOut = false;
- _Client.Send("Hello world", false);
- }
-
- ///
- /// Saves the project.
- ///
- public void Save()
- {
- if ((String.IsNullOrEmpty(_Game.GameTitle)) || (_Game.GameTitle == new Game().GameTitle))
- return;
-
- if ((_IsRenaming) && (Directory.Exists(Path.Combine("Projects", _OldName))))
- {
- Directory.Delete(Path.Combine("Projects", _OldName), true);
- File.Delete(Path.Combine(Environment.CurrentDirectory, _OldName + ".ini"));
- }
- _Game.Save();
- }
-
- private void frmDesigner_FormClosing(object sender, FormClosingEventArgs e)
- {
- DialogResult result = MessageBox.Show("Save Changes?", this.Text, MessageBoxButtons.YesNoCancel);
-
- if (result == System.Windows.Forms.DialogResult.Cancel)
- {
- e.Cancel = true;
- return;
- }
- else if (result == System.Windows.Forms.DialogResult.Yes)
- this.Save();
-
- }
-
- private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
- {
- if (e.ChangedItem.Label == "GameTitle")
- {
- 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,scrpt);
-
- _IsRenaming = true;
- _OldName = e.OldValue.ToString();
- }
- }
-
- private void ChangeObject(Object obj)
- {
- _SelectedObject = obj;
- propertyGrid1.SelectedObject = obj;
- }
-
- private void btnNewRealm_Click(object sender, EventArgs e)
- {
- ChangeObject(new MudEngine.GameObjects.Environment.Realm(_Game));
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- ChangeObject(new MudEngine.GameObjects.Environment.Zone(_Game));
- }
-
- private void txtCommand_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- _Client.Send(txtCommand.Text, true);
-
- System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
- t.Interval = 10000;
- t.Tick += new EventHandler(timerTick);
-
- _TimeOut = false;
- String result;
-
- while (!_TimeOut)
- {
- if (_Client.Receive(out result, 1))
- {
- txtConsole.Text += result;
- }
- else
- _TimeOut = true;
- }
-
- txtConsole.Text += "\n";
- }
- }
-
- void timerTick(object sender, EventArgs e)
- {
- _TimeOut = true;
- }
-
- void UpdateConsole(String message)
- {
- txtConsole.Text += message;
- }
- }
-}
diff --git a/MudDesigner/frmDesigner.resx b/MudDesigner/frmDesigner.resx
deleted file mode 100644
index a50688d..0000000
--- a/MudDesigner/frmDesigner.resx
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
- 133, 17
-
-
\ No newline at end of file
diff --git a/MudDesigner/frmInputBox.Designer.cs b/MudDesigner/frmInputBox.Designer.cs
deleted file mode 100644
index 7294a84..0000000
--- a/MudDesigner/frmInputBox.Designer.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-namespace MudDesigner
-{
- partial class frmInputBox
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.lblDescription = new System.Windows.Forms.Label();
- this.txtInput = new System.Windows.Forms.TextBox();
- this.btnCancel = new System.Windows.Forms.Button();
- this.btnOK = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // lblDescription
- //
- this.lblDescription.Location = new System.Drawing.Point(0, 0);
- this.lblDescription.Name = "lblDescription";
- this.lblDescription.Size = new System.Drawing.Size(353, 87);
- this.lblDescription.TabIndex = 0;
- this.lblDescription.Text = "Place input directions here via frmInputBox.Description";
- //
- // txtInput
- //
- this.txtInput.Location = new System.Drawing.Point(3, 90);
- this.txtInput.Name = "txtInput";
- this.txtInput.Size = new System.Drawing.Size(350, 20);
- this.txtInput.TabIndex = 1;
- this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown);
- //
- // btnCancel
- //
- this.btnCancel.Location = new System.Drawing.Point(278, 116);
- this.btnCancel.Name = "btnCancel";
- this.btnCancel.Size = new System.Drawing.Size(75, 24);
- this.btnCancel.TabIndex = 2;
- this.btnCancel.Text = "Cancel";
- this.btnCancel.UseVisualStyleBackColor = true;
- this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
- //
- // btnOK
- //
- this.btnOK.Location = new System.Drawing.Point(197, 116);
- this.btnOK.Name = "btnOK";
- this.btnOK.Size = new System.Drawing.Size(75, 24);
- this.btnOK.TabIndex = 3;
- this.btnOK.Text = "OK";
- this.btnOK.UseVisualStyleBackColor = true;
- this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
- //
- // frmInputBox
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(356, 145);
- this.Controls.Add(this.btnOK);
- this.Controls.Add(this.btnCancel);
- this.Controls.Add(this.txtInput);
- this.Controls.Add(this.lblDescription);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "frmInputBox";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Label lblDescription;
- private System.Windows.Forms.TextBox txtInput;
- private System.Windows.Forms.Button btnCancel;
- private System.Windows.Forms.Button btnOK;
- }
-}
\ No newline at end of file
diff --git a/MudDesigner/frmInputBox.cs b/MudDesigner/frmInputBox.cs
deleted file mode 100644
index 8a68b61..0000000
--- a/MudDesigner/frmInputBox.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Windows.Forms;
-
-namespace MudDesigner
-{
- public partial class frmInputBox : Form
- {
- public bool IsCancel { get; set; }
-
- public String Description { get { return this.lblDescription.Text; } set { this.lblDescription.Text = value; } }
-
- public String Input { get { return this.txtInput.Text; } private set { this.txtInput.Text = value; } }
-
- public frmInputBox(String desc)
- {
- InitializeComponent();
-
- this.Description = desc;
- }
-
- private void btnOK_Click(object sender, EventArgs e)
- {
- this.Hide();
- }
-
- private void btnCancel_Click(object sender, EventArgs e)
- {
- IsCancel = true;
- Input = String.Empty;
- }
-
- private void txtInput_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- btnOK_Click(sender, null);
- else if (e.KeyCode == Keys.Escape)
- btnCancel_Click(sender, null);
- }
- }
-}
diff --git a/MudDesigner/frmInputBox.resx b/MudDesigner/frmInputBox.resx
deleted file mode 100644
index 29dcb1b..0000000
--- a/MudDesigner/frmInputBox.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/MudDesigner/frmProjectManager.cs b/MudDesigner/frmProjectManager.cs
index 9392ca1..b25f8bb 100644
--- a/MudDesigner/frmProjectManager.cs
+++ b/MudDesigner/frmProjectManager.cs
@@ -9,10 +9,6 @@ using System.Windows.Forms;
using System.IO;
using System.Threading;
-using MudEngine.FileSystem;
-using MudEngine.GameManagement;
-using MudEngine.Scripting;
-
namespace MudDesigner
{
public partial class frmProjectManager : Form
@@ -20,8 +16,6 @@ namespace MudDesigner
public frmProjectManager()
{
InitializeComponent();
-
-
}
private void RefreshProjects()
diff --git a/MudEngine/ClassesPendingMigration/BaseStats.cs b/MudEngine/ClassesPendingMigration/BaseStats.cs
deleted file mode 100644
index e1e7582..0000000
--- a/MudEngine/ClassesPendingMigration/BaseStats.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace MudEngine.GameObjects.Characters
-{
- ///
- /// This class is the base class that handles the managing of a Characters stats.
- /// It was decided to place stats within their own class, to allow for developers to easily add additional
- /// stats or adjust how stats are used within their MUD's without having to modify the Character code themselves.
- ///
- public class BaseStats
- {
- ///
- /// Strength is a measure of muscle, endurance and stamina combined.
- /// Strength affects the ability of characters to lift and carry weights, melee attack rolls,
- /// damage rolls (for both melee and ranged weapons,) the Jump, Climb, and Swim skills,
- /// several combat actions, and general checks involving moving or breaking stubborn objects.
- ///
- public Int32 Strength { get; set; }
-
- ///
- /// Dexterity encompasses a number of physical attributes including hand-eye coordination, agility,
- /// reflexes, fine motor skills, balance and speed of movement; a high dexterity score indicates
- /// superiority in all these attributes. Dexterity affects characters with regard to initiative in combat,
- /// ranged attack rolls, Armor Class, Reflex saves, and the Balance, Escape Artist, Hide, Move Silently,
- /// Open Lock, Ride, Sleight of Hand, Tumble, and Use Rope skills. It also affects the number of additional
- /// attacks of opportunity granted by the Combat Reflexes feat. Dexterity is the ability most influenced by
- /// outside influences (such as armor).
- ///
- public Int32 Dexterity { get; set; }
-
- ///
- /// Constitution is a term which encompasses the character's physique, toughness, health and resistance to disease and poison.
- /// The higher a character's Constitution, the more hit points that character will have.
- /// Constitution also is important for Fortitude saves, the Concentration skill, and fatigue-based general checks.
- /// Constitution also determines the duration of a barbarian's rage.
- /// Unlike the other ability scores, which render the character unconscious or immobile when they hit 0,
- /// having 0 Constitution is fatal.
- ///
- public Int32 Constitution { get; set; }
-
- ///
- /// Intelligence is similar to IQ, but also includes mnemonic ability, reasoning and learning ability outside
- /// those measured by the written word. Intelligence dictates the number of languages a character can learn,
- /// and it influences the number of spells a preparation-based arcane spellcaster (like a Wizard) may cast per
- /// day, and the effectiveness of said spells. It also affects how many skill points a character gains per level,
- /// the Appraise, Craft, Decipher Script, Disable Device, Forgery, Knowledge, Search, and Spellcraft skills,
- /// and bardic knowledge checks.
- ///
- public Int32 Intelligence { get; set; }
-
- ///
- /// Wisdom is a composite term for the characters enlightenment, judgement, wile, willpower and intuitiveness.
- /// Wisdom influences the number of spells a divine spellcaster (like clerics, druids, paladins, and rangers)
- /// can cast per day, and the effectiveness of said spells. It also affects Will saving throws, the Heal, Listen,
- /// Profession, Sense Motive, Spot, and Survival skills, the effectiveness of the Stunning Fist feat, and a
- /// monk's quivering palm attack.
- ///
- public Int32 Wisdom { get; set; }
-
- ///
- /// Charisma is the measure of the character's combined physical attractiveness, persuasiveness, and personal magnetism.
- /// A generally non-beautiful character can have a very high charisma due to strong measures of the other two aspects of charisma.
- /// Charisma influences how many spells spontaneous arcane spellcasters (like sorcerers and bards) can cast per day, and the
- /// effectiveness of said spells. It also affects Bluff, Diplomacy, Disguise, Gather Information, Handle Animal,
- /// Intimidate, Perform, and Use Magic Device checks, how often and how effectively clerics and paladins can turn
- /// undead, the wild empathy of druids and rangers, and a paladin's lay on hands ability.
- ///
- public Int32 Charisma { get; set; }
-
- ///
- /// Experience is given to the player based off activities that they perform.
- ///
- public Int32 Experience { get; set; }
-
-
- }
-}
diff --git a/MudEngine/ClassesPendingMigration/Game.cs b/MudEngine/ClassesPendingMigration/Game.cs
deleted file mode 100644
index 0a23b6b..0000000
--- a/MudEngine/ClassesPendingMigration/Game.cs
+++ /dev/null
@@ -1,489 +0,0 @@
-//Microsoft .NET Framework
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using System.Xml.Serialization;
-using System.Xml;
-using System.IO;
-using System.Net;
-using System.Net.Sockets;
-using System.Reflection;
-
-//MUD Engine
-using MudEngine.FileSystem;
-using MudEngine.GameObjects;
-using MudEngine.GameObjects.Characters;
-using MudEngine.GameObjects.Environment;
-using MudEngine.Scripting;
-using MudEngine.Networking;
-using MudEngine.Core;
-
-namespace MudEngine.GameManagement
-{
- ///
- /// Manages all of the projects settings.
- ///
- [XmlInclude(typeof(StartingLocation))]
- [XmlInclude(typeof(Currency))]
- public class Game : BaseGame
- {
- #region ==== Properties & Types ====
-
- #region Game Object Setup
- ///
- /// Gets or Sets if this game is running in debug mode. Additional information is sent to the log if enabled.
- ///
- public static Boolean IsDebug { get; set; }
-
- ///
- /// Gets or Sets if the game will run with a server or not.
- ///
- public Boolean IsMultiplayer { get; set; }
-
- ///
- /// Gets or Sets if this game is currently running.
- ///
- [Browsable(false)]
- public Boolean IsRunning { get; internal set; }
-
- ///
- /// Gets or Sets the paths to various project related objects.
- ///
- [Browsable(false)]
- public SaveDataPaths DataPaths { get; set; }
-
- [Browsable(false)]
- public rScripting.CompileEngine Scripting { get; internal set; }
-
- ///
- /// Gets or Sets the path to the current project
- ///
- [Browsable(false)]
- public String ProjectPath { get; set; }
-
- ///
- /// Gets or Sets if all objects will be laoded during server startup. Enabling this results in a slower server start time, but faster object access.
- ///
- [Category("Project Settings")]
- [Description("If enabled, all objects will be loaded during server startup resulting in a slower server start time, but faster load time during gameplay")]
- [Browsable(false)]
- public Boolean PreCacheObjects { get; set; }
-
- ///
- /// Gets a copy of all identifiers being used in the game.
- ///
- internal List WorldObjects { get; private set; }
- #endregion
-
- #region Game Information
- [Category("Company Settings")]
- [Description("The name of the Company or Author building the game.")]
- ///
- /// Gets or Sets the name of the company
- ///
- public String CompanyName { get; set; }
-
- [Category("Company Settings")]
- [Description("The website URL that a player can visit to view additional information related to the game")]
- ///
- /// Gets or Sets the companies website for this project
- ///
- public String Website { get; set; }
-
- [Category("Project Settings")]
- [Description("The name of the game displayed to the users, and title bar of the runtime.")]
- public String GameTitle { get; set; }
-
- ///
- /// Gets or Sets the current working version of the game.
- ///
- [Category("Project Settings")]
- [Description("The current working version of the game.")]
- public String Version { get; set; }
-
- [Browsable(false)]
- public List CurrencyList { get; set; }
-
- [Category("Environment Settings")]
- [ReadOnly(true)]
- public Realm InitialRealm
- {
- get;
- internal set;
- }
-
- ///
- /// The Story that is displayed on initial player entry into the game
- ///
- public String Story { get; set; }
-
- [Category("Project Settings")]
- [Description("Enable or Disable Auto-saving of players when the player travels")]
- ///
- /// Gets or Sets if the Game world is automatically saved at a specified interval.
- /// Players will be saved every-time they change location.
- ///
- public Boolean AutoSave { get; set; }
-
- ///
- /// Gets or Sets the interval in which the Game will automatically save every game object.
- ///
- public Int32 AutoSaveInterval { get; set; }
-
- ///
- /// Gets or Sets the minimum number of characters required to create a 'legal' password.
- /// Default value is 6 characters required for a password during character creation.
- ///
- public Int32 MinimumPasswordSize { get; set; }
-
- [Category("Project Settings")]
- [Description("Hide Room names from being outputted to the console.")]
- ///
- /// Gets or Sets if room names are hidden during console output.
- ///
- public Boolean HideRoomNames { get; set; }
-
- [Category("Game Currency")]
- [DefaultValue(1)]
- [Description("Sets the amount that the base currency is valued at.")]
- public Int32 BaseCurrencyAmount { get; set; }
-
-
- [Category("Game Currency")]
- [DefaultValue("Copper")]
- public String BaseCurrencyName { get; set; }
-
- [Browsable(false)]
- public GameTime WorldTime { get; set; }
-
- [Browsable(false)]
- public GameWorld World { get; set; }
- #endregion
-
- #region Networking
- ///
- /// Collection of players currently running on the server.
- ///
- protected BaseCharacter[] PlayerCollection;
-
- ///
- /// Gets the current running Server object.
- ///
- [Browsable(false)]
- public Server Server { get; internal set; }
-
- ///
- /// Gets or Sets the protocol used by the server.
- ///
- public ProtocolType ServerType { get; set; }
-
- ///
- /// Gets or Sets the port that the server will run on
- ///
- public Int32 ServerPort { get; set; }
-
- ///
- /// Gets or Sets the maximum number of Players permitted to run on this Games server.
- ///
- public Int32 MaximumPlayers { get; set; }
- #endregion
- #endregion
-
- #region ==== Constructors ====
- public Game()
- {
- //Instance all of the Games Objects.
- CurrencyList = new List();
- 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", "Scripts");
-
- //Setup default settings for the Game
- GameTitle = "New Game";
- BaseCurrencyAmount = 1;
- BaseCurrencyName = "Copper";
- Version = "1.0";
- Story = "";
-
- //Setup default Networking settings
- IsMultiplayer = true;
- ServerType = ProtocolType.Tcp;
- ServerPort = 555;
- MaximumPlayers = 1000;
-
- //Setup the player arrays
- //used to be in Start
- PlayerCollection = new BaseCharacter[MaximumPlayers];
- for (Int32 i = 0; i < MaximumPlayers; i++)
- PlayerCollection[i] = new BaseCharacter(this);
-
- AutoSave = true;
- AutoSaveInterval = 60;
-
- MinimumPasswordSize = 6;
- }
- #endregion
-
- #region ==== Methods ====
- ///
- /// Starts the game and runs the server if IsMultiplayer is true
- ///
- public virtual Boolean Start()
- {
- Log.Write("Game Initializing...");
- if (!Directory.Exists(DataPaths.Players))
- Directory.CreateDirectory(DataPaths.Players);
-
- Scripting.Compiler = "MudScriptCompiler";
-
- //Check for compiler errors after script compiling completes.
- 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
- * don't get loaded and will need to be forced.
- * This prevents a duplicate "Loading Commands" message in the server console if the
- * player script exists and pre-loads the commands during script instancing in ScriptEngine.Initialize()
- */
- Log.Write("Initializing Command Engine...");
- if ((CommandEngine.CommandCollection == null) || (CommandEngine.CommandCollection.Count == 0))
- CommandEngine.LoadBaseCommands();
-
- if (IsDebug)
- {
- foreach (String command in CommandEngine.CommandCollection.Keys)
- Log.Write("Command Loaded: " + command);
- }
-
- World.Start();
-
- //Start the Telnet server
- if (IsMultiplayer)
- {
- Log.Write("Starting Server...");
- this.StartServer();
- }
- else //Not multiplayer so we change the save locations
- {
- SaveDataPaths paths = new SaveDataPaths("World", "Player", "Scripts");
- DataPaths = paths;
- PlayerCollection[0].Initialize();
- }
-
- WorldTime.Initialize();
-
- //Game is running now.
- IsRunning = true;
-
- //Load the game and world if it was previously saved.
- Load();
-
- String[] env = InitialRealm.InitialZone.InitialRoom.RoomLocation.Split('>');
- if (env.Length == 3)
- {
- if ((String.IsNullOrEmpty(env[0])) || (String.IsNullOrEmpty(env[1])) || (String.IsNullOrEmpty(env[2])))
- {
- Log.Write("Error: No starting location defined!");
- }
- }
- else
- Log.Write("Error: No starting location defined!");
-
- Log.Write("Game startup complete.");
- return true;
- }
-
- ///
- /// Shuts down the Game and Server.
- ///
- public virtual void Shutdown()
- {
- Log.Write("Server shutdown requested...");
-
- if (IsMultiplayer)
- Server.EndServer();
-
- Save();
-
- IsRunning = false;
-
- Log.Write("Shutdown completed...");
- }
-
- public virtual void Update()
- {
- WorldTime.Update();
-
- World.Update();
-
- if (IsMultiplayer)
- {
- Console.Write(Log.GetMessages());
- Log.FlushMessages();
- System.Threading.Thread.Sleep(1);
- }
- else
- {
- PlayerCollection[0].ExecuteCommand(Console.ReadLine());
- }
- }
-
- public virtual void Save()
- {
- Log.Write("Saving Game world....");
-
- Log.Write("Saving Game Players...");
- for (Int32 i = 0; i <= PlayerCollection.Length - 1; i++)
- {
- if (PlayerCollection[i].Name == "New BaseCharacter")
- continue;
- PlayerCollection[i].Save();
- }
-
- //Delete the last saved version of the World. We will dump the current version onto disk.
- if (Directory.Exists(DataPaths.Environment))
- Directory.Delete(DataPaths.Environment, true);
-
- //Re-create the environment directory
- Directory.CreateDirectory(DataPaths.Environment);
-
- //Save the Game World.
- World.Save();
-
- //Save the Game
- String filename = GameTitle + ".ini";
-
- if (File.Exists(filename))
- File.Delete(filename);
-
- FileManager.WriteLine(filename, this.AutoSave.ToString(), "AutoSave");
- FileManager.WriteLine(filename, this.AutoSaveInterval.ToString(), "AutoSaveInterval");
- FileManager.WriteLine(filename, this.BaseCurrencyAmount.ToString(), "BaseCurrencyAmount");
- FileManager.WriteLine(filename, this.BaseCurrencyName, "BaseCurrencyName");
- 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");
-
- if ((this.InitialRealm != null) && (this.InitialRealm.Name != "New Realm"))
- FileManager.WriteLine(filename, this.InitialRealm.Filename, "InitialRealm");
-
- FileManager.WriteLine(filename, this.IsMultiplayer.ToString(), "IsMultiplayer");
- FileManager.WriteLine(filename, this.MaximumPlayers.ToString(), "MaximumPlayers");
- FileManager.WriteLine(filename, this.PreCacheObjects.ToString(), "PreCacheObjects");
- FileManager.WriteLine(filename, this.ServerPort.ToString(), "ServerPort");
- FileManager.WriteLine(filename, this.ServerType.ToString(), "ServerType");
- FileManager.WriteLine(filename, this.Version, "Version");
- FileManager.WriteLine(filename, this.Website, "Website");
-
- foreach (Realm r in World.RealmCollection)
- {
- FileManager.WriteLine(filename, r.Filename, "RealmCollection");
- }
-
- //TODO: Save WorldTime
- //TODO: Save Story
- //TODO: Save Server Information
- //TODO: Save Currency Lists
- //TODO: Save Script Engine information
- }
-
- public virtual void Load()
- {
- String filename = GameTitle + ".ini";
-
- this.Load(filename);
- }
-
- public virtual void Load(String filename)
- {
- if (!File.Exists(filename))
- return;
-
- Log.Write("Restoring Game Settings...");
- try
- {
- this.AutoSave = Convert.ToBoolean(FileManager.GetData(filename, "AutoSave"));
- this.AutoSaveInterval = Convert.ToInt32(FileManager.GetData(filename, "AutoSaveInterval"));
- 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"), FileManager.GetData(filename, "DataPathScripts"));
- this.GameTitle = FileManager.GetData(filename, "GameTitle");
- this.HideRoomNames = Convert.ToBoolean(FileManager.GetData(filename, "HideRoomNames"));
- this.InitialRealm = new Realm(this);
- this.IsMultiplayer = Convert.ToBoolean(FileManager.GetData(filename, "IsMultiplayer"));
- this.MaximumPlayers = Convert.ToInt32(FileManager.GetData(filename, "MaximumPlayers"));
- this.PreCacheObjects = Convert.ToBoolean(FileManager.GetData(filename, "PreCacheObjects"));
- this.ServerPort = Convert.ToInt32(FileManager.GetData(filename, "ServerPort"));
- this.Version = FileManager.GetData(filename, "Version");
- this.Website = FileManager.GetData(filename, "Webite");
-
- //Need to re-assign the enumerator value that was previously assigned to the ServerType property
- Array values = Enum.GetValues(typeof(ProtocolType));
- foreach (Int32 value in values)
- {
- //Since enum values are not strings, we can't simply just assign the String to the enum
- String displayName = Enum.GetName(typeof(ProtocolType), value);
-
- //If the value = the String saved, then perform the needed conversion to get our data back
- if (displayName.ToLower() == FileManager.GetData(filename, "ServerType").ToLower())
- {
- ServerType = (ProtocolType)Enum.Parse(typeof(ProtocolType), displayName);
- break;
- }
- }
- }
- catch
- {
- Log.Write("Critical Error: Unable to complete Game.Load() due to error during loading of file data.");
- return;
- }
-
- //Restore the world.
- World.Load();
-
- //Check if any the initial room exists or not.
- if ((this.InitialRealm == null) || (this.InitialRealm.InitialZone == null) || (this.InitialRealm.InitialZone.InitialRoom == null))
- {
- Log.Write("ERROR: No initial location defined. Game startup failed!");
- Log.Write("Players will start in the Abyss. Each player will contain their own instance of this room.");
- //return false;
- }
- else
- Log.Write("Initial Location loaded: " + this.InitialRealm.InitialZone.InitialRoom.RoomLocationWithoutExtension);
-
- Log.Write("Game Restore complete.");
- }
-
- public BaseCharacter[] GetPlayerCollection()
- {
- return PlayerCollection;
- }
-
- ///
- /// Starts the Server.
- ///
- private void StartServer()
- {
- Server = new Networking.Server();
- Server.Initialize(ServerPort, ref PlayerCollection);
- Server.Start();
- }
- #endregion
- }
-}
diff --git a/MudEngine/ClassesPendingMigration/GameTime.cs b/MudEngine/ClassesPendingMigration/GameTime.cs
deleted file mode 100644
index 7c7362a..0000000
--- a/MudEngine/ClassesPendingMigration/GameTime.cs
+++ /dev/null
@@ -1,380 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace MudEngine.GameManagement
-{
- public class GameTime
- {
- public struct Time
- {
- public Int32 Year { get; set; }
- public Int32 Month { get; set; }
- public Int32 Day { get; set; }
- public Int32 Hour { get; set; }
- public Int32 Minute { get; set; }
- public Int32 Second { get; set; }
- private GameTime gameTime;
- }
-
- public enum TimeOfDayOptions
- {
- AlwaysDay,
- AlwaysNight,
- Transition,
- }
-
- internal Game ActiveGame { get; private set; }
-
- ///
- /// The time of day that the server actually started up.
- ///
- internal DateTime ServerStartTime { get; private set; }
-
- ///
- /// Gets the current World Time.
- ///
- public Time CurrentWorldTime { get; internal set; }
-
- ///
- /// Gets or Sets the current Time of the System
- ///
- private DateTime CurrentSystemTime { get; set; }
-
- ///
- /// Gets or Sets how many Hours it takes to make a full day in the World
- ///
- public Int32 HoursPerDay { get; set; }
-
- ///
- /// Gets or Sets how many minutes it takes to make a full Hour
- ///
- public Int32 MinutesPerHour { get; set; }
-
- ///
- /// Gets or Sets how many seconds it takes to make a full minute
- ///
- public Int32 SecondsPerMinute { get; set; }
-
- ///
- /// Gets or Sets how many Days it takes to make a full month in the world
- ///
- public Int32 DaysPerMonth { get; set; }
-
- ///
- /// Gets or Sets how many Months it takes to make a full Year in the world
- ///
- public Int32 MonthsPerYear { get; set; }
-
- ///
- /// Gets or Sets the name of each Day in a Week.
- ///
- public List DayNames { get; set; }
-
- ///
- /// Gets or Sets the name of each Month in a Year.
- ///
- public List MonthNames { get; set; }
-
- ///
- /// Gets or Sets what time of day the world is currently in.
- ///
- public TimeOfDayOptions DayTransitions { get; set; }
-
- ///
- /// Gets or Sets what time of day that it begins to transition to night.
- ///
- public Int32 DawnTime { get; set; }
-
- ///
- /// /Gets or Sets what time of day that it begins to transition into day time.
- ///
- public Int32 SunriseTime { get; set; }
-
- ///
- /// Gets or Sets the initial Time that the world starts in.
- ///
- public Time InitialGameTime { get; set; }
-
- private Int32 _LastSavedTime = 0;
-
- public GameTime(Game game)
- {
- ActiveGame = game;
-
- ServerStartTime = DateTime.Now;
-
- DayNames = new List();
- MonthNames = new List();
-
- DayNames.Add("Monday");
- DayNames.Add("Tuesday");
- DayNames.Add("Wednesday");
- DayNames.Add("Thursday");
- DayNames.Add("Friday");
- DayNames.Add("Saturday");
- DayNames.Add("Sunday");
-
- MonthNames.Add("January");
- MonthNames.Add("February");
- MonthNames.Add("March");
- MonthNames.Add("April");
- MonthNames.Add("May");
- MonthNames.Add("June");
- MonthNames.Add("July");
- MonthNames.Add("August");
- MonthNames.Add("September");
- MonthNames.Add("October");
- MonthNames.Add("November");
- MonthNames.Add("December");
-
- Time t = new Time();
- t.Second = 0;
- t.Minute = 0;
- t.Hour = 1;
- t.Day = 1;
- t.Month = 1;
- t.Year = 2010;
-
- InitialGameTime = t;
-
- DawnTime = 19;
- SunriseTime = 6;
-
- DayTransitions = TimeOfDayOptions.Transition;
-
- SecondsPerMinute = 1;
- MinutesPerHour = 1;
- HoursPerDay = 1;
- DaysPerMonth = 3;
- MonthsPerYear = 3;
-
- CurrentWorldTime = InitialGameTime;
- }
-
- public void Initialize()
- {
- Time t = InitialGameTime;
- CurrentWorldTime = t;
- CurrentSystemTime = DateTime.Now;
- }
-
- public virtual void Update()
- {
- TimeSpan ts = CurrentSystemTime - DateTime.Now;
-
- //If the seconds that has passed inbetween the last Update call is greater than 0
- //Then we need to increment a Second, which will start a domino effect if it needs to
- //in order to increment minute/hours/days/months and years.
- if (ts.Seconds <= -1)
- {
- CurrentSystemTime = DateTime.Now;
- Int32 amount = Math.Abs(ts.Seconds);
- IncrementSecond(amount);
- //Log.Write(GetCurrentWorldTime());
- }
-
- DateTime systemTime = DateTime.Now;
-
- if (_LastSavedTime == ActiveGame.AutoSaveInterval)
- {
- if (ActiveGame.AutoSave)
- ActiveGame.Save();
- _LastSavedTime = 0;
- }
-
- //ServerTime holds the last minute prior to our current minute.
- if (CurrentSystemTime.Minute != DateTime.Now.Minute)
- {
- _LastSavedTime++;
- }
-
- CurrentSystemTime = DateTime.Now;
- }
-
- public void IncrementSecond(Int32 amount)
- {
- Time t = new Time();
- t = CurrentWorldTime;
-
- if (CurrentWorldTime.Second == SecondsPerMinute)
- {
- IncrementMinute(1);
- t = CurrentWorldTime;
- t.Second = 0;
- }
- else if (CurrentWorldTime.Second > SecondsPerMinute)
- {
- Int32 minutes = CurrentWorldTime.Second / SecondsPerMinute;
- Int32 seconds = CurrentWorldTime.Second - SecondsPerMinute;
- IncrementMinute(minutes);
- t = CurrentWorldTime; //Get the updated world time.
- t.Second = seconds; //Edit it.
- }
- else
- t.Second += amount;
-
- CurrentWorldTime = t;
- }
-
- public void IncrementMinute(Int32 amount)
- {
- Time t = new Time();
- t = CurrentWorldTime;
-
- if (CurrentWorldTime.Minute == MinutesPerHour)
- {
- IncrementHour(1);
- t = CurrentWorldTime;
- t.Minute = 0;
-
- }
- else if (CurrentWorldTime.Minute > MinutesPerHour)
- {
- Int32 hours = CurrentWorldTime.Minute / MinutesPerHour;
- Int32 Minutes = CurrentWorldTime.Minute - MinutesPerHour;
- IncrementHour(hours);
- t = CurrentWorldTime;
- t.Minute = Minutes;
- }
- else
- t.Minute += amount;
-
- CurrentWorldTime = t;
- }
-
- public void IncrementHour(Int32 amount)
- {
- Time t = new Time();
- t = CurrentWorldTime;
-
- if (CurrentWorldTime.Hour == HoursPerDay)
- {
- IncrementDay();
- t = CurrentWorldTime;
- t.Hour = 0;
- }
- else if (CurrentWorldTime.Hour > HoursPerDay)
- {
- Int32 days = CurrentWorldTime.Hour / HoursPerDay;
- Int32 hours = CurrentWorldTime.Hour - HoursPerDay;
- IncrementDay();
- t = CurrentWorldTime;
- t.Hour = hours;
- }
- else
- t.Hour++;
-
- CurrentWorldTime = t;
- }
-
- public void IncrementDay()
- {
- Time t = new Time();
- t = CurrentWorldTime;
-
- //TODO: Finish GameTime syncing with Server Time.
- if (CurrentWorldTime.Day == DaysPerMonth)
- {
- IncrementMonth();
- t = CurrentWorldTime;
- t.Day = 1;
- }
- else
- t.Day++;
-
- CurrentWorldTime = t;
- }
-
- public void IncrementMonth()
- {
- Time t = new Time();
- t = CurrentWorldTime;
-
- if (CurrentWorldTime.Month == MonthsPerYear)
- {
- IncrementYear();
- t = CurrentWorldTime;
- t.Month = 1;
- }
- else
- t.Month++;
-
- CurrentWorldTime = t;
- }
-
- public void IncrementYear()
- {
- Time t = new Time();
- t = CurrentWorldTime;
-
- t.Year++;
-
- CurrentWorldTime = t;
- }
-
- public String GetCurrentWorldTime()
- {
- if (DayNames.Count < CurrentWorldTime.Day)
- {
- return "Not enough Day Names specified to match up with DaysPerMonth property.";
- }
- else if (MonthNames.Count < CurrentWorldTime.Month)
- {
- return "Not enough Month names specified to match up with MonthsPerYear property.";
- }
-
- String day = DayNames[CurrentWorldTime.Day - 1];
- String month = MonthNames[CurrentWorldTime.Month - 1];
-
- return day + ", " + month + " " + CurrentWorldTime.Day + ", " + CurrentWorldTime.Year + ": " + CurrentWorldTime.Hour + ":" + CurrentWorldTime.Minute + ":" + CurrentWorldTime.Second;
- }
-
- public Int32 GetCurrentSecond()
- {
- return CurrentWorldTime.Second;
- }
-
- public Int32 GetCurrentMinute()
- {
- return CurrentWorldTime.Minute;
- }
-
- public Int32 GetCurrentHour()
- {
- return CurrentWorldTime.Hour;
- }
-
- public Int32 GetCurrentDayNumber()
- {
- return CurrentWorldTime.Day;
- }
-
- public String GetCurrentDayName()
- {
- if (DayNames.Count > CurrentWorldTime.Day)
- return "No Day Name available for the current Date.";
- else
- return DayNames[CurrentWorldTime.Day - 1];//Days start at 1, array index starts at 0
- }
-
- public Int32 GetCurrentMonthNumber()
- {
- return CurrentWorldTime.Month;
- }
-
- public String GetCurrentMonthName()
- {
- if (MonthNames.Count > CurrentWorldTime.Month)
- return "No Month Name available for the current Date.";
- else
- return MonthNames[CurrentWorldTime.Month - 1]; //Day starts at 1, array index starts at 0.
- }
-
- public Int32 GetCurrentYear()
- {
- return CurrentWorldTime.Year;
- }
- }
-}
diff --git a/MudEngine/ClassesPendingMigration/GameWorld.cs b/MudEngine/ClassesPendingMigration/GameWorld.cs
index 6d1665b..06d341d 100644
--- a/MudEngine/ClassesPendingMigration/GameWorld.cs
+++ b/MudEngine/ClassesPendingMigration/GameWorld.cs
@@ -5,7 +5,7 @@ using System.Linq;
using System.IO;
using System.Text;
-//MudEngine
+/*
using MudEngine.FileSystem;
using MudEngine.GameManagement;
using MudEngine.GameObjects;
@@ -200,3 +200,4 @@ namespace MudEngine.GameManagement
}
}
}
+*/
\ No newline at end of file
diff --git a/MudEngine/ClassesPendingMigration/ICommand.cs b/MudEngine/ClassesPendingMigration/ICommand.cs
deleted file mode 100644
index d965057..0000000
--- a/MudEngine/ClassesPendingMigration/ICommand.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-//Microsoft .NET Framework
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-//MUD Engine
-using MudEngine.Commands;
-using MudEngine.GameObjects.Characters;
-using MudEngine.GameManagement;
-using MudEngine.GameObjects.Environment;
-
-namespace MudEngine.GameManagement
-{
- public interface IGameCommand
- {
- //Name of the command
- String Name { get; set; }
- //Used to override commands with the same name
- Boolean Override { get; set; }
-
- //Used when the player enters the help command
- List Help { get; set; }
-
- //Executes the command.
- void Execute(String command, BaseCharacter player);
- }
-}
diff --git a/MudEngine/ClassesPendingMigration/Log.cs b/MudEngine/ClassesPendingMigration/Log.cs
index 1405c87..43bf323 100644
--- a/MudEngine/ClassesPendingMigration/Log.cs
+++ b/MudEngine/ClassesPendingMigration/Log.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.IO;
+/*
using MudEngine.FileSystem;
namespace MudEngine.GameManagement
@@ -67,3 +68,4 @@ namespace MudEngine.GameManagement
}
}
}
+*/
\ No newline at end of file
diff --git a/MudEngine/ClassesPendingMigration/SecurityRoles.cs b/MudEngine/ClassesPendingMigration/SecurityRoles.cs
deleted file mode 100644
index e003c44..0000000
--- a/MudEngine/ClassesPendingMigration/SecurityRoles.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-
-namespace MudEngine.GameManagement
-{
- public enum SecurityRoles
- {
- Admin,
- Immortal,
- GM,
- QuestGiver,
- Player,
- NPC
- }
-}
diff --git a/MudEngine/Communication/OldServer.cs b/MudEngine/Communication/OldServer.cs
new file mode 100644
index 0000000..f489c8f
--- /dev/null
+++ b/MudEngine/Communication/OldServer.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+using System.Text;
+
+using MudEngine.Core;
+
+namespace MudEngine.Communication
+{
+ public class OldServer
+ {
+ /*
+ public OldServer()
+ {
+ stage = 0;
+ port = 0;
+ server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ }
+ ~OldServer()
+ {
+ stage = 0;
+ port = 0;
+ }
+ public Boolean Initialize(Int32 p, ref BaseCharacter[] pbs)
+ {
+ if (stage != 0)
+ return false;
+ if (p <= 0)
+ return false;
+ port = p;
+ players = pbs;
+ clientThreads = new Thread[players.Length];
+ stage++;
+ return true;
+ }
+ public Boolean Start()
+ {
+ try
+ {
+ if (stage != 1)
+ return false;
+ IPEndPoint ipep = new IPEndPoint(IPAddress.Any, port);
+ server.Bind(ipep);
+ server.Listen(10);
+ stage++;
+ serverThread = new Thread(ServerThread);
+ serverThread.Start();
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ return true;
+ }
+ public void EndServer()
+ {
+ stage = 0;
+ serverThread.Abort();
+ server.Close();
+ }
+ private void ServerThread()
+ {
+ while (stage == 2)
+ {
+ Int32 sub = -1;
+ do
+ {
+ for (Int32 i = 0; i < players.Length; i++)
+ {
+ if (!players[i].IsActive)
+ {
+ sub = i;
+ break;
+ }
+ }
+ } while (sub < 0);
+ players[sub].client = server.Accept();
+ players[sub].IsActive = true;
+ players[sub].IsControlled = true;
+ clientThreads[sub] = new Thread(ReceiveThread);
+ clientThreads[sub].Start((object)sub);
+ }
+ }
+ private void ReceiveThread(object obj)
+ {
+ Int32 sub = (Int32)obj;
+ players[sub].Initialize();
+ while (stage == 2 && players[sub].IsActive)
+ {
+ players[sub].Receive(players[sub].ReadInput());
+ }
+ }
+ public void Disconnect(Int32 sub)
+ {
+ if (sub > 0 && sub < players.Length)
+ {
+ clientThreads[sub].Abort();
+ if (players[sub].IsActive)
+ players[sub].Disconnect();
+ }
+ }
+
+ private Thread serverThread;
+ private Socket server;
+ private Int32 stage;
+ private Int32 port;
+
+ BaseCharacter[] players;
+
+ private Thread[] clientThreads;
+ */
+ }
+}
\ No newline at end of file
diff --git a/MudEngine/Communication/Server.cs b/MudEngine/Communication/Server.cs
new file mode 100644
index 0000000..18e9292
--- /dev/null
+++ b/MudEngine/Communication/Server.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+using System.Text;
+
+using MudEngine.Core;
+
+namespace MudEngine.Communication
+{
+ public class Server : BaseServer
+ {
+ //Listens for incoming connections
+ private TcpListener _Listener;
+
+ //Dedicated thread for accepting and processing new connections
+ private Thread _Connect;
+
+ private Dictionary _ClientCollection;
+
+ ///
+ /// Server constructor. Requires a currently active game to start.
+ ///
+ ///
+ public Server(BaseGame game) : base(game)
+ {
+ this._Listener = new TcpListener(IPAddress.Any, 555);
+ this._Connect = new Thread(new ThreadStart(ListenForConnections));
+ this._ClientCollection = new Dictionary();
+ }
+
+ ///
+ /// Server constructor. Requires a currently active game and desired port number to start.
+ ///
+ ///
+ ///
+ public Server(BaseGame game, int port)
+ : base(game)
+ {
+ this._Listener = new TcpListener(IPAddress.Any, port);
+ this._Connect = new Thread(new ThreadStart(ListenForConnections));
+ this._ClientCollection = new Dictionary();
+ }
+
+ //Listens for incoming client connections.
+ private void ListenForConnections()
+ {
+ this._Listener.Start();
+
+ while (true)
+ {
+ TcpClient client = this._Listener.AcceptTcpClient();
+
+ //Someone connects, send them to a new thread.
+ Thread newClient = new Thread(new ParameterizedThreadStart(OnConnect));
+ newClient.Start(client);
+ }
+ }
+
+ public override void Initialize()
+ {
+ this._Connect.Start();
+ }
+
+ public override void OnConnect(object client)
+ {
+ this.ActiveGame.OnConnect((TcpClient)client);
+ }
+
+ public override void OnDisconnect(object client)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void RecieveData(string data)
+ {
+ //TODO: command needs to be executed.
+ }
+
+ public override void SendData(string data)
+ {
+ }
+ }
+}
diff --git a/MudEngine/Core/BaseCharacter.cs b/MudEngine/Core/BaseCharacter.cs
new file mode 100644
index 0000000..c37bfcd
--- /dev/null
+++ b/MudEngine/Core/BaseCharacter.cs
@@ -0,0 +1,141 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ ///
+ /// Collection of Roles that can be assigned to a character, either controlled or non-controlled.
+ ///
+ public enum CharacterRoles
+ {
+ Admin,
+ Immortal,
+ GM,
+ QuestGiver,
+ Player,
+ NPC
+ }
+
+ public struct CharacterStats
+ {
+ public int Strength { get; set; }
+ public int Dexterity { get; set; }
+ public int Constitution { get; set; }
+ public int Intelligence { get; set; }
+ public int Wisdom { get; set; }
+ public int Charisma { get; set; }
+ public int Experience { get; set; }
+ }
+
+ public abstract class BaseCharacter : BaseObject, ICharacter
+ {
+ private TcpClient _ConnectedClient;
+
+ ///
+ /// Gets the currently active game.
+ ///
+ [Browsable(false)]
+ public BaseGame ActiveGame { get; private set; }
+
+ ///
+ /// Gets or Sets the Role that this character has in the game.
+ ///
+ [Browsable(false)]
+ public CharacterRoles Role { get; set; }
+
+ ///
+ /// Gets the current stats for this character.
+ ///
+ [Browsable(false)]
+ public CharacterStats Stats { get; protected set; }
+
+ ///
+ /// Gets or Sets the password used to log into this character
+ ///
+ [Browsable(false)]
+ public string Password { get; set; }
+
+ ///
+ /// Gets or Sets if this character can move about the world or not.
+ ///
+ public bool IsStatic { get; set; }
+
+ ///
+ /// Gets if this character is controlled by Human or AI
+ ///
+ public bool IsAI { get; private set; }
+
+ ///
+ /// Gets the current location of this character within the world.
+ ///
+ public IEnvironment CurrentLocation { get; private set; }
+
+ public BaseCharacter(BaseGame game)
+ {
+ this.ActiveGame = game;
+ this.ID = this.ActiveGame.GetAvailableID();
+ }
+
+ public void Initialize()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Update()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnConnect(TcpClient client)
+ {
+ this._ConnectedClient = client;
+
+ NetworkStream clientStream = this._ConnectedClient.GetStream();
+
+ //Stores messages recieved from the client
+ byte[] message = new byte[4096];
+ int bytesRead;
+
+ while (true)
+ {
+ bytesRead = 0;
+
+ try
+ {
+ bytesRead = clientStream.Read(message, 0, 4096);
+ }
+ catch
+ {
+ break; //error occured. Re-try
+ }
+
+ if (bytesRead == 0)
+ {
+ break; //Disconnected.
+ }
+
+ ASCIIEncoding encoder = new ASCIIEncoding();
+ string data = encoder.GetString(message, 0, bytesRead);
+ //RecieveData(data);
+ }
+
+ //TODO: Call ActiveGame.OnDisconnect();
+ //newClient.Close(); //Disconnect the client.
+ }
+
+ public void OnTravel(World.AvailableTravelDirections travelDirection)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnTalk(string message, ICharacter instigator)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/MudEngine/Core/BaseCommand.cs b/MudEngine/Core/BaseCommand.cs
new file mode 100644
index 0000000..9226b84
--- /dev/null
+++ b/MudEngine/Core/BaseCommand.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public abstract class BaseCommand : ICommand
+ {
+ ///
+ /// Gets or Sets a collection of help topics related to this command.
+ ///
+ [Browsable(false)]
+ public List Help { get; set; }
+
+ public BaseCommand()
+ {
+ Help = new List();
+ }
+
+ ///
+ /// Executes the command for the character supplied.
+ ///
+ ///
+ ///
+ public abstract void Execute(string command, ICharacter character);
+
+ public string Name
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public string Description
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/MudEngine/Core/BaseEnvironment.cs b/MudEngine/Core/BaseEnvironment.cs
new file mode 100644
index 0000000..f14a5a8
--- /dev/null
+++ b/MudEngine/Core/BaseEnvironment.cs
@@ -0,0 +1,172 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public abstract class BaseEnvironment : BaseObject, IEnvironment
+ {
+ ///
+ /// Gets or Sets if this environment will be safe from harmful objects
+ ///
+ [Category("Environment Settings")]
+ [Description("Sets if the environment will be safe from harmful objects.")]
+ public bool IsSafe {get;set;}
+
+ ///
+ /// Gets a collection of all occupants, either players or NPC, within this environment.
+ ///
+ [Browsable(false)]
+ public List CurrentOccupants {get; private set;}
+
+ ///
+ /// Gets or Sets the way that the environment smells.
+ ///
+ [Category("Environment Settings")]
+ [Description("Sets how the environment will smell.")]
+ public string Smell {get;set;}
+
+ ///
+ /// Gets or Sets how the environment feels.
+ ///
+ [Category("Environment Settings")]
+ [Description("Sets how the environment feels.")]
+ public string Feel {get;set;}
+
+ ///
+ /// Gets or Sets the sounds that can be heard within this environment.
+ ///
+ [Category("Environment Settings")]
+ [Description("Sets the sounds that can be heard within this environment")]
+ public string Listen { get; set; }
+
+ protected BaseGame ActiveGame { get; private set; }
+
+ public BaseEnvironment(BaseGame game)
+ {
+ this.ActiveGame = game;
+ this.ID = this.ActiveGame.GetAvailableID();
+ }
+
+ ///
+ /// Performs any actions needed when a character occupies the environment.
+ ///
+ ///
+ public virtual void OnOccupantEnter(ICharacter character)
+ {
+ if (!CurrentOccupants.Contains(character.Name))
+ CurrentOccupants.Add(character.Name);
+ }
+
+ ///
+ /// Performs needed actions when a character leaves the occupied environment.
+ ///
+ ///
+ public virtual void OnOccupantExit(ICharacter character)
+ {
+ if (!CurrentOccupants.Contains(character.Name))
+ CurrentOccupants.Remove(character.Name);
+ }
+
+ bool IEnvironment.IsSafe
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ List IEnvironment.CurrentOccupants
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ string IEnvironment.Smell
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ string IEnvironment.Feel
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ string IEnvironment.Listen
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ void IEnvironment.OnOccupantEnter(ICharacter character)
+ {
+ throw new NotImplementedException();
+ }
+
+ void IEnvironment.OnOccupantExit(ICharacter character)
+ {
+ throw new NotImplementedException();
+ }
+
+ string IObject.Name
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ string IObject.Filename
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ string IObject.Description
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/MudEngine/Core/BaseGame.cs b/MudEngine/Core/BaseGame.cs
new file mode 100644
index 0000000..0f161cd
--- /dev/null
+++ b/MudEngine/Core/BaseGame.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public abstract class BaseGame : BaseObject
+ {
+ ///
+ /// Enables or Disables the server.
+ ///
+ [Category("Game Settings")]
+ [Description("Enables or Disabels the server.")]
+ public bool EnableServer { get; set; }
+
+ ///
+ /// Enables or Disables the Auto Save feature.
+ ///
+ [Category("Game Settings")]
+ [Description("Enables or Disables the Auto Save feature.")]
+ public bool EnableAutoSave { get; set; }
+
+ public int AutoSaveInterval { get; set; }
+
+ public int PasswordMinimumSize { get; set; }
+
+ public int MaximumPlayers { get; set; }
+
+ public Dictionary ConnectedPlayers { get; private set; }
+
+ public string Version { get; set; }
+
+ public IEnvironment InitialEnvironment { get; set; }
+
+ public BaseGame()
+ {
+ this.ConnectedPlayers = new Dictionary();
+ this.ID = 0;
+ }
+
+ public abstract void Initialize();
+
+ public abstract void Update();
+
+ public abstract void Shutdown();
+
+ public abstract void OnConnect(TcpClient client);
+
+ public abstract void OnDisconnect(TcpClient client);
+
+ public abstract int GetAvailableID();
+ }
+}
diff --git a/MudEngine/Core/BaseItem.cs b/MudEngine/Core/BaseItem.cs
new file mode 100644
index 0000000..d775aa0
--- /dev/null
+++ b/MudEngine/Core/BaseItem.cs
@@ -0,0 +1,83 @@
+using System;
+using System.ComponentModel;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public abstract class BaseItem : BaseObject, IGameComponent
+ {
+ #region Properties
+ ///
+ /// Gets a reference to the currently active game.
+ ///
+ [Browsable(false)]
+ public BaseGame ActiveGame { get; private set; }
+ #endregion
+
+ public BaseItem(BaseGame game)
+ {
+ this.ActiveGame = game;
+ this.ID = this.ActiveGame.GetAvailableID();
+ }
+
+ ///
+ /// Initializes the item
+ ///
+ public abstract void Initialize();
+
+ public abstract void Update();
+
+ BaseGame IGameComponent.ActiveGame
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ void IGameComponent.Initialize()
+ {
+ throw new NotImplementedException();
+ }
+
+ void IGameComponent.Update()
+ {
+ throw new NotImplementedException();
+ }
+
+ string IObject.Name
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ string IObject.Filename
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ string IObject.Description
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/MudEngine/Core/BaseObject.cs b/MudEngine/Core/BaseObject.cs
new file mode 100644
index 0000000..177ca92
--- /dev/null
+++ b/MudEngine/Core/BaseObject.cs
@@ -0,0 +1,118 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public abstract class BaseObject : IObject
+ {
+ #region Fields
+ //Name of this object
+ string _Name;
+
+ //Object filename
+ string _Filename;
+ #endregion
+
+ #region Properties
+ ///
+ /// Gets or Sets the Name for this object. The objects Filename property is automatically set to match the Name.
+ ///
+ [Category("Object Information")]
+ [Description("Provides a name for this object")]
+ public string Name
+ {
+ get
+ {
+ return _Name;
+ }
+ set
+ {
+ _Name = value;
+ if (this.GetType().Name.StartsWith("Base"))
+ Filename = value + "." + this.GetType().Name.Substring("Base".Length);
+ else
+ Filename = value + "." + this.GetType().Name;
+ }
+ }
+
+ public int ID { get; protected set; }
+
+ ///
+ /// Gets or Sets the Filename used to save/load this object. The Filename is automatically set/changed when the Name property changes
+ ///
+ [Category("Object Information")]
+ [Description("Sets the Filename used to Save/Load this object. The Filename is automatically set/changed when the Name property is changed.")]
+ public string Filename
+ {
+ get
+ {
+ return _Filename;
+ }
+ set
+ {
+ if (this.GetType().Name.StartsWith("Base"))
+ {
+ if (value.EndsWith("." + this.GetType().Name.Substring("Base".Length)))
+ {
+ _Filename = value;
+ }
+ else
+ _Filename = value + "." + this.GetType().Name.Substring("Base".Length);
+ }
+ else
+ {
+ if (value.EndsWith("." + this.GetType().Name))
+ {
+ _Filename = value;
+ }
+ else
+ _Filename = value + "." + this.GetType().Name;
+ }
+ }
+ }
+
+ ///
+ /// Gets or Sets a description of what this object is in the game world.
+ ///
+ [Category("Object Information")]
+ [Description("Sets the description used to explain what this object is within the game world.")]
+ public string Description { get; set; }
+ #endregion
+
+ public BaseObject()
+ {
+ this.Name = DefaultName();
+ }
+
+ #region Public Methods
+
+ ///
+ /// Returns the default name generated for this object by the engine.
+ ///
+ ///
+ protected virtual string DefaultName()
+ {
+ return "New " + this.GetType().Name;
+ }
+
+ public override string ToString()
+ {
+ return this.Name;
+ }
+ #endregion
+
+
+ public virtual void Load(string objectName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual void Save()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/MudEngine/Core/BaseServer.cs b/MudEngine/Core/BaseServer.cs
new file mode 100644
index 0000000..22cd8f3
--- /dev/null
+++ b/MudEngine/Core/BaseServer.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+
+namespace MudEngine.Core
+{
+ public abstract class BaseServer : BaseObject, ICommunicate
+ {
+ public int Port { get; set; }
+
+ public ICommand LoginCommand { get; set; }
+
+ public BaseGame ActiveGame { get; private set; }
+
+ public BaseServer(BaseGame game)
+ {
+ this.ActiveGame = game;
+ }
+
+ public virtual void Initialize()
+ {
+ }
+
+ public virtual void Update()
+ {
+ throw new NotImplementedException();
+ }
+
+ public abstract void OnConnect(object client);
+
+ public abstract void OnDisconnect(object client);
+
+ public abstract void RecieveData(string data);
+
+ public abstract void SendData(string data);
+ }
+}
diff --git a/MudEngine/Core/ICharacter.cs b/MudEngine/Core/ICharacter.cs
new file mode 100644
index 0000000..92aa015
--- /dev/null
+++ b/MudEngine/Core/ICharacter.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+
+using MudEngine.World;
+
+namespace MudEngine.Core
+{
+ public interface ICharacter : IGameComponent
+ {
+ CharacterRoles Role { get; set; }
+ string Password { get; set; }
+ bool IsStatic { get; set; }
+ bool IsAI { get; }
+ IEnvironment CurrentLocation { get; }
+
+ void OnTravel(AvailableTravelDirections travelDirection);
+ void OnTalk(string message, ICharacter instigator);
+ void OnConnect(TcpClient client);
+ }
+}
diff --git a/MudEngine/Core/ICommand.cs b/MudEngine/Core/ICommand.cs
new file mode 100644
index 0000000..b20fec5
--- /dev/null
+++ b/MudEngine/Core/ICommand.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public interface ICommand
+ {
+ string Name { get; set; }
+ string Description { get; set; }
+ List Help { get; set; }
+
+ void Execute(string command, ICharacter character);
+ }
+}
diff --git a/MudEngine/Core/ICommunicate.cs b/MudEngine/Core/ICommunicate.cs
new file mode 100644
index 0000000..b627d57
--- /dev/null
+++ b/MudEngine/Core/ICommunicate.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public interface ICommunicate : IGameComponent
+ {
+ int Port { get; set; }
+ ICommand LoginCommand { get; set; }
+
+ void OnConnect(object client);
+ void OnDisconnect(object client);
+ void RecieveData(string data);
+ void SendData(string data);
+ }
+}
diff --git a/MudEngine/Core/ICompiler.cs b/MudEngine/Core/ICompiler.cs
new file mode 100644
index 0000000..e16c75c
--- /dev/null
+++ b/MudEngine/Core/ICompiler.cs
@@ -0,0 +1,40 @@
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+
+namespace MudEngine.Core
+{
+ ///
+ /// Used to implement a wrapper for an existing compiler.
+ ///
+ public interface ICompiler
+ {
+ CompilerResults Results { get; set; }
+ ///
+ /// The file extension used for the script files.
+ ///
+ String ScriptExtension { get; set; }
+
+ ///
+ /// Provides a collection of Assemblies that the compiler will add to its reference list.
+ ///
+ List AssemblyReferences { get; set; }
+
+ ///
+ /// Provides compiling options to various compilers, if they support this feature.
+ ///
+ Dictionary CompilerOptions { get; set; }
+
+ ///
+ /// Compiles the source files found within the scriptRepository directory matching the ICompiler.ScriptExtension
+ /// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
+ ///
+ /// Compiler Parameters that can be supplied to customize the compilation of the source.
+ /// Returns true if the compilation was completed without error.
+ Boolean Compile(CompilerParameters param, String scriptRepository);
+
+ Boolean Compile(CompilerParameters param, System.IO.FileInfo scriptFile);
+
+ Boolean Compile(CompilerParameters param, String[] scriptSource);
+ }
+}
\ No newline at end of file
diff --git a/MudEngine/Core/IEnvironment.cs b/MudEngine/Core/IEnvironment.cs
new file mode 100644
index 0000000..1519452
--- /dev/null
+++ b/MudEngine/Core/IEnvironment.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public interface IEnvironment : IObject
+ {
+ bool IsSafe { get; set; }
+ List CurrentOccupants { get; }
+
+ string Smell { get; set; }
+ string Feel { get; set; }
+ string Listen { get; set; }
+
+ void OnOccupantEnter(ICharacter character);
+
+ void OnOccupantExit(ICharacter character);
+ }
+}
diff --git a/MudEngine/Core/IGameComponent.cs b/MudEngine/Core/IGameComponent.cs
new file mode 100644
index 0000000..10fbc32
--- /dev/null
+++ b/MudEngine/Core/IGameComponent.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public interface IGameComponent : IObject
+ {
+ BaseGame ActiveGame { get; }
+
+ void Initialize();
+
+ void Update();
+ }
+}
diff --git a/MudEngine/Core/IObject.cs b/MudEngine/Core/IObject.cs
new file mode 100644
index 0000000..aedbc08
--- /dev/null
+++ b/MudEngine/Core/IObject.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.Core
+{
+ public interface IObject
+ {
+ string Name { get; set; }
+
+ string Filename { get; set; }
+
+ string Description { get; set; }
+ }
+}
diff --git a/MudEngine/MudEngine.csproj b/MudEngine/MudEngine.csproj
index 01ab665..10ba86d 100644
--- a/MudEngine/MudEngine.csproj
+++ b/MudEngine/MudEngine.csproj
@@ -54,20 +54,35 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}
- rScripting
-
+
+
+
+
+
+
+
+
+
+
diff --git a/MudEngine/Runtime/CommandSystem.cs b/MudEngine/Runtime/CommandSystem.cs
new file mode 100644
index 0000000..d7d688a
--- /dev/null
+++ b/MudEngine/Runtime/CommandSystem.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+using MudEngine.Core;
+
+namespace MudEngine.Runtime
+{
+ public class CommandSystem
+ {
+ public Dictionary Commands { get; private set; }
+
+ public CommandSystem()
+ {
+ Commands = new Dictionary();
+ LoadCommands();
+ }
+
+ public List GetCommands()
+ {
+ List collection = new List();
+
+ foreach (ICommand c in this.Commands.Values)
+ collection.Add(c);
+
+ return collection;
+ }
+
+ public ICommand GetCommand(string command)
+ {
+ foreach (ICommand c in this.Commands.Values)
+ {
+ if (c.Name.ToLower() == command.ToLower())
+ return c;
+ }
+
+ return null;
+ }
+
+ public bool IsValidCommand(string command)
+ {
+ if (this.Commands.ContainsKey(command))
+ return true;
+ else
+ return false;
+ }
+
+ public void Execute(string command, ICharacter character)
+ {
+ string key = command.Insert(0, "Command");
+
+ foreach (string k in this.Commands.Keys)
+ {
+ if (key.ToLower().Contains(k.ToLower()))
+ {
+ ICommand cmd = this.Commands[k];
+ try
+ {
+ cmd.Execute(command, character);
+ }
+ catch (Exception ex)
+ {
+ throw new NotImplementedException();
+ }
+
+ return;
+ }
+ }
+
+ //TODO: Inform player that this was not a valid command.
+ }
+
+ private void LoadCommands()
+ {
+ this.LoadCommandLibrary(Assembly.GetExecutingAssembly(), true);
+ }
+
+ public void LoadCommandLibrary(Assembly commandLibrary)
+ {
+ LoadCommandLibrary(commandLibrary, true);
+ }
+
+ public void LoadCommandLibrary(Assembly commandLibrary, bool purgeLoadedCommands)
+ {
+ if (purgeLoadedCommands)
+ PurgeCommands();
+
+ if (commandLibrary == null)
+ return;
+
+ foreach (Type type in commandLibrary.GetTypes())
+ {
+ //All commands implement the ICommand interface.
+ //If that interface is not present on this Type, skip and go to the next one.
+ if (!type.IsInterface)
+ continue;
+
+ if (type.GetInterface("ICommand") == null)
+ continue;
+
+ ICommand cmd = (ICommand)Activator.CreateInstance(type);
+
+ if (cmd != null)
+ {
+ //Fail safe measures. Ensure that we always have a name assigned to the commands.
+ if ((cmd.Name == "") || (cmd.Name == null))
+ cmd.Name = cmd.GetType().Name.ToLower();
+ else
+ cmd.Name = cmd.Name.ToLower(); //Commands are always stored in lower case.
+
+ if (this.Commands.ContainsKey(cmd.Name))
+ continue; //No overriding supported. Skip this command.
+
+ //Everything checks out ok. Add the command to our collection.
+ this.Commands.Add(cmd.Name, cmd);
+ }
+ }
+ }
+
+ public void PurgeCommands()
+ {
+ this.Commands.Clear();
+ }
+ }
+}
diff --git a/MudEngine/Runtime/MudCompiler.cs b/MudEngine/Runtime/MudCompiler.cs
new file mode 100644
index 0000000..21ab725
--- /dev/null
+++ b/MudEngine/Runtime/MudCompiler.cs
@@ -0,0 +1,124 @@
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.IO;
+using Microsoft.CSharp;
+
+using MudEngine.Core;
+
+namespace MudEngine.Runtime
+{
+ ///
+ /// Standard C# source code compiler.
+ ///
+ internal class MudCompiler : ICompiler
+ {
+ ///
+ /// The file extension used for the script files.
+ ///
+ public String ScriptExtension { get; set; }
+
+ ///
+ /// Provides a collection of Assemblies that the compiler will add to its reference list.
+ ///
+ public List AssemblyReferences { get; set; }
+
+ ///
+ /// The results of the compilation
+ ///
+ public CompilerResults Results { get; set; }
+
+ ///
+ /// Provides compiling options to various compilers, if they support this feature.
+ ///
+ public Dictionary CompilerOptions { get; set; }
+
+ ///
+ /// Compiles the source files found within the scriptRepository directory matching the ICompiler.ScriptExtension
+ /// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
+ ///
+ /// Compiler Parameters that can be supplied to customize the compilation of the source.
+ /// Returns true if the compilation was completed without error.
+ public Boolean Compile(CompilerParameters param, String scriptRepository)
+ {
+ //Make sure we have a compiler version supplied.
+ if (!CompilerOptions.ContainsKey("CompilerVersion"))
+ CompilerOptions.Add("CompilerVersion", "v4.0");
+
+ //Instance a reference to the C# code provider, this is what will perform the compiling.
+ CSharpCodeProvider provider = new CSharpCodeProvider(CompilerOptions);
+ //Create an array of script files found within the ScriptRepository matching the ScriptExtension properties.
+ String[] scripts = Directory.GetFiles(scriptRepository, "*" + this.ScriptExtension, SearchOption.AllDirectories);
+
+ //Compile the scripts and provide the Results property with a reference to the compilation results.
+ Results = provider.CompileAssemblyFromFile(param, scripts);
+
+ //if the compiler has errors, return false.
+ if (Results.Errors.HasErrors)
+ return false;
+ else
+ return true;
+ }
+
+ ///
+ /// Compiles the source files found within the scriptFile argument.
+ /// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
+ ///
+ ///
+ ///
+ public Boolean Compile(CompilerParameters param, FileInfo scriptFile)
+ {
+ //Make sure we have a compiler version supplied.
+ if (!CompilerOptions.ContainsKey("CompilerVersion"))
+ CompilerOptions.Add("CompilerVersion", "v4.0");
+
+ CSharpCodeProvider provider = new CSharpCodeProvider(CompilerOptions);
+
+ //Make sure the file exists prior to attempting to compile it.
+ if (scriptFile.Exists)
+ {
+ //Compile the script and provide the Results property with a referece to the compilation results.
+ Results = provider.CompileAssemblyFromFile(param, scriptFile.FullName);
+ }
+ else
+ {
+ Results.Errors.Add(new CompilerError(scriptFile.FullName, 0, 0, "rS01", "The supplied filename does not exist."));
+ return false;
+ }
+
+ if (Results.Errors.HasErrors)
+ return false;
+ else
+ return true;
+ }
+
+ ///
+ /// Compiles the source code found within the scriptSourceCode argument
+ /// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
+ ///
+ ///
+ ///
+ public Boolean Compile(CompilerParameters param, String[] scriptSourceCode)
+ {
+ if (!CompilerOptions.ContainsKey("CompilerVersion"))
+ CompilerOptions.Add("CompilerVersion", "v4.0");
+
+ CSharpCodeProvider provider = new CSharpCodeProvider(CompilerOptions);
+
+ if (scriptSourceCode.Length == 0)
+ {
+ Results.Errors.Add(new CompilerError("None", 0, 0, "rS02", "No Source provided."));
+ return false;
+ }
+ else
+ {
+ Results = provider.CompileAssemblyFromSource(param, scriptSourceCode);
+ }
+
+ if (Results.Errors.HasErrors)
+ return false;
+ else
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MudEngine/Runtime/ScriptFactory.cs b/MudEngine/Runtime/ScriptFactory.cs
new file mode 100644
index 0000000..c0974f7
--- /dev/null
+++ b/MudEngine/Runtime/ScriptFactory.cs
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+
+namespace MudEngine.Runtime
+{
+ public class ScriptFactory
+ {
+ //The assembly loaded that will be used.
+ private List _AssemblyCollection;
+
+ ///
+ /// Constructor for a Windows PC Script Factory
+ ///
+ ///
+ public ScriptFactory(String assembly)
+ {
+ Assembly a;
+ _AssemblyCollection = new List();
+
+ //See if a file exists first with this assembly name.
+ if (File.Exists(assembly))
+ {
+ a = Assembly.Load(new AssemblyName(assembly));
+ }
+ //If not, then try and load it differently
+ else
+ {
+ a = Assembly.Load(assembly);
+ }
+
+ if (a == null)
+ return;
+
+ //Add the assembly to our assembly collection.
+ _AssemblyCollection.Add(a);
+ }
+
+ ///
+ /// Alternate Constructor for a Windows PC ScriptFactory
+ ///
+ ///
+ public ScriptFactory(Assembly assembly)
+ {
+ _AssemblyCollection = new List();
+ //Add the supplied assembly to our AssemblyCollection
+ _AssemblyCollection.Add(assembly);
+ }
+
+ ///
+ /// Adds another assembly to the factories assembly collection.
+ ///
+ /// provides the name of the assembly, or file name that needs to be loaded.
+ public void AddAssembly(String assembly)
+ {
+ Assembly a;
+
+ //See if a file exists first with this assembly name.
+ if (File.Exists(assembly))
+ {
+ a = Assembly.Load(new AssemblyName(assembly));
+ }
+ //If not, then try and load it differently
+ else
+ {
+ a = Assembly.Load(assembly);
+ }
+
+ //Add the assembly to our assembly collection.
+ _AssemblyCollection.Add(a);
+ }
+
+ ///
+ /// Adds another assembly to the factories assembly collection.
+ ///
+ /// Provides a reference to the assembly that will be added to the collection.
+ public void AddAssembly (Assembly assembly)
+ {
+ //Add the supplied assembly to our AssemblyCollection
+ _AssemblyCollection.Add(assembly);
+ }
+
+ public ScriptObject GetScript(String scriptName)
+ {
+ Type script = typeof(Object);
+ Boolean foundScript = false;
+
+ if (_AssemblyCollection.Count == 0)
+ return new ScriptObject(null);
+
+ try
+ {
+ foreach (Assembly a in _AssemblyCollection)
+ {
+ //The assembly can be null if accessing after a failed compilation.
+ if (a == null)
+ continue;
+
+ foreach (Type t in a.GetTypes())
+ {
+ if (t.Name == scriptName)
+ {
+ script = t;
+ foundScript = true;
+ break;
+ }
+ }
+
+ if (foundScript)
+ break;
+ }
+ }
+ catch
+ {
+ throw new Exception("Error encounted during factory instancing of script " + scriptName + ".");
+ }
+
+ ScriptObject obj = new ScriptObject(Activator.CreateInstance(script));
+ return obj;
+ }
+ }
+}
diff --git a/MudEngine/Runtime/ScriptObject.cs b/MudEngine/Runtime/ScriptObject.cs
new file mode 100644
index 0000000..8cadb4c
--- /dev/null
+++ b/MudEngine/Runtime/ScriptObject.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Reflection;
+using System.Text;
+
+namespace MudEngine.Runtime
+{
+ public class ScriptObject
+ {
+ public Object Instance { get; set; }
+
+ public ScriptObject(Object instance)
+ {
+ if (instance == null)
+ Instance = new Object();
+ else
+ Instance = instance;
+ }
+
+ ~ScriptObject()
+ {
+ //TODO: Add ability to call a Shutdown() method within this Instance.
+ Instance = null;
+ }
+
+ public void SetProperty(String propertyName, object propertyValue)
+ {
+ PropertyInfo propertyInfo = Instance.GetType().GetProperty(propertyName);
+
+ if (propertyValue is String)
+ {
+ if (propertyInfo.PropertyType.Name is String)
+ {
+ propertyInfo.SetValue(Instance, propertyValue, null);
+ }
+ }
+ }
+
+ public object GetProperty(String propertyName)
+ {
+ String[] tokens = propertyName.Split('.');
+ PropertyInfo previousProperty = Instance.GetType().GetProperty(tokens[0]);
+
+ return previousProperty.GetValue(Instance, null);
+ }
+
+ public dynamic GetProperty()
+ {
+ return Instance;
+ }
+
+ public object GetField(String propertyName)
+ {
+ String[] tokens = propertyName.Split('.');
+ FieldInfo previousField = Instance.GetType().GetField(tokens[0]);
+
+ return previousField.GetValue(Instance);
+ }
+
+ public dynamic GetField()
+ {
+ return Instance;
+ }
+
+ public Object InvokeMethod(String methodName)
+ {
+ return InvokeMethod(methodName, null);
+ }
+
+ public Object InvokeMethod(String methodName, params Object[] parameters)
+ {
+ MethodInfo method = Instance.GetType().GetMethod(methodName);
+
+ try
+ {
+ if (parameters == null || parameters.Length == 0)
+ return method.Invoke(Instance, null);
+ else
+ return method.Invoke(Instance, parameters);
+ }
+ catch
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("Error invoking method. Does the method exist?");
+ return sb.ToString();
+ }
+ }
+ }
+}
diff --git a/MudEngine/Runtime/ScriptSystem.cs b/MudEngine/Runtime/ScriptSystem.cs
new file mode 100644
index 0000000..e815175
--- /dev/null
+++ b/MudEngine/Runtime/ScriptSystem.cs
@@ -0,0 +1,403 @@
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using Microsoft.CSharp;
+using Microsoft.VisualBasic;
+
+using MudEngine.Core;
+
+namespace MudEngine.Runtime
+{
+ ///
+ /// Provides Properties & Methods needed to compile script source code into .NET assemblies.
+ ///
+ public class ScriptSystem
+ {
+ ///
+ /// The file extension used for the script files.
+ ///
+ public String ScriptExtension
+ {
+ get
+ {
+ return _ScriptExtension;
+ }
+ set
+ {
+ if (value.StartsWith("."))
+ _ScriptExtension = value;
+ else
+ _ScriptExtension = "." + value;
+ }
+ }
+ private String _ScriptExtension;
+
+ ///
+ /// Provides a collection of Assemblies that the compiler will add to its reference list.
+ ///
+ public List AssemblyReferences { get; private set; }
+
+ ///
+ /// Provides a reference to the assembly generated during script compilation.
+ ///
+ public Assembly CompiledAssembly { get; set; }
+
+ ///
+ /// The compiler that will be used when the contents of ScriptRepository are compiled.
+ ///
+ protected String Compiler { get; set; }
+
+ ///
+ /// Used to supply compiling options to various compilers if they support this feature.
+ ///
+ protected Dictionary CompilerOptions { get; set; }
+
+ ///
+ /// Used to check if the compilation contained any errors.
+ ///
+ public Boolean HasErrors { get; internal set; }
+
+ ///
+ /// String of errors that occurred during compilation, if any.
+ ///
+ public String Errors
+ {
+ get
+ {
+ if (_CompileMessages.Length == 0)
+ return "No Errors.";
+ else
+ {
+ StringBuilder builder = new StringBuilder();
+ foreach (String error in _CompileMessages)
+ {
+ builder.AppendLine(error);
+ }
+
+ return builder.ToString();
+ }
+ }
+ }
+
+ //Messages stored from the compilers CompilerResults property.
+ private String[] _CompileMessages;
+
+ //Returns all of the assemblies currently loaded in the current domain.
+ private Assembly[] _Assemblies
+ {
+ get
+ {
+ return AppDomain.CurrentDomain.GetAssemblies();
+ }
+ }
+
+ public ScriptSystem() : this(".cs")
+ {
+ //Passes defaults off to the parameterized constructor.
+ }
+
+ public ScriptSystem(String scriptExtensions)
+ {
+ _CompileMessages = new String[] { "No compiler messages available." };
+
+ CompilerOptions = new Dictionary();
+ Compiler = "MudCompiler";
+
+ AssemblyReferences = new List();
+ AssemblyReferences.Add("mscorlib.dll");
+ AssemblyReferences.Add("System.dll");
+ AssemblyReferences.Add("System.Core.dll");
+
+ ScriptExtension = scriptExtensions;
+ }
+
+ ///
+ /// Adds a reference to the supplied Assembly name to the compilers reference collection.
+ ///
+ ///
+ public void AddAssemblyReference(String assembly)
+ {
+ if (!AssemblyReferences.Contains(assembly))
+ AssemblyReferences.Add(assembly);
+ }
+
+ ///
+ /// Adds a reference to the supplied Assembly to the compilers reference collection.
+ ///
+ ///
+ public void AddAssemblyReference(Assembly assembly)
+ {
+ if (!AssemblyReferences.Contains(assembly.GetName().Name))
+ AssemblyReferences.Add(assembly.GetName().Name);
+ }
+
+ ///
+ /// Removes the supplied assembly from the compilers reference collection.
+ ///
+ ///
+ public void RemoveAssemblyReference(String assembly)
+ {
+ if (AssemblyReferences.Contains(assembly))
+ AssemblyReferences.Remove(assembly);
+ }
+
+ ///
+ /// Clears the compilers reference collection, leaving it empty.
+ ///
+ public void ClearAssemblyReference()
+ {
+ AssemblyReferences.Clear();
+ }
+
+ ///
+ /// Compiles the scripts found within the CompileEngine.ScriptRepository directory that match the CompileEngine.ScriptExtension file extension.
+ /// The compiler will compile the scripts using the compiler specified with the CompileEngine.Compiler Property.
+ ///
+ /// Returns true if compilation was completed without any errors.
+ public Boolean Compile(String scriptRepository)
+ {
+ //Get the compiler that the developer has selected.
+ //If the developer chooses a compiler that is not part of the engine, the GetCompiler() method
+ //will check all the currently loaded assemblies in memory for a custom compiler implementing
+ //the ICompiler interface.
+ Type compiler = GetCompiler();
+
+ //Incase a non-default compiler was specified and we could not find it in memory, fail.
+ if (compiler.Name == "ICompiler")
+ {
+ this._CompileMessages = new string[] { "Compilation Failed.", "Unable to locate the specified compiler of Type '" + Compiler + "'." };
+ return false;
+ }
+
+ //Get the compiler parameters.
+ CompilerParameters param = GetParameters();
+
+ //Create a Instance of the compiler, either custom or internal.
+ ICompiler com = (ICompiler)Activator.CreateInstance(compiler);
+
+ //Setup it's properties to match that of our CompileEngine.
+ com.AssemblyReferences = AssemblyReferences;
+ com.ScriptExtension = ScriptExtension;
+ com.CompilerOptions = this.CompilerOptions;
+
+ //Compile the scripts.
+ Boolean isSuccess = com.Compile(param, scriptRepository);
+ HasErrors = !isSuccess;
+
+ //If the compilation failed, store all of the compiler errors
+ //into our _CompileMessages string.
+ if (!isSuccess)
+ {
+ List compilerMessages = new List();
+ foreach (String message in com.Results.Output)
+ {
+ compilerMessages.Add(message);
+ }
+
+ _CompileMessages = compilerMessages.ToArray();
+ return false;
+ }
+ else
+ {
+ //Compiling completed without error, so we need to save
+ //a reference to the compiled assembly.
+ CompiledAssembly = com.Results.CompiledAssembly;
+ return true;
+ }
+ }
+
+ ///
+ /// Compiles the script supplied.
+ /// The compiler will compile the script using the compiler specified with the CompileEngine.Compiler Property.
+ ///
+ /// Returns true if compilation was completed without any errors.
+ public Boolean Compile(FileInfo sourceFile)
+ {
+ if (!sourceFile.Exists)
+ {
+ this._CompileMessages = new String[] { "Error: File " + sourceFile.FullName + " does not exists." };
+ return false;
+ }
+
+ //Get the compiler that the developer has selected.
+ //If the developer chooses a compiler that is not part of the engine, the GetCompiler() method
+ //will check all the currently loaded assemblies in memory for a custom compiler implementing
+ //the ICompiler interface.
+ Type compiler = GetCompiler();
+
+ //Incase a non-default compiler was specified and we could not find it in memory, fail.
+ if (compiler.Name == "ICompiler")
+ {
+ this._CompileMessages = new string[] { "Compilation Failed.", "Unable to locate the specified compiler of Type '" + Compiler + "'." };
+ return false;
+ }
+
+ //Get the compiler parameters.
+ CompilerParameters param = GetParameters();
+
+ //Create a Instance of the compiler, either custom or internal.
+ ICompiler com = (ICompiler)Activator.CreateInstance(compiler);
+
+ //Setup it's properties to match that of our CompileEngine.
+ com.AssemblyReferences = AssemblyReferences;
+ com.ScriptExtension = ScriptExtension;
+ com.CompilerOptions = this.CompilerOptions;
+
+ //Compile the script.
+ Boolean isSuccess = com.Compile(param, sourceFile);
+ HasErrors = !isSuccess;
+
+ //If the compilation failed, store all of the compiler errors
+ //into our _CompileMessages string.
+ if (!isSuccess)
+ {
+ List compilerMessages = new List();
+ foreach (String message in com.Results.Output)
+ {
+ compilerMessages.Add(message);
+ }
+
+ _CompileMessages = compilerMessages.ToArray();
+ return false;
+ }
+ else
+ {
+ //Compiling completed without error, so we need to save
+ //a reference to the compiled assembly.
+ CompiledAssembly = com.Results.CompiledAssembly;
+ return true;
+ }
+ }
+
+ ///
+ /// Compiles the source code provided.
+ /// The compiler will compile the scripts using the compiler specified with the CompileEngine.Compiler Property.
+ ///
+ /// Returns true if compilation was completed without any errors.
+ public Boolean Compile(String[] sourceCode)
+ {
+ //Get the compiler that the developer has selected.
+ //If the developer chooses a compiler that is not part of the engine, the GetCompiler() method
+ //will check all the currently loaded assemblies in memory for a custom compiler implementing
+ //the ICompiler interface.
+ Type compiler = GetCompiler();
+
+ //Incase a non-default compiler was specified and we could not find it in memory, fail.
+ if (compiler.Name == "ICompiler")
+ {
+ this._CompileMessages = new string[] { "Compilation Failed.", "Unable to locate the specified compiler of Type '" + Compiler + "'." };
+ return false;
+ }
+
+ //Get the compiler parameters.
+ CompilerParameters param = GetParameters();
+
+ //Create a Instance of the compiler, either custom or internal.
+ ICompiler com = (ICompiler)Activator.CreateInstance(compiler);
+
+ //Setup it's properties to match that of our CompileEngine.
+ com.AssemblyReferences = AssemblyReferences;
+ com.ScriptExtension = ScriptExtension;
+ com.CompilerOptions = this.CompilerOptions;
+
+ //Compile the scripts.
+ Boolean isSuccess = com.Compile(param, sourceCode);
+ HasErrors = !isSuccess;
+
+ //If the compilation failed, store all of the compiler errors
+ //into our _CompileMessages string.
+ if (!isSuccess)
+ {
+ List compilerMessages = new List();
+ foreach (String message in com.Results.Output)
+ {
+ compilerMessages.Add(message);
+ }
+
+ _CompileMessages = compilerMessages.ToArray();
+ return false;
+ }
+ else
+ {
+ //Compiling completed without error, so we need to save
+ //a reference to the compiled assembly.
+ CompiledAssembly = com.Results.CompiledAssembly;
+ return true;
+ }
+ }
+
+ ///
+ /// Gets compiler parameters that the compiler will be supplied with.
+ ///
+ ///
+ private CompilerParameters GetParameters()
+ {
+ //Setup some default parameters that will be used by the compilers.
+ CompilerParameters param = new CompilerParameters(this.AssemblyReferences.ToArray());
+ param.GenerateExecutable = false;
+ param.GenerateInMemory = true;
+
+ //Left out, Add as CompileEngine properties in the future.
+ //param.TreatWarningsAsErrors = true;
+ //param.WarningLevel = 0;
+ //param.IncludeDebugInformation = true;
+ return param;
+ }
+
+ ///
+ /// Gets the compiler that will be used during the compilation of the scripts.
+ /// If a custom compiler is used, then the method will check every assembly in memory
+ /// and find the custom one requested. If none are found, then it will return a new
+ /// Object of type ICompiler.
+ ///
+ ///
+ private Type GetCompiler()
+ {
+ Type compiler = typeof(ICompiler);
+
+ //Internal CSharpRaw compiler Type specified, so we'll use that.
+ if ((this.Compiler.ToLower() == "MudCompiler") || (this.Compiler.ToLower() == "mc"))
+ {
+ compiler = typeof(MudCompiler);
+ return compiler;
+ }
+ //Build a collection of available compilers by scanning all the assemblies loaded in memory.
+ //If any of the assemblies contain a Type that uses the ICompiler interface, we will assume that the
+ //assembly is a add-on assembly for rScript, adding a new compiler to the CompileEngine.
+ //Only used if a non-internal compiler is specified
+ else
+ { //Non-internal compiler supplied, so loop through every assembly loaded in memory
+ foreach (Assembly a in _Assemblies)
+ {
+ Boolean isCompiler = false;
+
+ //Create an array of all Types within this assembly
+ Type[] types = a.GetTypes();
+
+ //Itterate through each Type; See if any implement the ICompiler interface.
+ foreach (Type t in a.GetTypes())
+ {
+ //If this Type implements ICompiler, then our compiler field needs to reference the Type.
+ if ((t.GetInterface("ICompiler") != null) && (t.Name.ToLower() == Compiler.ToLower()))
+ {
+ //compiler needs to reference this custom compiler Type.
+ compiler = t;
+ isCompiler = true;
+ break;
+ }
+ }
+
+ //If we found a matching compiler, then exit this loop.
+ if (isCompiler)
+ break;
+ }
+ }
+
+
+ return compiler;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MudEngine/World/Door.cs b/MudEngine/World/Door.cs
new file mode 100644
index 0000000..7117a3c
--- /dev/null
+++ b/MudEngine/World/Door.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+
+using MudEngine.Core;
+
+namespace MudEngine.World
+{
+ public class Door
+ {
+ ///
+ /// Gets or Sets if this doorway is locked, requiring a key to enter.
+ ///
+ [Category("Door Settings")]
+ [DefaultValue(false)]
+ public bool IsLocked { get; set; }
+
+ ///
+ /// Gets or Sets what item is required to travel through this doorway if IsLocked
+ ///
+ [Category("Door Settings")]
+ [Browsable(false)]
+ public BaseItem RequiredKey { get; set; }
+
+ ///
+ /// Gets or Sets the minimum level a character must be in order to travel through this doorway
+ ///
+ [Category("Door Settings")]
+ [DefaultValue(0)]
+ public int LevelRequirement { get; set; }
+
+ ///
+ /// Gets or Sets the direction a character must travel in order to move through this doorway
+ ///
+ [Category("Door Settings")]
+ public AvailableTravelDirections TravelDirection { get; set; }
+
+ ///
+ /// Gets or Sets the Room that the player will be arriving.
+ ///
+ public Room ArrivalRoom { get; set; }
+
+ ///
+ /// Gets or Sets the Room that the user is leaving.
+ ///
+ public Room DepartureRoom { get; set; }
+ }
+
+}
diff --git a/MudEngine/World/Room.cs b/MudEngine/World/Room.cs
new file mode 100644
index 0000000..22d9c49
--- /dev/null
+++ b/MudEngine/World/Room.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using MudEngine.Core;
+
+namespace MudEngine.World
+{
+ public class Room : BaseEnvironment
+ {
+ ///
+ /// Gets or Sets the type of terrain that this room contains.
+ ///
+ public TerrainTypes Terrain { get; set; }
+
+ ///
+ /// Gets a reference to the collection of doorways present within this room
+ ///
+ public List Doorways { get; private set; }
+
+ public Room(BaseGame game) : base(game)
+ {
+ Doorways = new List();
+ }
+
+ ///
+ /// Installs a doorway into the room. Multiple doorways for the same travel direction is not allowed.
+ ///
+ ///
+ ///
+ public bool InstallDoor(Door door)
+ {
+ //Anonymous method to check if a door already exists for the travel direction supplied.
+ Door dr = Doorways.Find(delegate(Door d)
+ {
+ return d.TravelDirection == door.TravelDirection;
+ }
+ );
+
+ if (dr != null)
+ return false;
+
+ Doorways.Add(door);
+ return true;
+ }
+
+ ///
+ /// Removes a doorway from the room.
+ ///
+ ///
+ public void RemoveDoor(AvailableTravelDirections travelDirection)
+ {
+ Door dr = Doorways.Find(delegate(Door d)
+ {
+ return d.TravelDirection == travelDirection;
+ }
+ );
+
+ if (dr != null)
+ Doorways.Remove(dr);
+ }
+
+ ///
+ /// Checks to see if a doorway exists for the supplied travel direction.
+ ///
+ ///
+ ///
+ public bool DoorwayExists(AvailableTravelDirections travelDirection)
+ {
+ return Doorways.Exists(d => d.TravelDirection == travelDirection);
+ }
+
+ ///
+ /// Returns a reference to an installed doorway, for the supplied travel direction.
+ ///
+ ///
+ ///
+ public Door GetDoorway(AvailableTravelDirections travelDirection)
+ {
+ return Doorways.Find(d => d.TravelDirection == travelDirection);
+ }
+ }
+}
diff --git a/MudEngine/World/TerrainType.cs b/MudEngine/World/TerrainType.cs
new file mode 100644
index 0000000..af514a2
--- /dev/null
+++ b/MudEngine/World/TerrainType.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MudEngine.World
+{
+ public enum TerrainTypes
+ {
+ Stone,
+ Dirt,
+ Grass,
+ Rock,
+ Wood,
+ Water,
+ Air,
+ Mud,
+ Other,
+ }
+}
diff --git a/MudEngine/World/TravelDirections.cs b/MudEngine/World/TravelDirections.cs
new file mode 100644
index 0000000..9ea7361
--- /dev/null
+++ b/MudEngine/World/TravelDirections.cs
@@ -0,0 +1,67 @@
+using System;
+
+namespace MudEngine.World
+{
+ [System.Flags]
+ public enum AvailableTravelDirections : uint
+ {
+ None = 0,
+ North = 1,
+ South = 2,
+ East = 4,
+ West = 8,
+ Up = 16,
+ Down = 32,
+ Northeast = North | East,
+ Northwest = North | West,
+ Southeast = South | East,
+ Southwest = South | West
+ }
+
+ public static class TravelDirections
+ {
+ public static AvailableTravelDirections GetReverseDirection(AvailableTravelDirections Direction)
+ {
+ switch (Direction)
+ {
+ case AvailableTravelDirections.North:
+ return AvailableTravelDirections.South;
+ case AvailableTravelDirections.South:
+ return AvailableTravelDirections.North;
+ case AvailableTravelDirections.East:
+ return AvailableTravelDirections.West;
+ case AvailableTravelDirections.West:
+ return AvailableTravelDirections.East;
+ case AvailableTravelDirections.Up:
+ return AvailableTravelDirections.Down;
+ case AvailableTravelDirections.Down:
+ return AvailableTravelDirections.Up;
+ case AvailableTravelDirections.Northeast:
+ return AvailableTravelDirections.Southwest;
+ case AvailableTravelDirections.Southwest:
+ return AvailableTravelDirections.Northeast;
+ case AvailableTravelDirections.Northwest:
+ return AvailableTravelDirections.Southeast;
+ case AvailableTravelDirections.Southeast:
+ return AvailableTravelDirections.Northwest;
+ default:
+ return AvailableTravelDirections.None;
+ }
+ }
+
+ public static AvailableTravelDirections GetTravelDirectionValue(String Direction)
+ {
+ Array values = Enum.GetValues(typeof(AvailableTravelDirections));
+
+ foreach (Int32 value in values)
+ {
+ String displayName = Enum.GetName(typeof(AvailableTravelDirections), value);
+
+ if (displayName.ToLower() == Direction.ToLower())
+ return (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), displayName);
+ }
+
+ return AvailableTravelDirections.None;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MudEngine/World/Zone.cs b/MudEngine/World/Zone.cs
new file mode 100644
index 0000000..a92dc73
--- /dev/null
+++ b/MudEngine/World/Zone.cs
@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using MudEngine.Core;
+
+namespace MudEngine.World
+{
+ public class Zone : BaseEnvironment
+ {
+ ///
+ /// Gets a reference to the Room collection for this zone
+ ///
+ public List Rooms { get; private set; }
+
+ public Zone(BaseGame game)
+ : base(game)
+ {
+ Rooms = new List();
+ }
+
+ ///
+ /// Installs a Room into this Zone, if the Room does not already exists.
+ ///
+ ///
+ ///
+ public bool InstallRoom(Room room)
+ {
+ Room rm = Rooms.Find(delegate(Room r)
+ {
+ return r.ID == room.ID;
+ }
+ );
+
+ if (rm != null)
+ return false;
+
+ Rooms.Add(room);
+ return true;
+ }
+
+ ///
+ /// Returns a reference to a room matching the supplied name
+ ///
+ ///
+ ///
+ public Room GetRoom(string name)
+ {
+ return Rooms.Find(r => r.Name == name);
+ }
+
+ ///
+ /// Returns a reference to a room matching the supplied id.
+ ///
+ ///
+ ///
+ public Room GetRoom(int id)
+ {
+ return Rooms.Find(r => r.ID == id);
+ }
+
+ ///
+ /// Checks if the specified Room exists within this zone.
+ ///
+ ///
+ ///
+ public bool RoomExists(Room room)
+ {
+ return Rooms.Exists(r => r.ID == room.ID);
+ }
+
+ ///
+ /// Checks if the specified ID exists within this zone.
+ ///
+ ///
+ ///
+ public bool RoomExists(int id)
+ {
+ return Rooms.Exists(r => r.ID == id);
+ }
+
+ ///
+ /// Replaces a room matching the oldID argument with the supplied newRoom.
+ ///
+ ///
+ ///
+ public bool ReplaceRoom(Room newRoom, int oldID)
+ {
+ if (!RoomExists(oldID))
+ return false;
+
+ Room rm = Rooms.Find(delegate(Room r)
+ {
+ return r.ID == oldID;
+ }
+ );
+
+ if (rm == null)
+ return false;
+
+ Rooms.Remove(rm);
+ Rooms.Add(newRoom);
+
+ return false;
+ }
+ }
+}
diff --git a/MudGame/MudGame.csproj b/MudGame/MudGame.csproj
index f0a7d25..71f072d 100644
--- a/MudGame/MudGame.csproj
+++ b/MudGame/MudGame.csproj
@@ -112,10 +112,6 @@
{498943A8-DF5A-4DB0-B506-0BFF44788657}
MudEngine
-
- {BC1B32DA-7209-4B32-8171-A190EF21F5D6}
- rScripting
-