Reputation: 43
I making a simple game engine with C# (in VB 2008, mostly for myself). There is a main application which does the graphics and stuff, and most of the data from the actually game will be in a dll generated with the tools I would give to the game designer.
I've heard a lot about C# being great for scripting, (and it looks like it would suit my needs better than any other way) but I can't really find an answer of exactly how it's done. I ran into this problem:
I obviously don't want to give out my source code for the main exe but it will contain all the main methods needed for scripting (because they act on the main exe).
How could a dll be generated when it doesn't have a definition of the methods it will be calling in the parent exe? The main exe will have the dll as a dependency to use it. That means that the dll can't have a dependency on the exe which would cause a loop.
I could create another dll that both the exe and the library would use, but then the methods in there wouldn't be able to act directly on the main exe using it.
The only logical solution I came up with is this:
This doesn't seem too elegant though.
I've seen a lot of words in my research (MAF, MEF, Roslyn, etc.) before I got too tired to read further. I have spent several hours on this alone.
In your opinion, how should I go about doing this? Is there something I'm overlooking?
Upvotes: 2
Views: 290
Reputation: 19117
It's sounds like you're mixing up extensibility through dlls and extensibility through scripting.
Let's take the dll approach first.
The standard way to implement this is quite close to what you've outlined:
interfaces.dll
interfaces.dll
interfaces.dll
interfaces.dll
, invoke the methods as needed.For scripting, you'll typically want to use a scripting language - powershell is popular for .Net, and there are also some experiments with JavaScript
Upvotes: 0
Reputation: 25705
I don't know where you heard C# is 'great' for scripting. The half-baked attempt of Rosyln is not really "scripting".
Why not try one of those DLR languages - like IronPython and IronRuby?
Also there is Lua binding for .NET.. Most game developers these days do their scripting in Lua. So the modder community will definitely love your Game Engine, if you plan to keep it closed source.
Upvotes: 1