Blit Script Updates
I spent some time this morning working on converting the Blit Script Engine from .NET 3.5 and XNA 3.0 to .NET 4.0 and XNA 4.0. The project was moved into Visual Studio 2010 Express and now supports Dynamic Types which is really nice.
Now instead of being forced to Explicitly Convert a Type, developers can access the Type dynamically during runtime.
The previous version required the following lines of code to change a Property and invoke the scripts method.
//Assign a value to the scripts Name property engine.GetObject("Player").SetProperty("Name", "Billy Bob"); //Get the property value from the object and assign it to the window title. string bulletSize = (string)engine.GetObject("Player").GetProperty("Name"); //Invoking methods can be performed using an explicit Type conversion bool temp = (bool)engine.GetObject("Player").InvokeMethod("IsColliding", null); if (temp) Window.Title = "Invoke Method Completed without error!";
However, now with .NET 4.0 and the latest version of Blit Script, developers can access properties and invoke methods without needing to perform any conversions.
//Supports .NET 4.0 Dynamic Types; Use this for nested Property access. engine.GetObject("Player").SetProperty().Name = "Bob"; string bulletSize = engine.GetObject("Player").GetProperty().Weapon.Bullet.Size; //Or you can invoke a method using a Dynamic Type (.NET 4.0 only) dynamic d = engine.GetObject("Player").InvokeMethod("IsColliding", null); if (d) Window.Title = "Invoke Method completed without error!";
As you can see from the two examples, developers no longer need to do any conversions, and using the supported Dynamic Type, allows them to just reference their scripts from within their engine as if it was a class contained within the engine already.
Both forms of property management is supported with the latest version of the Blit Source, however Dynamic Type support was not implemented when I released 1.0, but it will be supported in the next release.