1+ using System . Reflection ;
12using COTL_API . CustomFollowerCommand ;
23using COTL_API . CustomInventory ;
34using COTL_API . CustomLocalization ;
910using COTL_API . CustomTarotCard ;
1011using COTL_API . CustomTasks ;
1112using Lamb . UI ;
13+ using Lamb . UI . FollowerInteractionWheel ;
1214using UnityEngine ;
1315
1416namespace COTL_API . Debug ;
@@ -26,6 +28,76 @@ internal class DebugManager
2628
2729 internal static RelicType DebugRelic { get ; private set ; }
2830
31+ internal static Dictionary < Type , Type > CustomClassMappings = new ( )
32+ {
33+ { typeof ( InventoryItem ) , typeof ( CustomInventoryItem ) } ,
34+ // { typeof(CommandItem), typeof(CustomFollowerCommand.CustomFollowerCommand) },
35+ // { typeof(RelicData), typeof(CustomRelicData) },
36+ // { typeof(StructureBrain), typeof(CustomStructure) },
37+ { typeof ( TarotCards ) , typeof ( CustomTarotCard . CustomTarotCard ) }
38+ } ;
39+
40+ private static string BeautifyNamespace ( string ? str )
41+ {
42+ return str is null or "" ? "" : str + "." ;
43+ }
44+
45+ private static void ShowDiff ( Type a , Type b )
46+ {
47+ LogDebug ( $ "Showing diff between { BeautifyNamespace ( a . Namespace ) } { a . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } ") ;
48+
49+ LogDebug ( "Methods" ) ;
50+ foreach ( var method in a . GetMethods ( ) )
51+ {
52+ if ( method . Name . StartsWith ( "get_" ) || method . Name . StartsWith ( "set_" ) )
53+ continue ;
54+
55+ var corrspondingMethod = b . GetMethods ( ) . FirstOrDefault ( m => m . Name == method . Name ) ;
56+
57+ if ( corrspondingMethod is null )
58+ {
59+ LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } : missing corrsponding method") ;
60+ continue ;
61+ }
62+
63+ if ( ! method . ReturnType . IsAssignableFrom ( corrspondingMethod . ReturnType ) )
64+ {
65+ LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } have mismatched return type") ;
66+ continue ;
67+ }
68+
69+ var corrospondingParameters = method . GetParameters ( ) ;
70+
71+ var parameters = method . GetParameters ( ) ;
72+
73+ if ( parameters . Length == 1 && parameters [ 0 ] . GetType ( ) . IsEnum )
74+ parameters = parameters . Skip ( 1 ) . ToArray ( ) ;
75+
76+ var parameterMatches = parameters . Length == corrospondingParameters . Length && parameters . All ( info =>
77+ {
78+ return info . ParameterType . IsAssignableFrom ( corrospondingParameters [ info . Position ] . ParameterType ) ;
79+ } ) ;
80+
81+ if ( ! parameterMatches )
82+ {
83+ LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } and { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } have mismatched parameters") ;
84+ LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } : { parameters } ") ;
85+ LogDebug ( $ "{ BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } : { corrospondingParameters } ") ;
86+ continue ;
87+ }
88+
89+ LogDebug ( $ "{ BeautifyNamespace ( a . Namespace ) } { a . Name } .{ method . Name } matches { BeautifyNamespace ( b . Namespace ) } { b . Name } .{ method . Name } ") ;
90+ }
91+ }
92+
93+ internal static void CheckCustomClasses ( )
94+ {
95+ foreach ( var type in CustomClassMappings )
96+ {
97+ ShowDiff ( type . Key , type . Value ) ;
98+ }
99+ }
100+
29101 internal static void AddDebugContent ( )
30102 {
31103 if ( DebugContentAdded ) return ;
0 commit comments