diff --git a/MudEngine/GameManagement/GameWorld.cs b/MudEngine/GameManagement/GameWorld.cs
index 69bb3e6..10cdcbb 100644
--- a/MudEngine/GameManagement/GameWorld.cs
+++ b/MudEngine/GameManagement/GameWorld.cs
@@ -121,11 +121,62 @@ namespace MudEngine.GameManagement
}
}
+ ///
+ /// Adds a object to the game world. Any Game Object can be supplied as a parameter.
+ ///
+ ///
+ public Boolean AddObject(dynamic worldObject)
+ {
+ //Check if this object is a Realm
+ if (worldObject is Realm)
+ {
+ ///Add it to the Worlds Realm collection
+ this.RealmCollection.Add(worldObject);
+ }
+ //Check if this object is a Zone
+ else if (worldObject is Zone)
+ {
+ //Query the Realm collection to find the Realm this Zone belongs to.
+ var realmQuery =
+ from r in RealmCollection
+ where r.Filename == worldObject.Realm
+ select r;
+ //Add the zone to the Realm we found
+ if (realmQuery.FirstOrDefault() != null)
+ realmQuery.FirstOrDefault().AddZone(worldObject);
+ else
+ {
+ Log.Write("Error: Attempted to add Zone " + worldObject.Filename + " to a unspecified Realm.");
+ return false;
+ }
+ }
+ else if (worldObject is Room)
+ {
+ var realmQuery =
+ from r in RealmCollection
+ where r.Filename == worldObject.Realm
+ select r;
+ var zoneQuery =
+ from z in realmQuery.FirstOrDefault().ZoneCollection
+ where z.Filename == worldObject.Zone
+ select z;
+ if (zoneQuery.FirstOrDefault() != null)
+ zoneQuery.FirstOrDefault().AddRoom(worldObject);
+ else
+ {
+ Log.Write("Error: Attempted to add Room " + worldObject.Filename + " to a unspecified Realm and/or Zone");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
///
/// Adds a Realm to the Games current list of Realms.
///
///
- public void AddRealm(Realm realm)
+ private void AddRealm(Realm realm)
{
//If this Realm is set as Initial then we need to disable any previously
//set Realms to avoid conflict.
diff --git a/MudEngine/MudEngine.csproj b/MudEngine/MudEngine.csproj
index 895865e..bfbcc53 100644
--- a/MudEngine/MudEngine.csproj
+++ b/MudEngine/MudEngine.csproj
@@ -77,6 +77,7 @@
+
diff --git a/MudGame/Program.cs b/MudGame/Program.cs
index 26d9ea4..34aafe2 100644
--- a/MudGame/Program.cs
+++ b/MudGame/Program.cs
@@ -15,10 +15,11 @@ namespace MudGame
static class Program
{
const String SettingsFile = "Settings.ini";
- static Game game;
-
+
static void Main(String[] args)
{
+ dynamic game = new Game();
+
//Re-create the settings file if it is missing. Don't push any log messages until we know that this is
//verbose or not
Log.Write("Loading Settings...", false);
diff --git a/MudGame/Scripts/CommandCreate.cs b/MudGame/Scripts/CommandCreate.cs
index b830c39..dfcc53e 100644
--- a/MudGame/Scripts/CommandCreate.cs
+++ b/MudGame/Scripts/CommandCreate.cs
@@ -102,7 +102,7 @@
}
}
- player.ActiveGame.World.AddRealm(realm);
+ player.ActiveGame.World.AddObject(realm);
Log.Write(player.Name + " has created a Realm called " + realm.Name);
player.Send(realm.Name + " has been created and added to the world.");
}
diff --git a/MudGame/Scripts/WorldCalifornia.cs b/MudGame/Scripts/WorldCalifornia.cs
index 0e47cc6..1c76d2f 100644
--- a/MudGame/Scripts/WorldCalifornia.cs
+++ b/MudGame/Scripts/WorldCalifornia.cs
@@ -14,7 +14,7 @@ public class WorldCalifornia
myRealm.Name = "California";
myRealm.Description = "The Beaches of California are relaxing and fun to be at.";
myRealm.IsInitialRealm = true;
- _Game.World.AddRealm(myRealm);
+ _Game.World.AddObject(myRealm);
Zone myZone = new Zone(_Game);
myZone.Name = "San Diego";
diff --git a/MudGame/bin/Debug/Scripts/WorldCalifornia.cs b/MudGame/bin/Debug/Scripts/WorldCalifornia.cs
index 0e47cc6..1c76d2f 100644
--- a/MudGame/bin/Debug/Scripts/WorldCalifornia.cs
+++ b/MudGame/bin/Debug/Scripts/WorldCalifornia.cs
@@ -14,7 +14,7 @@ public class WorldCalifornia
myRealm.Name = "California";
myRealm.Description = "The Beaches of California are relaxing and fun to be at.";
myRealm.IsInitialRealm = true;
- _Game.World.AddRealm(myRealm);
+ _Game.World.AddObject(myRealm);
Zone myZone = new Zone(_Game);
myZone.Name = "San Diego";