11using System ;
22using System . IO ;
3+ using System . Reflection ;
34using MelonLoader ;
45
56[ assembly: MelonInfo ( typeof ( S1APILoader . S1APILoader ) , "S1APILoader" , "{VERSION_NUMBER}" , "KaBooMa" ) ]
@@ -12,24 +13,25 @@ public class S1APILoader : MelonPlugin
1213
1314 public override void OnPreModsLoaded ( )
1415 {
15- string ? pluginsFolder = Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . Location ) ;
16+ string ? pluginsFolder = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
1617 if ( pluginsFolder == null )
1718 throw new Exception ( "Failed to identify plugins folder." ) ;
1819
19- string gameFolder = Path . Combine ( pluginsFolder , ".." ) ;
20- string modsFolder = Path . Combine ( gameFolder , "Mods" ) ;
21-
2220 string buildsFolder = Path . Combine ( pluginsFolder , BuildFolderName ) ;
2321
2422 string activeBuild = MelonUtils . IsGameIl2Cpp ( ) ? "Il2Cpp" : "Mono" ;
2523 MelonLogger . Msg ( $ "Loading S1API for { activeBuild } ...") ;
2624
2725 string s1APIBuildFile = Path . Combine ( buildsFolder , $ "S1API.{ activeBuild } .dll") ;
28-
2926
30- string s1APIModFile = Path . Combine ( modsFolder , "S1API.dll" ) ;
27+ // FIX: https://github.com/KaBooMa/S1API/issues/30
28+ // Manual assembly loading versus file manipulation.
29+ // Thunderstore doesn't pick it up if we do file manipulation.
30+ Assembly assembly = Assembly . LoadFile ( s1APIBuildFile ) ;
31+ MelonAssembly melonAssembly = MelonAssembly . LoadMelonAssembly ( s1APIBuildFile , assembly ) ;
32+ foreach ( MelonBase melon in melonAssembly . LoadedMelons )
33+ melon . Register ( ) ;
3134
32- File . Copy ( s1APIBuildFile , s1APIModFile , true ) ;
3335 MelonLogger . Msg ( $ "Successfully loaded S1API for { activeBuild } !") ;
3436 }
3537 }
0 commit comments