- Either you implement some sort of simplified scripting system with your own syntax and fitting your needs, that would receive the necessary context, parsing the expression and executing it accordingly.
Either you implement some sort of simplified scripting system with your own syntax and fitting your needs, that would receive the necessary context, parsing the expression and executing it accordingly.
This system would need to be able to handle a set of basic data types (int, float, string, boolean, Vector2, Vector3), would need to be able to access properties on the parent component (which would be translated to Reflection calls), and know how to perform the basic arithmetic operations between data types. I don't think this would be an easy task.
Or another alternative I can think about is maybe using C# runtime compilation (I talk a little about it here and show an example) and put C# code directly in the template.
Then you would go through the template file at load time and prepare/compile one method for each initialization entry, taking the parent entity as a parameter. This way you can put C# code directly in the template, which would be executed later when instantiating the entities. The biggest advantage is not having to create your own scripting language though.
This system would need to be able to handle a set of basic data types (int, float, string, boolean, Vector2, Vector3), would need to be able to access properties on the parent component (which would be translated to Reflection calls), and know how to perform the basic arithmetic operations between data types. I don't think this would be an easy task.
- Or another alternative I can think about is maybe using C# runtime compilation (I talk a little about it here and show an example) and put C# code directly in the template.
Then you would go through the template file at load time and prepare/compile one method for each initialization entry, taking the parent entity as a parameter. This way you can put C# code directly in the template, which would be executed later when instantiating the entities. The biggest advantage is not having to create your own scripting language though.