This PR allows users classes to be injected into assembly with the same name as their mod assembly, instead of InjectedMonoTypes.
There are two benefits from this:
Users can declare their assemblies in Unity Editor using asmdefs or use custom precompiled assemblies
Because types exist in the correct assembly according to il2cpp runtime, any code which checks assembly will work correctly. For example Burst runtime checks assembly name, so with this change adding custom Bursted code becomes possible.
The changes are backwards compatible. Despite the classes now being defined in the mod assembly, they will still correctly deserialize because we inject classes into every assembly that exists.
To implement this I had to determine a list of possible assemblies very early, so plugins folder scanning is performed.
Also I needed to modify contents of ScriptingAssemblies.json file in the game Data folder, because Unity seems to get a list of assemblies from there. A backup of original is created.
I have implemented IAT hooking, so no files are modified now.
Assembly scanning now should be performed by mod loader by adding AssemblyInjectorComponent.
I have tested these changes on Core Keeper Unity 2021.3.14.
This PR allows users classes to be injected into assembly with the same name as their mod assembly, instead of
InjectedMonoTypes
. There are two benefits from this:The changes are backwards compatible. Despite the classes now being defined in the mod assembly, they will still correctly deserialize because we inject classes into every assembly that exists.
To implement this I had to determine a list of possible assemblies very early, so plugins folder scanning is performed. Also I needed to modify contents ofScriptingAssemblies.json
file in the game Data folder, because Unity seems to get a list of assemblies from there. A backup of original is created.I have implemented IAT hooking, so no files are modified now. Assembly scanning now should be performed by mod loader by adding AssemblyInjectorComponent.
I have tested these changes on Core Keeper Unity 2021.3.14.