I'm writing a particle system. (for a game and a particle editor) In this system there are a 0 to n modifiers. Those modify the particles in the particle system every frame.
For example you could have a predefined modifier called "GravityModifier" that only does the following to every particle every frame: "particle.Velocity.Y += 9.81" or something like that.
Now I want the user to be able to write additional modifiers at runtime (in the editor). I would like to be able to just use C# for this. And since the particle systems are written to JSON files, the custom modifier scripts should be written as sourcecode (maybe base64 encoded) to the file.
--
My question is: Assume the game wants to load such a particle system file. How do I compile the custom modifiers into executable code?
Another very important thing to consider when answering this question: Note that this will be a particle system for a game. The compiled code will be called more than 3000 times every frame. (mostly at 60fps) So it's very important that the compiled code doesn't take much longer to execute than other game-functions. It would be nice to have the modifier scripts compiled into delegates of the form: delegate void ModifyParticle(ref Particle p);
Is this possible? If so, how?
Eclipse. It is one of the most popular, powerful and useful IDEs used by developers for C/C++ programming. It is open-source software which is simple and easy to use.
So C always uses top down approach, whereas C++ also uses bottom up approach. Because we use main function in c++ at anywhere but the compiler starts to compile the program in main function so it is called as bottom up approach.
Though there are many compilers available for C, GCC stands out to be one of the best as of now. The winner declaration here lies based on durability, optimization, speed, and code/error/syntax checks. Through this, we can clearly understand that the Compiler is an important pillar to the programming languages.
There is a CTP of the 'Roslyn' C# compiler as a service API, where you can execute C# code defined at runtime, such as a REPL etc. Here is an MSDN Article covering it
http://visualstudiomagazine.com/articles/2011/11/16/the-roslyn-scripting-api.aspx
Mono has had this functionality for a while in their Mono.CSharp library so that could be used as an alternative.
Yes,
This is possible and quite simple using the CSScript library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With