@@ -17,6 +17,7 @@ namespace NetcodePatcher
1717 public static class Patcher
1818 {
1919 // when ran from command line
20+
2021 public static void Main ( string [ ] args )
2122 {
2223 // if not enough args
@@ -31,7 +32,7 @@ public static void Main(string[] args)
3132 var pluginPath = args [ 0 ] ;
3233 var managedPath = args [ 1 ] ;
3334 // initialize
34- Patcher . Initialize ( pluginPath , managedPath ) ;
35+ Patch ( pluginPath , managedPath ) ;
3536 }
3637
3738 public static IEnumerable < string > TargetDLLs
@@ -42,7 +43,12 @@ public static IEnumerable<string> TargetDLLs
4243 }
4344 }
4445
45- public static void Initialize ( string pluginPath , string managedPath )
46+ public static void Initialize ( )
47+ {
48+ Patch ( ) ;
49+ }
50+
51+ public static void Patch ( string pluginPath = null , string managedPath = null )
4652 {
4753 Patcher . Logger . LogMessage ( "Initializing NetcodePatcher" ) ;
4854 HashSet < string > hashSet = new HashSet < string > ( ) ;
@@ -66,14 +72,14 @@ public static void Initialize(string pluginPath, string managedPath)
6672 {
6773 foreach ( TypeDefinition typeDefinition in AssemblyDefinition . ReadAssembly ( text3 ) . MainModule . Types )
6874 {
69-
75+
7076
7177 if ( typeDefinition . BaseType != null )
7278 {
73- ; // check if subclass of NetworkBehaviour
79+ ; // check if subclass of NetworkBehaviour
7480 if ( typeDefinition . IsSubclassOf ( typeof ( NetworkBehaviour ) . FullName ) || typeDefinition . HasInterface ( typeof ( INetworkMessage ) . FullName ) || typeDefinition . HasInterface ( typeof ( INetworkSerializable ) . FullName ) )
7581 {
76-
82+
7783 hashSet . Add ( text3 ) ;
7884 break ;
7985 }
@@ -92,13 +98,13 @@ public static void Initialize(string pluginPath, string managedPath)
9298 // replace || with new line
9399 warning = warning . Replace ( "|| " , "\r \n " ) . Replace ( "||" , " " ) ;
94100 Patcher . Logger . LogWarning ( $ "Warning when patching ({ Path . GetFileName ( text4 ) } ): { warning } ") ;
95- } ,
101+ } ,
96102 ( error ) =>
97103 {
98104 error = error . Replace ( "|| " , "\r \n " ) . Replace ( "||" , " " ) ;
99105 Patcher . Logger . LogError ( $ "Error when patching ({ Path . GetFileName ( text4 ) } ): { error } ") ;
100106 } ) ;
101-
107+
102108 }
103109 catch ( Exception exception )
104110 {
0 commit comments