Patching code into BRUTAL

Plazma

Member
Messages
36
Reaction score
38
For KSA right now, we have to use external tools like StarMap to patch code into the game. Would it be possible to add something similar into BRUTAL?

Ideally, C# files could be created in a mod, then, on startup, is patched into the game (KSA.dll for reference). Realistically, .dll files could be merged and/or loaded into the game's .exe.

What are your thoughts on this? Have any good ideas on how we could do this?
 
I think a good way to do this would be to use AssemblyLoadContext and make the game simply load a list of DLLs or all DLLs in a path (such as "game_directory/Mods/").

The game can do this on startup and search for all classes that implement an interface such as `IMod` that has all the entry points a mod would need to interact with the game. This is essentially the DLL "injection" that you would traditionally do. The downside with this setup is that the game needs to support it from the start so it needs work from the dev.

We did a similar thing for a game I've worked on and it seemed to work well and even internally we separated our own game systems into these IMod entry points to separate the codebase.

Some extra info about how to use AssemblyLoadContext:
Feel free to ask if you have questions about this approach.
 
Back
Top