]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Map.cs
SaberMonster loads from map file and walks around using the path finder, and a lot...
[chaz/carfire] / CarFire / CarFire / CarFire / Map.cs
index 93dc5ef6ba181c1f678298bf79015a0c62d6c118..8c744bad3e8a96962288d966ea47c991911d099a 100644 (file)
@@ -166,6 +166,16 @@ namespace CarFire
             set { mView.Zoom = value; }\r
         }\r
 \r
+\r
+        /// <summary>\r
+        /// Get and set the associated game object.\r
+        /// </summary>\r
+        public Game Game\r
+        {\r
+            get { return mData.Game; }\r
+            set { mData.Game = value; }\r
+        }\r
+\r
         #endregion\r
 \r
 \r
@@ -278,7 +288,7 @@ namespace CarFire
         /// thrown if there are entities without associated classes.\r
         /// </summary>\r
         /// <returns>List of entity objects loaded.</returns>\r
-        public List<object> GetAllEntities()\r
+        public List<IEntity> GetAllEntities()\r
         {\r
             return mData.GetAllEntities();\r
         }\r
@@ -358,6 +368,8 @@ namespace CarFire
             public Point[] PlayerPositions { get { return mPlayerPositions; } }\r
             public bool[,] Grid { get { return mBooleanGrid; } }\r
 \r
+            public Game Game;\r
+\r
 \r
             public Model(Metadata metadata, char[,] grid, char defaultTile,\r
                 List<RawEntity> entities, Point[] playerPositions)\r
@@ -426,9 +438,9 @@ namespace CarFire
             }\r
 \r
 \r
-            public List<object> GetAllEntities()\r
+            public List<IEntity> GetAllEntities()\r
             {\r
-                List<object> list = new List<object>();\r
+                List<IEntity> list = new List<IEntity>();\r
 \r
                 foreach (RawEntity raw in mEntities)\r
                 {\r
@@ -436,16 +448,20 @@ namespace CarFire
                     {\r
                         string typename = raw.Attributes["type"];\r
 \r
-                        object[] args = new object[3];\r
+                        object[] args = new object[4];\r
                         args[0] = raw.Id;\r
                         args[1] = raw.Position;\r
                         args[2] = raw.Attributes;\r
+                        args[3] = Game;\r
 \r
                         try\r
                         {\r
-\r
-                            object entity = Activator.CreateInstance(System.Type.GetType("CarFire." + typename), args);\r
-                            if (entity != null) list.Add(entity);\r
+                            IEntity entity = (IEntity)Activator.CreateInstance(System.Type.GetType("CarFire." + typename), args);\r
+                            if (entity != null)\r
+                            {\r
+                                entity.LoadContent(Game.ContentManager);\r
+                                list.Add(entity);\r
+                            }\r
                             else throw new RuntimeException();\r
                         }\r
 #pragma warning disable 0168\r
@@ -474,13 +490,18 @@ namespace CarFire
                 {\r
                     if (raw.Attributes.ContainsKey("type") && typename == raw.Attributes["type"])\r
                     {\r
-                        object[] args = new object[3];\r
+                        object[] args = new object[4];\r
                         args[0] = raw.Id;\r
                         args[1] = raw.Position;\r
                         args[2] = raw.Attributes;\r
+                        args[3] = Game;\r
 \r
                         T entity = (T)Activator.CreateInstance(type, args);\r
-                        if (entity != null) list.Add(entity);\r
+                        if (entity != null)\r
+                        {\r
+                            ((IEntity)entity).LoadContent(Game.ContentManager);\r
+                            list.Add(entity);\r
+                        }\r
                         else throw new RuntimeException("Entity of type " + typename + " not loaded because an entity class can't be found.");\r
                     }\r
                 }\r
This page took 0.019939 seconds and 4 git commands to generate.