]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Script.cs
Implemented map tiles; started new Key entity; added missing variables to Melee.cs...
[chaz/carfire] / CarFire / CarFire / CarFire / Script.cs
index 146bb22685249cf7db7449c521a1cbe644aef819..9676bbb83e62d07b36067d59d9f6dbdd4a137b16 100644 (file)
@@ -7,10 +7,17 @@ using System.Diagnostics;
 \r
 namespace CarFire\r
 {\r
+    /// <summary>\r
+    /// The Script class handles the parsing and execution of lists\r
+    /// of functions.  Scripts are closely related to triggers.\r
+    /// </summary>\r
     public class Script\r
     {\r
         #region Public Properties\r
 \r
+        /// <summary>\r
+        /// Determine if the script is in the process of being run.\r
+        /// </summary>\r
         public bool IsRunning { get { return mIsRunning; } }\r
 \r
         #endregion\r
@@ -18,9 +25,14 @@ namespace CarFire
 \r
         #region Public Methods\r
 \r
+        /// <summary>\r
+        /// Construct a script object with code and a game reference.\r
+        /// </summary>\r
+        /// <param name="code">The script code.</param>\r
+        /// <param name="game">A game reference.</param>\r
         public Script(string code, Game game)\r
         {\r
-            mGame = game;\r
+            mImpl = new Impl(game);\r
 \r
             string[] functions = Parse.List(code);\r
             if (functions != null)\r
@@ -44,6 +56,17 @@ namespace CarFire
             else throw new Exception("Script could not be parsed: " + code);\r
         }\r
 \r
+        /// <summary>\r
+        /// Start execution of the script.  If there is no need to break\r
+        /// execution before the script ends, it will finish before this method\r
+        /// call ends.  Otherwise, execution will be delayed and will finish sometime\r
+        /// in the future.  This will execute each function in sequence as long\r
+        /// as each function evaluates to true.  If a function does not evaluate to true,\r
+        /// this method will return and execution will be delayed.  In either case,\r
+        /// the evaluation of the last function is returned by this method.\r
+        /// </summary>\r
+        /// <param name="player">The player associated with this script.</param>\r
+        /// <returns>Evaluation of the last function call.</returns>\r
         public bool Run(Player player)\r
         {\r
             bool result = false;\r
@@ -69,6 +92,12 @@ namespace CarFire
 \r
         #region Private Methods\r
 \r
+        /// <summary>\r
+        /// Call a function in the last at a certain index.\r
+        /// </summary>\r
+        /// <param name="index">The function index.</param>\r
+        /// <param name="player">The associated player object.</param>\r
+        /// <returns>The evaluation of the function.</returns>\r
         bool Call(int index, Player player)\r
         {\r
             Debug.Assert(0 <= index && index < mFunctions.Count);\r
@@ -118,6 +147,14 @@ namespace CarFire
                 }\r
                 return true;\r
             }\r
+\r
+\r
+            public Impl(Game game)\r
+            {\r
+                mGame = game;\r
+            }\r
+\r
+            Game mGame;\r
         }\r
 \r
         class Function\r
@@ -140,11 +177,10 @@ namespace CarFire
 \r
         #region Private Variables\r
 \r
-        Game mGame;\r
+        Impl mImpl;\r
         List<Function> mFunctions = new List<Function>();\r
         bool mIsRunning;\r
         int mRunningIndex;\r
-        Impl mImpl = new Impl();\r
 \r
         #endregion\r
     }\r
This page took 0.021433 seconds and 4 git commands to generate.