X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FScript.cs;fp=CarFire%2FCarFire%2FCarFire%2FScript.cs;h=0cf9dbdbd56c5e22e4145ed37a05506ac1cbaef6;hp=9676bbb83e62d07b36067d59d9f6dbdd4a137b16;hb=08f41ef45f3c41ca6302150bc6d5270c8e7143db;hpb=60d05271b295d2ca94a0028059add525c1bbffb1 diff --git a/CarFire/CarFire/CarFire/Script.cs b/CarFire/CarFire/CarFire/Script.cs index 9676bbb..0cf9dbd 100644 --- a/CarFire/CarFire/CarFire/Script.cs +++ b/CarFire/CarFire/CarFire/Script.cs @@ -30,9 +30,9 @@ namespace CarFire /// /// The script code. /// A game reference. - public Script(string code, Game game) + public Script(string code, object bindings) { - mImpl = new Impl(game); + mBindings = bindings; string[] functions = Parse.List(code); if (functions != null) @@ -87,6 +87,12 @@ namespace CarFire return result; } + public void Reset() + { + mIsRunning = false; + + } + #endregion @@ -106,7 +112,7 @@ namespace CarFire object[] args = new object[2]; args[0] = player; args[1] = mFunctions[index].Arguments; - return (bool)typeof(Impl).InvokeMember(mFunctions[index].Name, BindingFlags.InvokeMethod, null, null, args); + return (bool)mBindings.GetType().InvokeMember(mFunctions[index].Name, BindingFlags.InvokeMethod, null, mBindings, args); } #pragma warning disable 0168 catch (System.MissingMethodException ex) @@ -121,42 +127,6 @@ namespace CarFire #region Private Types - class Impl - { - public static bool True(Player player, string[] args) - { - return true; - } - - public static bool False(Player player, string[] args) - { - return false; - } - - public static bool Has(Player player, string[] args) - { - return false; - } - - public static bool Print(Player player, string[] args) - { - foreach (string arg in args) - { - string line = Parse.String(arg); - if (line != null) Console.WriteLine(line); - } - return true; - } - - - public Impl(Game game) - { - mGame = game; - } - - Game mGame; - } - class Function { public string Name { get { return mName; } } @@ -177,7 +147,7 @@ namespace CarFire #region Private Variables - Impl mImpl; + object mBindings; List mFunctions = new List(); bool mIsRunning; int mRunningIndex;