@@ -837,6 +837,58 @@ private void GetAllFieldsAndResolveGenerics(TypeDefinition type, ref List<TypeRe
837
837
GetAllFieldsAndResolveGenerics ( resolved , ref fieldTypes , genericParams ) ;
838
838
}
839
839
840
+ private void GetAllBaseTypesAndResolveGenerics ( TypeDefinition type , ref List < TypeReference > baseTypes , Dictionary < string , TypeReference > genericParameters )
841
+ {
842
+
843
+ if ( type . BaseType == null || type . BaseType . Name == "Object" )
844
+ {
845
+ return ;
846
+ }
847
+
848
+ var baseType = type . BaseType ;
849
+
850
+ var genericParams = new Dictionary < string , TypeReference > ( ) ;
851
+
852
+ if ( baseType . IsGenericInstance )
853
+ {
854
+ var genericType = ( GenericInstanceType ) baseType ;
855
+ var newGenericType = new GenericInstanceType ( baseType . Resolve ( ) ) ;
856
+ for ( var i = 0 ; i < genericType . GenericArguments . Count ; ++ i )
857
+ {
858
+ var argument = genericType . GenericArguments [ i ] ;
859
+
860
+ if ( genericParameters != null && genericParameters . ContainsKey ( argument . Name ) )
861
+ {
862
+ newGenericType . GenericArguments . Add ( genericParameters [ argument . Name ] ) ;
863
+ genericParams [ baseType . Resolve ( ) . GenericParameters [ newGenericType . GenericArguments . Count - 1 ] . Name ] = genericParameters [ argument . Name ] ;
864
+ }
865
+ else
866
+ {
867
+ newGenericType . GenericArguments . Add ( argument ) ;
868
+ }
869
+ }
870
+ baseTypes . Add ( newGenericType ) ;
871
+ }
872
+ else
873
+ {
874
+ baseTypes . Add ( baseType ) ;
875
+ }
876
+
877
+ var resolved = type . BaseType . Resolve ( ) ;
878
+ if ( type . BaseType . IsGenericInstance )
879
+ {
880
+ var genericType = ( GenericInstanceType ) type . BaseType ;
881
+ for ( var i = 0 ; i < genericType . GenericArguments . Count ; ++ i )
882
+ {
883
+ if ( ! genericParams . ContainsKey ( resolved . GenericParameters [ i ] . Name ) )
884
+ {
885
+ genericParams [ resolved . GenericParameters [ i ] . Name ] = genericType . GenericArguments [ i ] ;
886
+ }
887
+ }
888
+ }
889
+ GetAllBaseTypesAndResolveGenerics ( resolved , ref baseTypes , genericParams ) ;
890
+ }
891
+
840
892
private void ProcessNetworkBehaviour ( TypeDefinition typeDefinition , string [ ] assemblyDefines )
841
893
{
842
894
var rpcHandlers = new List < ( uint RpcMethodId , MethodDefinition RpcHandler ) > ( ) ;
@@ -898,6 +950,34 @@ private void ProcessNetworkBehaviour(TypeDefinition typeDefinition, string[] ass
898
950
}
899
951
}
900
952
}
953
+ {
954
+ var baseTypes = new List < TypeReference > ( ) ;
955
+
956
+ var genericParams = new Dictionary < string , TypeReference > ( ) ;
957
+ var resolved = type . Resolve ( ) ;
958
+ if ( type . IsGenericInstance )
959
+ {
960
+ var genericType = ( GenericInstanceType ) type ;
961
+ for ( var i = 0 ; i < genericType . GenericArguments . Count ; ++ i )
962
+ {
963
+ genericParams [ resolved . GenericParameters [ i ] . Name ] = genericType . GenericArguments [ i ] ;
964
+ }
965
+ }
966
+
967
+ GetAllBaseTypesAndResolveGenerics ( type . Resolve ( ) , ref baseTypes , genericParams ) ;
968
+ foreach ( var baseType in baseTypes )
969
+ {
970
+ if ( baseType . Resolve ( ) . Name == typeof ( NetworkVariable < > ) . Name || baseType . Resolve ( ) . Name == typeof ( NetworkList < > ) . Name )
971
+ {
972
+ var genericInstanceType = ( GenericInstanceType ) baseType ;
973
+ var wrappedType = genericInstanceType . GenericArguments [ 0 ] ;
974
+ if ( ! m_WrappedNetworkVariableTypes . Contains ( wrappedType ) )
975
+ {
976
+ m_WrappedNetworkVariableTypes . Add ( wrappedType ) ;
977
+ }
978
+ }
979
+ }
980
+ }
901
981
}
902
982
}
903
983
0 commit comments