File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,10 @@ public void InitalizeAssemblies()
198198 {
199199 mod . InitializeAssembly ( ) ;
200200 }
201+ foreach ( var mod in Mods )
202+ {
203+ mod . InitializeComponents ( ) ;
204+ }
201205 Logger . Log ( "HAT" , "Assembly initialization completed!" ) ;
202206 }
203207
@@ -214,7 +218,7 @@ public void InitalizeComponents()
214218 {
215219 foreach ( var mod in Mods )
216220 {
217- mod . InitializeComponents ( ) ;
221+ mod . InjectComponents ( ) ;
218222 }
219223 Logger . Log ( "HAT" , "Component initialization completed!" ) ;
220224 }
Original file line number Diff line number Diff line change @@ -90,8 +90,21 @@ public void InitializeAssets()
9090 }
9191 }
9292
93- // injects custom components of this mod into the game
93+
9494 public void InitializeComponents ( )
95+ {
96+ if ( RawAssembly == null || Assembly == null ) return ;
97+
98+ foreach ( Type type in Assembly . GetExportedTypes ( ) )
99+ {
100+ if ( ! typeof ( IGameComponent ) . IsAssignableFrom ( type ) || ! type . IsPublic ) continue ;
101+ var gameComponent = ( IGameComponent ) Activator . CreateInstance ( type , new object [ ] { ModLoader . Game } ) ;
102+ Components . Add ( gameComponent ) ;
103+ }
104+ }
105+
106+ // injects custom components of this mod into the game
107+ public void InjectComponents ( )
95108 {
96109 // add game components
97110 foreach ( var component in Components )
@@ -102,17 +115,11 @@ public void InitializeComponents()
102115 }
103116 }
104117
118+ // loads mod's assemblies
105119 public void InitializeAssembly ( )
106120 {
107121 if ( RawAssembly == null ) return ;
108122 Assembly = Assembly . Load ( RawAssembly ) ;
109-
110- foreach ( Type type in Assembly . GetExportedTypes ( ) )
111- {
112- if ( ! typeof ( IGameComponent ) . IsAssignableFrom ( type ) || ! type . IsPublic ) continue ;
113- var gameComponent = ( IGameComponent ) Activator . CreateInstance ( type , new object [ ] { ModLoader . Game } ) ;
114- Components . Add ( gameComponent ) ;
115- }
116123 }
117124
118125 public void Dispose ( )
You can’t perform that action at this time.
0 commit comments