Patching code into BRUTAL

Plazma

Member
Messages
37
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.
 
I'm pretty sure .ddl and .exe are windows specific file types. With how BRUTAL works right now, they'll probably have to find a way on how to do this for every platform BRUTAL supports right now
 
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.
This is basically how StarMap works, and while it was created for KSA and has some KSA specific functions in it, the general way to load the mods is not very specific, just load each mod in its own ALC, find a class that has a specific attribute, create it and then call an initial function. Then the mod can do whatever it wants (mostly harmony patches at the moment.
 
I'm pretty sure .ddl and .exe are windows specific file types. With how BRUTAL works right now, they'll probably have to find a way on how to do this for every platform BRUTAL supports right now
AssemblyLoadContext which was mentioned earlier is the platform-agnostic way of doing this in dotnet. It works very well everywhere, so we don't have to worry about that part luckily.
 
Back
Top